]> git.sesse.net Git - ultimatescore/blob - stinger/sting.pl
480eff67d7f65f2d142274c724a47d4a66c2d280
[ultimatescore] / stinger / sting.pl
1 #! /usr/bin/perl
2 use strict;
3 use warnings;
4 use POSIX qw(ceil floor);
5
6 for my $i (0..24) {
7 #for my $i (23..23) {
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 :-/
11
12         for my $j (0..97) {  # 98 hits a movit limit!
13                 #my $f = $i / 50.0;
14                 my $f = $i / 25.0 + ($j * 0.010) / 25.0;
15                 #my $f = $i / 255.0;
16
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";
20
21                 my $w = int((($x2 - $x1) / 25.4) * $d * $convfactor + 0.5);
22                 my $h = int((($y2 - $y1) / 25.4) * $d * $convfactor + 0.5);
23
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);
30
31                         $w = floor($w / 2);
32                         $h = floor($h / 2);
33                 }
34
35                 my $cmd = "LANG=C inkscape --export-png=$outfilename --export-area=$x1:$y1:$x2:$y2 --export-width=$w --export-height=$h stinger.svg";
36         #       print "$cmd\n";
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);
41
42 #               my $extent = "";
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);
47 #               }
48 #
49 #               my $left = int(($w - 1280) / 2);
50 #               my $top = int(($h - 720) / 2);
51 #
52 #               system("convert $extent -crop 1280x720+${left}+$top stinger.png $outfilename");
53                 push @args, $outfilename;
54         }
55         system(@args);
56         print join(' ', @args), " -> $i\n";
57         rename("blurout.png", sprintf("blur%03d.png", $i));
58 }