use strict;
use warnings;
+use Getopt::Long 2.33 qw(HelpMessage :config bundling);
use Template;
use List::Util;
use Data::Dumper;
+our $VERSION = '1.00';
+
+GetOptions(
+ "verbose|v!" => \our $DEBUG,
+) or HelpMessage(-exitval => 2);
+
my %area = (
fieldxmin => 45,
fieldxmax => 1590,
}
}
+ for (0 .. 3) {
+ my $line = $lines[$_][$player];
+ my $start;
+ my $lasty;
+ for (my $i = 1; $i <= $#$line; $i++) {
+ defined $line->[$i] or next;
+ if ($line->[$i][1] == $line->[$i - 1][1]) {
+ $start = $i unless defined $start;
+ } elsif (defined $start) {
+ delete @$line[$start .. $i-2];
+ undef $start;
+ }
+ }
+ delete @$line[$start .. $#$line-2] if defined $start; # or -1
+ }
+
$player++;
}
+$max[2] = $max[3];
my @norm = ((map {$area{fieldysize} / $_} @max), $area{fieldxsize} / $maxtime);
my $xsteps = 25;
open my $output, '>', "$filename.svg";
$svg->process('timeline', {
title => "$title timeline for /replay/20080201md4x4",
+ fill => $line == 2 && [
+ map { "\n\tM " . join "\tL ", map sprintf("%s %s\n",
+ $area{fieldxmin} + $_->[0] * $norm[4],
+ $area{fieldymax} - $_->[1] * $norm[$line+1]
+ ), grep defined, @{$lines[$line][$_]}, reverse @{$lines[$line+1][$_]} } 0 .. $#{$lines[$line]}
+ ],
paths => [
map { "\n\tM " . join "\tL ", map sprintf("%s %s\n",
$area{fieldxmin} + $_->[0] * $norm[4],
[% END %]
</g>
+[% IF fill %]
+<g class="data">
+[% count = 0 %]
+[% FOREACH path = fill %][% count = count + 1 %]
+<path d="[% path %]" class="fill[% count %]" />
+[% END %]
+</g>
+[% END %]
+
</svg>