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