+if ($ACTGIF) {
+ open my $imgfile, '>', "test.gif" or die;
+ binmode $imgfile;
+ select $imgfile;
+
+ use GD;
+ my $ani = GD::Image->new($head->{width}, $head->{height});
+ my $bg = $ani->colorAllocate(0, 0, 0);
+ my @plot = (
+ $ani->colorAllocate(255, 0, 0),
+ $ani->colorAllocate(255, 255, 0),
+ $ani->colorAllocate(0, 255, 0),
+ $ani->colorAllocate(0, 255, 255),
+ $ani->colorAllocate(0, 0, 255),
+ $ani->colorAllocate(255, 0, 255),
+ );
+
+ print $ani->gifanimbegin;
+# print $ani->gifanimadd;
+ {
+ my $frame = GD::Image->new($ani->getBounds);
+ print $frame->gifanimadd;
+ my $length = 30 / .042;
+ my $last = 0;
+ for (@$map) {
+ my ($time, $player, $cmd, @data) = @$_;
+#$time < $length * 10 or last;
+ while ($time > $last + $length) {
+ $last += $length;
+ print $frame->gifanimadd(0, 0, 0, 32);
+# $frame = GD::Image->new($ani->getBounds);
+ }
+ if ($cmd eq "build") {
+ $frame->setPixel($data[1]>>5, $data[2]>>5, $plot[$player]);
+ }
+ elsif ($cmd eq "move" or $cmd eq "attack") {
+ $frame->setPixel($data[0]>>5, $data[1]>>5, $plot[$player]);
+# if $data[2] == 0xFFFF_FFFF;
+ }
+ }
+# add_frame_data($frame);
+ print $frame->gifanimadd;
+ }
+ print $ani->gifanimend;
+ select STDOUT;
+}
+