Here it is in Wx, real dirty (currently wxWidgets doesn't have a nice canvas library) .
Someone should try an OpenGL approach :)
use strict;
use Wx qw( :everything );
use Wx::Event 'EVT_PAINT';
use vars::i qw( $width 4 );
use vars::i qw( $height 4 );
use vars::i '@iterative_set' =>
(
sub {
my @pt = ( 400, 50 );
return( ( $pt[0] + $_[0] ) / 2, ( $pt[1] + $_[1] ) / 2 );
},
sub {
my @pt = ( 50, 400 );
return( ( $pt[0] + $_[0] ) / 2, ( $pt[1] + $_[1] ) / 2 );
},
sub {
my @pt = ( 750, 400 );
return( ( $pt[0] + $_[0] ) / 2, ( $pt[1] + $_[1] ) / 2 );
},
);
## cause I don't wanna subclass anything just yet
*Wx::App::OnInit = sub {
Wx::InitAllImageHandlers();
my $frame = Wx::Frame::->new(undef, -1, 'And Justice For All');
$frame->Show(1);
EVT_PAINT( $frame, sub {
my($s,$e)=@_;
my $dc = Wx::PaintDC->new($s); # must create, to stop crap
$dc->SetBackgroundMode( wxTRANSPARENT );
$dc->SetTextForeground( Wx::Colour->newRGB(169,169,69));
# start coordinates
my $x = 40;
my $y = 400;
my $iter = 0;
# weed out transients
while( $iter++ != 100 ) {
( $x, $y ) = $iterative_set[ int rand 3 ]->( $x, $y );
}
$iter = 0;
while( $iter++ < 10000 ) {
( $x, $y ) = $iterative_set[ int rand 3 ]->( $x, $y );
$dc->DrawRectangle( int $x, int $y, $width,$height);
}
return 0;
});
return 1;
};
Wx::App->new->MainLoop; # we're off'n'runnin'now
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" |
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). |
** The third rule of perl club is a statement of fact: pod is sexy. |