diff --git a/lib/Slic3r/SVG.pm b/lib/Slic3r/SVG.pm index 0179ea769..0ac286395 100644 --- a/lib/Slic3r/SVG.pm +++ b/lib/Slic3r/SVG.pm @@ -7,6 +7,8 @@ use SVG; use constant X => 0; use constant Y => 1; +our $filltype = 'evenodd'; + sub factor { return &Slic3r::SCALING_FACTOR * 10; } @@ -36,6 +38,25 @@ sub output { my $svg = svg(); + foreach my $type (qw(expolygons red_expolygons green_expolygons)) { + next if !$things{$type}; + my ($colour) = $type =~ /^(red|green)_/; + my $g = $svg->group( + style => { + 'stroke-width' => 2, + 'stroke' => $colour || 'black', + 'fill' => ($type !~ /polygons/ ? 'none' : ($colour || 'grey')), + 'fill-type' => $filltype, + }, + ); + foreach my $expolygon (@{$things{$type}}) { + my $points = join ' ', map "M $_ z", map join(" ", reverse map $_->[0]*factor() . " " . $_->[1]*factor(), @$_), @$expolygon; + $g->path( + d => $points, + ); + } + } + foreach my $type (qw(polygons polylines white_polygons green_polygons red_polygons red_polylines)) { if ($things{$type}) { my $method = $type =~ /polygons/ ? 'polygon' : 'polyline';