Skip to content

Instantly share code, notes, and snippets.

@devdsp
Created November 14, 2013 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdsp/7461886 to your computer and use it in GitHub Desktop.
Save devdsp/7461886 to your computer and use it in GitHub Desktop.
a few unfinished scripts for the Roland GRX400 drafting plotter
#!/usr/bin/perl
use strict;
use warnings;
my ($minx,$miny,$maxx,$maxy);
while(<>) {
chomp;
foreach my $cmd (split/;/) {
if( $cmd =~ m/^(PU|PD|PA)([-\d]+),([-\d]+)$/ ) {
$minx = defined $minx && $minx < $2 ? $minx : $2;
$maxx = defined $maxx && $maxx > $2 ? $maxx : $2;
$miny = defined $miny && $miny < $3 ? $miny : $3;
$maxy = defined $maxy && $maxy > $3 ? $maxy : $3;
# print "$cmd;\n";
}
}
}
print "height: 10680\n";
print "-5340 > x > 5340\n";
print "$minx > x > $maxx\n";
print (($maxx - $minx) /2,"\n");
print "--\n";
print "width: 6240\n";
print "-3120 > x > 3120\n";
print "$miny > y > $maxy\n";
print (($maxx - $miny) /2,"\n");
print "SC$minx,$maxx,$miny,$maxy;\n";
#!/usr/bin/perl
use strict;
use warnings;
while(<>) {
  chomp;
  foreach my $cmd (split/;/) {
    print "$cmd;" unless ( $cmd =~ m/^(BP|PS|WU|TR|LA|PW)/);
  }
  print "\n";
}
#!/usr/bin/perl
use strict;
use warnings;
print "IN;SP2;PU;PA0,0;\n";
my $width = 5340*2;
my $height = 3120*2;
print "PA",-$width/2,",",-$height/2,";\n";
print "PD",-$width/2,",",+$height/2,";\n";
print "PD",+$width/2,",",+$height/2,";\n";
print "PD",+$width/2,",",-$height/2,";\n";
print "PD",-$width/2,",",-$height/2,";\n";
print "PU;PA0,0;\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment