File: animate.pl

package info (click to toggle)
prima 1.28-1.3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,356 kB
  • ctags: 10,513
  • sloc: ansic: 62,743; perl: 59,268; cpp: 2,861; makefile: 94; sed: 16
file content (68 lines) | stat: -rw-r--r-- 1,566 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# $Id: animate.pl,v 1.2 2008/04/25 08:17:35 dk Exp $
use strict;
use Prima qw(Application Image::AnimateGIF);

my $clip_debug = 0;

unless ( @ARGV) {
	my $f = $0;
	$f =~ s/([\\\/]|^)([^\\\/]*)$/$1/;
	$f .= "../Prima/sys/win32/sysimage.gif";
	print "(no argument given, trying to find at least $f...";
	if ( -f $f) {
		print "ok)\n";
		print "Next time specify some GIF animation as an argument\n";
		@ARGV = ($f);
	} else {
		print "nopes)\n";
		die "Please specify some GIF animation as an argument\n";
	}
}

my $x = Prima::Image::AnimateGIF->load($ARGV[0]);
die "Can't load $ARGV[0]:$@\n" unless $x;

my ( $X, $Y) = ( 100, 100);
my $g = $::application-> get_image( $X, $Y, $x-> size);

$::application-> begin_paint;

my $break;

$SIG{INT} = sub { $break++ };
while ( my $info = $x-> next) {
	my $c = $g-> dup;
	$c-> begin_paint;
	$x-> draw( $c, 0, 0);

	$::application-> clipRect(
		$X + $info-> {left},
		$Y + $info-> {bottom},
		$X + $info-> {right},
		$Y + $info-> {top},
	) if $clip_debug;

	$::application-> color(cl::Red);
	$::application-> rop(rop::XorPut);
	my @r = (
		$X + $info-> {left},
		$Y + $info-> {bottom},
		$X + $info-> {right},
		$Y + $info-> {top},
	);
	for ( 1..10) {
		next unless $clip_debug;
		$::application-> bar(@r);
		select(undef,undef,undef,0.03);
	}
	$::application-> rop(rop::CopyPut);
	$::application-> put_image( $X, $Y, $c);
	
	$::application-> sync;
	select(undef, undef, undef, $info-> {delay});

	last if $break;
}

$::application-> clipRect(0,0,$::application-> size);
$::application-> put_image( $X, $Y, $g, rop::CopyPut);