Added support for expolygons in Slic3r::SVG

internal-support
Alessandro Ranellucci 2013-03-11 14:23:45 +01:00
parent b7945ac790
commit e809a5bdcc
1 changed files with 21 additions and 0 deletions

View File

@ -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';