Imager

 view release on metacpan or  search on metacpan

samples/flasher.pl  view on Meta::CPAN


my @down;
my $down_frames = $frames / 2;
my $step = (100 - $low_pct) / $down_frames;
my $percent = 100 - $step;
++$|;
print "Generating frames\n" if $verbose;
for my $frame_no (1 .. $down_frames) {
  print "\rFrame $frame_no/$down_frames";

  # canvas with our background color
  my $canvas = Imager->new(xsize => $width, ysize => $height);
  $canvas->box(filled => 1, color => $back_color);

  # make a version of our original with the alpha scaled
  my $scale = $percent / 100.0;
  my $draw = $base->convert(matrix => [ [ 1, 0, 0, 0 ],
					[ 0, 1, 0, 0 ],
					[ 0, 0, 1, 0 ],
					[ 0, 0, 0, $scale ] ]);

  # draw it on the canvas
  $canvas->rubthrough(src => $draw);

  push @down, $canvas;
  $percent -= $step;
}
print "\n" if $verbose;

# generate a sequence going from the original down to the most faded
my @frames = $base;
push @frames, @down;
# remove the most faded frame so it isn't repeated
pop @down; 
# and back up again

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 2.802 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )