10 my $current = \@array;
16 next if $l =~ s/\\$//;
19 if (m/^\!(\w+)\s*\(\)\s*\{$/) {
21 die if $current ne \@array;
22 die if exists $procs{$pname};
23 $current = $procs{$pname} = [];
42 defvar('extruderate',0.097200);
43 defvar('feedrate',540);
44 defvar('jerkfeedrate',7800);
45 defvar('retract',4.5);
46 defvar('restart',4.5);
47 defvar('restartfeedrate',1800);
48 defvar('retractfeedrate',1800);
49 defvar('movefeedrate',7800);
57 return sprintf "%.5f", $f;
61 return "X".float_g($coords->[0])." Y".float_g($coords->[1]);
64 sub p ($) { print "$_[0]" or die $!; }
65 sub pl ($) { p("$_[0]\n"); }
78 if (m/^\!(\w+)\s*\(\)$/) {
80 die "$pname ?" unless $procs{$pname};
82 } elsif (m/^\!draw\s+/) {
83 my @coords = split /\s+/, $'; #';
84 my @undefs = grep { !defined $c{$_} } qw(zprint);
85 die "@undefs ?" if @undefs;
89 [ $`, $', !!$jerk ]; # '];
91 foreach my $co (@coords) {
92 foreach my $xy (qw(0 1)) {
94 next unless $xyv =~ s/^\@//;
95 my $orgxy = ($c{orgx},$c{orgy})[$xy];
96 $co->[$xy] = float_g($xyv + $orgxy);
99 my $extrudepos=$c{restart};
101 my $zmove=$c{zprint}+$c{zlift};
102 pl("G1 F$c{movefeedrate} Z$zmove");
103 pl("G1 ".coords_g($coords[0]));
104 pl("G1 Z$c{zprint}");
105 pl("G1 F$c{restartfeedrate} E".float_g($extrudepos));
107 foreach (my $ci=1; $ci<@coords; $ci++) {
108 my $g = "G1 ".coords_g($coords[$ci]);
110 if (!$coords[$ci][2]) {
111 $wantfeedrate=$c{feedrate};
113 foreach my $xy (qw(0 1)) {
114 my $dxy = $coords[$ci][$xy] - $coords[$ci-1][$xy];
115 $dist += $dxy * $dxy;
118 $extrudepos += $dist * $c{extruderate};
119 $g .= " E".float_g($extrudepos);
121 $wantfeedrate=$c{jerkfeedrate};
123 if ($wantfeedrate != $lastfeedrate) {
124 $g .= " F$wantfeedrate";
125 $lastfeedrate = $wantfeedrate;
129 $extrudepos -= $c{retract};
130 pl("G1 F$c{retractfeedrate} E".float_g($extrudepos));
131 pl("G1 F$c{movefeedrate} Z$zmove");
133 } elsif (m/^\!(\w+)\=(\S+)$/) {
134 die "$1 ?" unless exists $c{$1};