here is my lame attempt:
#!/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";
bw, bliako
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.