From d881d154fdb9d29bae4257bc5a291d48f755e53b Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 28 Dec 2011 03:31:45 +0100 Subject: [PATCH] svg.pl: Frontent for SVG rendering --- perl/svg.pl | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 perl/svg.pl diff --git a/perl/svg.pl b/perl/svg.pl new file mode 100755 index 0000000..164fee9 --- /dev/null +++ b/perl/svg.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl +# +# Render a SVG image using Brm::Lasic - pass it as a parameter! + +use warnings; +use strict; + +use lib qw(.); +use Brm::Lasic; +use Brm::Lasic::PBM; + +my $lasic = Brm::Lasic->new(dev => '/dev/ttyUSB0'); +# $lasic->reset(); + +open my $fd, '-|', '../svg/showsvg.py', $ARGV[0] or die "showsvg.py: $!"; +my @cmd = <$fd>; +chomp @cmd; +@cmd = map { + @_ = split(/ +/, $_); + die "bad SVG - unsupported object" if $_[0] eq 'fuck'; + pop @_; + [ @_ ] +} @cmd; +close $fd; + +print "Does the plot look good? Make sure the axes are based at/near zero!\n"; +open my $plot, '|-', 'gnuplot', '-e', 'set size ratio -1; plot \'-\' u 1:(-$2) with lines; pause mouse' or die "gnuplot: $!"; +foreach (@cmd) { + my @c = @$_; + next unless $c[0] eq 'v'; + print $plot "$c[2] $c[3]\n"; +} +close $plot; +print "If the plot looked wrong, press Ctrl-C now! Waiting 5 seconds.\n"; +sleep 5; + +foreach (@cmd) { + $lasic->msg(@$_); +} +$lasic->laser_off(); +$lasic->move(0, 0);