Just a little Tk script to demonstrate the "persistence-of-image" problem in eyes. It's safer than looking at the sun. :-) Just stare at the cross-hairs, you should see a pink orb, where there is none.
UPDATE: I fixed a logic error which caused it to skip at 7 o'clock.
#!/usr/bin/perl use warnings; use strict; use Tk; # stare at the cross-hairs, a pink orb # should appear rotating, where there is none my $mw = MainWindow->new(); # first create a canvas widget my $canvas = $mw->Canvas(width => 600, height => 600, -bg => 'gray', )->pack(); my %pos; my $angle = 0; my $radius = 200; my $pos; my $hidden = 0; foreach my $pos(0..11){ my $x = 300 + sin($angle)*$radius; my $y = 300 + cos($angle)*$radius; my $x1 = $x - 40; my $y1= $y - 40; $pos{$pos} = $canvas->createOval($x,$y,$x1,$y1, -fill => 'green', -outline=>'green', -tags => [$pos], # -stipple => 'gray75', ); $angle += .5236; # (pi / 180) * 30 } $canvas->createLine(260,280,300,280, -width=>5, -fill=>'black'); $canvas->createLine(280,260,,280,300, -width=>5, -fill=>'black'); my $ebutton = $mw->Button(-text => 'Exit', -command => 'Tk::exit')->pack(); $pos = 0; my $timer = $mw->repeat(100,sub{ $canvas->itemconfigure($pos{$hidden} , -state => 'normal'); $canvas->itemconfigure($pos{$pos}, -state => 'hidden'); $hidden = $pos; $pos++; if($pos == 12){ $pos=0 }; }); MainLoop();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Tk Optical Illusion
by Celada (Monk) on Dec 13, 2005 at 17:04 UTC | |
by zentara (Archbishop) on Dec 13, 2005 at 17:47 UTC | |
by ambrus (Abbot) on Dec 13, 2005 at 18:20 UTC | |
by Celada (Monk) on Dec 13, 2005 at 19:26 UTC | |
by zentara (Archbishop) on Dec 13, 2005 at 20:27 UTC | |
by arkturuz (Curate) on Dec 14, 2005 at 13:22 UTC |
Back to
Cool Uses for Perl