mirror of
https://github.com/brmlab/lasic.git
synced 2025-06-08 01:03:59 +02:00
svg.pl: Frontent for SVG rendering
This commit is contained in:
parent
3e76f2d552
commit
d881d154fd
1 changed files with 41 additions and 0 deletions
41
perl/svg.pl
Executable file
41
perl/svg.pl
Executable file
|
@ -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);
|
Loading…
Add table
Add a link
Reference in a new issue