#!/usr/bin/env perl # Last MODIFIED: Mon Aug 11 12:34:52 UTC 2008 no locale; use Cwd ('cwd'); use File::Spec; use Tk; use Tk::widgets qw( Frame Photo ); use strict; select STDERR; $| = 1; select STDOUT; $| = 1; use constant ROWLEN => 2; use constant GRFORMAT => "gif"; $\ = "\n"; my $pwd = cwd; my $mw = MainWindow->new; $mw->geometry("+10+90"); my $pixframe = $mw->Frame(); my @XColors = qw(midnightblue turquoise gold salmon) ; my @Fractal = map { 'TileP_'. $_ .'.'. GRFORMAT } @XColors; print STDERR qq|Using files |, join q| |, @Fractal; unless ( scalar(@XColors) == grep { -f } @Fractal ) { # Create images programmatically using the sh shell and ImageMagick # if we did not already make them system q{for COLT in }. join(q[ ]=>@XColors) .q{; do convert -size 356x356 fractal:$COLT -depth 8 -geometry 64x64 } .q{-colors 256 }. GRFORMAT .q{:TileP_$COLT.} . GRFORMAT .q{ ; done} and die "Uh-oh, we didn't get our images made"; } my $section = 0; for ( 1 .. ROWLEN ) { my $rndx = $_; my @across; my $name = "Imfz"; my @imgstrip = map { File::Spec->catfile($pwd => $_) } @Fractal [ $section .. ($section + ROWLEN - 1) ]; # print STDERR "Image strip is @imgstrip"; my $Col_0_Pic = $pixframe->Photo( '-format' => GRFORMAT , '-file' => $imgstrip[0]); for my $imgwi ( @imgstrip ) { print STDERR "Attempting to add image \"$imgwi\" to row $rndx now."; ++${name}; my $Photo = $pixframe->Photo(-format=> GRFORMAT, -file=> $imgwi); printf STDERR 'Seeing img with width %3u and height %3u in format %s'."\n" , $Photo->width() , $Photo->height(), $Photo->cget('-format'); # print STDERR for keys %$Photo; push @across, $Photo; } $Col_0_Pic->Tk::grid ( @across[1 .. $#across] ); $section += ROWLEN; } $pixframe->pack(); MainLoop; exit 0;