Added support for expolygons in Slic3r::SVG
This commit is contained in:
parent
b7945ac790
commit
e809a5bdcc
@ -7,6 +7,8 @@ use SVG;
|
|||||||
use constant X => 0;
|
use constant X => 0;
|
||||||
use constant Y => 1;
|
use constant Y => 1;
|
||||||
|
|
||||||
|
our $filltype = 'evenodd';
|
||||||
|
|
||||||
sub factor {
|
sub factor {
|
||||||
return &Slic3r::SCALING_FACTOR * 10;
|
return &Slic3r::SCALING_FACTOR * 10;
|
||||||
}
|
}
|
||||||
@ -36,6 +38,25 @@ sub output {
|
|||||||
|
|
||||||
my $svg = svg();
|
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)) {
|
foreach my $type (qw(polygons polylines white_polygons green_polygons red_polygons red_polylines)) {
|
||||||
if ($things{$type}) {
|
if ($things{$type}) {
|
||||||
my $method = $type =~ /polygons/ ? 'polygon' : 'polyline';
|
my $method = $type =~ /polygons/ ? 'polygon' : 'polyline';
|
||||||
|
Loading…
Reference in New Issue
Block a user