#!/usr/bin/perl # # 100 simultaneous supernovae collapse into a supermassive blackhole! # This makes a pretty picture by incrementing the sigma values on the # sample data resulting in an animated GIF. Please feel free to hack # it up and post your version! use strict; use warnings; use Imager::Heatmap; my $filename = 'heatmapa.gif'; my @insert ; my @images = (); $| = 1; print "Generating GIF frame "; my $text = Imager->new(xsize=>300,ysize=>30); $text->box( color => Imager::Color->new(255, 255, 255), filled=>1 ); my $black = Imager::Color->new("#000000"); my $font = Imager::Font->new( file => '/usr/share/fonts/open-sans/OpenSans-Semibold.ttf', color => $black, size => 25); my $japh = "Just another Perl hacker,"; $text->string(font=>$font, text=>$japh, color=>$black, x=>1, y=>20); $text->write(file=>'fuck.png', type=>'png') or die "Cannot write: ",$text->errstr; for my $x (0..299){ for my $y (0..24){ my $pix = ($text->getpixel(x=>$x, y=>$y, type=>'8bit')->rgba())[0]; next if( $pix == 0 ); push @insert, [ $x, $y, $pix ] ; } } for my $x ('1'..'10') { my $hmap = Imager::Heatmap->new( xsize => 300, ysize => 30, xsigma => $x, ysigma => $x, ); $hmap->insert_datas(@insert); push @images, $hmap->draw; print "$x " } print "done!\n"; Imager->write_multi({ file => $filename, transp => 'none', gif_loop => 0, }, @images); print "Saved $filename\n";