I was looking at
Animated Heatmap, with a view to making a PDL version. It has animation, which I remembered adding to PDL::IO::Pic, with a fun demo script making a bouncing ball, visible at
https://metacpan.org/pod/PDL::IO::Pic#wmpeg:
use strict; use warnings;
use PDL;
use PDL::IO::Pic;
my ($width, $height, $framecount, $xvel, $maxheight, $ballsize) = (320
+, 80, 100, 15, 60, 8);
my $frames = zeros byte, $width, $height, $framecount;
my $coords = yvals(3, $framecount); # coords for drawing ball, all val
+=frameno
my ($xcoords, $ycoords) = map $coords->slice($_), 0, 1;
$xcoords *= $xvel; # moves $xvel pixels/frame
$xcoords .= $width - abs(($xcoords % (2*$width)) - $width); # back and
+ forth
my $sqrtmaxht = sqrt $maxheight;
$ycoords .= indx($maxheight - ((($ycoords % (2*$sqrtmaxht)) - $sqrtmax
+ht)**2));
my $val = pdl(byte,250); # start with white
$frames->range($coords, [$ballsize,$ballsize,1], 't') .= $val;
$frames = $frames->dummy(0, 3)->copy; # now make the movie
$frames->wmpeg('bounce.gif'); # or bounce.mp4, ffmpeg deals OK
Running this with:
perl scriptname.pl && animate bounce.gif