fixed spirograph to work with textext; some cleanings in colorize paths

This commit is contained in:
Mario Voigt 2021-05-15 15:35:30 +02:00
parent 4e9301c8de
commit ed10bf466d
3 changed files with 71 additions and 62 deletions

View File

@ -3,10 +3,11 @@
<name>Colorize Path Lengths</name>
<id>fablabchemnitz.de.pathselection</id>
<param name="selection" type="optiongroup" appearance="combo" gui-text="Selection: ">
<option value="Path_lengthselection">Length_selection</option>
<option value="Path_slantselection">Slant_selection</option>
<option value="path_lengthselection">Length selection</option>
<option value="path_slantselection">Slant selection</option>
</param>
<param name="len1" type="float" gui-text="Len1: red &lt; (px)" min="1" max="100">12</param>
<label>Unit for lengths is px</label>
<param name="len1" type="float" gui-text="Len1: red &lt;" min="1" max="100">12</param>
<param name="len2" type="float" gui-text="Len2: green &lt; =" min="1" max="100">25</param>
<param name="len3" type="float" gui-text="Len3: greenyellow &lt; =" min="1" max="100">40</param>
<param name="len4" type="float" gui-text="Len4: skyblue &lt; =" min="1" max="100">60</param>

View File

@ -69,8 +69,9 @@ class Length(inkex.EffectExtension):
def effect(self):
# loop over all selected paths
if self.options.selection=="Path_lengthselection":
for id, node in self.svg.selected.items():
if self.options.selection=="path_lengthselection":
if len(self.svg.selected) > 0:
for node in self.svg.selected.values():
if node.tag == inkex.addNS('path','svg'):
l1,l2,l3,l4,l5=[],[],[],[],[]
p = paths.CubicSuperPath(inkex.paths.Path(node.get('d')))
@ -99,9 +100,13 @@ class Length(inkex.EffectExtension):
'stroke': i, 'stroke-linecap': 'butt', 'fill': 'none'}
attribs={'style':str(inkex.Style(s)),'d':str(paths.Path(paths.CubicSuperPath(x).to_path().to_arrays()))}
etree.SubElement(node.getparent(),inkex.addNS('path','svg'),attribs)
else:
self.msg('Please select some paths first.')
return
if self.options.selection=="Path_slantselection":
for id, node in self.svg.selected.items():
if self.options.selection=="path_slantselection":
if len(self.svg.selected) > 0:
for node in self.svg.selected.values():
if node.tag == inkex.addNS('path','svg'):
hor1,ver2,slan3=[],[],[]
p = paths.CubicSuperPath(inkex.paths.Path(node.get('d')))
@ -125,6 +130,9 @@ class Length(inkex.EffectExtension):
'stroke': i, 'stroke-linecap': 'butt', 'fill': 'none'}
attribs={'style':str(inkex.Style(s)),'d':str(paths.Path(paths.CubicSuperPath(x).to_path().to_arrays()))}
etree.SubElement(node.getparent(),inkex.addNS('path','svg'),attribs)
else:
self.msg('Please select some paths first.')
return
if __name__ == '__main__':
Length().run()

View File

@ -23,7 +23,7 @@
# --------------------------------------------------------------------------------------
# Please uncomment (remove the # character) in the following line to disable LaTeX support via textext extension.
# useLatex=False
useLatex=False
import os