4 use POSIX qw(ceil floor);
8 my @args = ("./stinger/blur");
9 my ($x1, $y1, $x2, $y2) = (0, 0, 346.547, 202.492); # From Inkscape output when converting by default.
10 my $convfactor = 0.26458; # mm to SVG units, empirical :-/
12 for my $j (0..97) { # 98 hits a movit limit!
14 my $f = $i / 25.0 + ($j * 0.010) / 25.0;
17 my $d = 90.0 / (1.0 - $f) - 80.0;
18 my $outfilename = sprintf("stinger%03d.png", $i * 10 + $j);
19 print "$outfilename [$d]...\n";
21 my $w = int((($x2 - $x1) / 25.4) * $d * $convfactor + 0.5);
22 my $h = int((($y2 - $y1) / 25.4) * $d * $convfactor + 0.5);
24 while ($w >= 1280*2 && $h >= 720*2) {
25 my $newx1 = $x1 + 0.25 * ($x2 - $x1);
26 my $newy1 = $y1 + 0.25 * ($y2 - $y1);
27 my $newx2 = $x1 + 0.75 * ($x2 - $x1);
28 my $newy2 = $y1 + 0.75 * ($y2 - $y1);
29 ($x1, $y1, $x2, $y2) = ($newx1, $newy1, $newx2, $newy2);
35 my $cmd = "LANG=C inkscape --export-png=$outfilename --export-area=$x1:$y1:$x2:$y2 --export-width=$w --export-height=$h stinger.svg";
37 system("$cmd 2>/dev/null >/dev/null");
38 #my $x = `$cmd 2>/dev/null`;
39 #$x =~ /exported to (\d+) x (\d+)/ or die "$x";
40 #my ($w, $h) = ($1, $2);
43 # if ($w < 1280 || $h < 720) {
44 # $w = 1280 if ($w < 1280);
45 # $h = 720 if ($h < 720);
46 # $extent = sprintf("-background #00000000 -gravity center -extent %dx%d", $w, $h);
49 # my $left = int(($w - 1280) / 2);
50 # my $top = int(($h - 720) / 2);
52 # system("convert $extent -crop 1280x720+${left}+$top stinger.png $outfilename");
53 push @args, $outfilename;
56 print join(' ', @args), " -> $i\n";
57 rename("blurout.png", sprintf("blur%03d.png", $i));