From: Shiar Date: Wed, 6 Feb 2008 21:39:30 +0000 (+0100) Subject: simplify paths produced by graphplay X-Git-Url: http://git.shiar.nl/perl/schtarr.git/commitdiff_plain/9b6efb5f25ff032a46a2f6bc9b4f3501c9d7b47c?hp=acea822c3a40b7e74b8d390f6c4d497eface0b56 simplify paths produced by graphplay Only keep first and last entries for identical values. In other words, horizontal lines will not have each pixel specified, but only the two corners. This already results in significantly smaller files (test case went from 1.8MB to 1.5MB, and to just 130kB for unit graphs!). The same thing should be done for sloped lines, but this is not as obviously simple. --- diff --git a/graphplay b/graphplay index d6baebf..9956168 100755 --- a/graphplay +++ b/graphplay @@ -54,6 +54,22 @@ for my $input (@ARGV) { } } + for (0 .. 2) { + 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++; }