fixes in polygon and netting extension

This commit is contained in:
Mario Voigt 2021-05-30 11:14:40 +02:00
parent 16ef1c7627
commit 718cdec4b3
2 changed files with 17 additions and 9 deletions

View File

@ -51,12 +51,20 @@ class Netting(inkex.EffectExtension):
if self.options.netting_type == "allwithall": if self.options.netting_type == "allwithall":
allnet_group = inkex.Group(id="g" + element.get('id')) allnet_group = inkex.Group(id="g" + element.get('id'))
pathsCollection = []
self.svg.get_current_layer().append(allnet_group) self.svg.get_current_layer().append(allnet_group)
for segment1 in range(0, len(old_segments)): for segment1 in range(0, len(old_segments)):
for segment2 in range(1, len(old_segments)): for segment2 in range(1, len(old_segments)):
if old_segments[segment1] != old_segments[segment2]:
pathVariant1 = Path('M' + old_segments[segment1] + ' L' + old_segments[segment2])
pathVariant2 = Path('M' + old_segments[segment2] + ' L' + old_segments[segment1]) #the reversed one
if pathVariant1 not in pathsCollection and pathVariant2 not in pathsCollection:
pathsCollection.append(pathVariant1)
for p in pathsCollection:
allnet_path = inkex.PathElement() allnet_path = inkex.PathElement()
allnet_path.style = style allnet_path.style = style
allnet_path.path = Path('M' + old_segments[segment1] + ' L' + old_segments[segment2]) allnet_path.path = p
allnet_group.append(allnet_path) allnet_group.append(allnet_path)
elif self.options.netting_type == "alternatingly": elif self.options.netting_type == "alternatingly":

View File

@ -87,11 +87,6 @@ class Polygon(inkex.EffectExtension):
widthDoc = self.svg.unittouu(svg.get('width')) widthDoc = self.svg.unittouu(svg.get('width'))
heightDoc = self.svg.unittouu(svg.get('height')) heightDoc = self.svg.unittouu(svg.get('height'))
# Create a new layer.
layer = etree.SubElement(svg, 'g')
layer.set(inkex.addNS('label', 'inkscape'), 'newlayer')
layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer')
parent=self.svg.get_current_layer() parent=self.svg.get_current_layer()
# Get script's option values. # Get script's option values.
@ -166,6 +161,11 @@ class Polygon(inkex.EffectExtension):
groupdraw(s,[color1,color2]) groupdraw(s,[color1,color2])
if self.options.displaylasertag: if self.options.displaylasertag:
# Create a new layer.
layer = etree.SubElement(svg, 'g')
layer.set(inkex.addNS('label', 'inkscape'), 'lasertag')
layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer')
tag_1=lasertag tag_1=lasertag
tag_1=tag_1.replace("%n",str(pass_offset+1)).replace("%s",str(speed)).replace("%i",str(intensity)).replace("%c",str(color2)) tag_1=tag_1.replace("%n",str(pass_offset+1)).replace("%s",str(speed)).replace("%i",str(intensity)).replace("%c",str(color2))
tag_2=lasertag tag_2=lasertag