Thread Jeden Pixel färben ??? (20 answers)
Opened by Matze at 2005-11-24 22:53

ptk
 2005-11-26 18:46
#45060 #45060
User since
2003-11-28
3645 Artikel
ModeratorIn
[default_avatar]
Ich würde in diesem Fall auch mit Tk::Photo arbeiten, mit der Methode put. Aber ein Rennpferd dürfte das nicht sein. Unter Umständen ist es schneller, auf eine externe Bibliothek (GD, Imager, Image::Magick) auszuweichen.
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
use Tk;
$top = new MainWindow;
$p = $top->Photo(-width => 400, -height => 300);
$c = $top->Canvas(-width => 400, -height => 300)->pack(-fill => "both", -expand => 1);
$img = $c->createImage(0,0,-image=>$p,-anchor=>"nw");
for my $x (-$p->width/2 .. $p->width/2) {
my($tx) = int($x+$p->width/2);
my $y = sin($x/10)*$p->height/2;
my($ty) = int($y+$p->height/2);
$p->put("#ff0000", -to => $tx,$ty+1,$tx+1,$ty);
}
MainLoop;

View full thread Jeden Pixel färben ???