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,16 +3,17 @@
<name>Colorize Path Lengths</name> <name>Colorize Path Lengths</name>
<id>fablabchemnitz.de.pathselection</id> <id>fablabchemnitz.de.pathselection</id>
<param name="selection" type="optiongroup" appearance="combo" gui-text="Selection: "> <param name="selection" type="optiongroup" appearance="combo" gui-text="Selection: ">
<option value="Path_lengthselection">Length_selection</option> <option value="path_lengthselection">Length selection</option>
<option value="Path_slantselection">Slant_selection</option> <option value="path_slantselection">Slant selection</option>
</param> </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="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="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> <param name="len4" type="float" gui-text="Len4: skyblue &lt; =" min="1" max="100">60</param>
<param name="len5" type="float" gui-text="Len5: blue &gt; " min="1" max="100">60</param> <param name="len5" type="float" gui-text="Len5: blue &gt;" min="1" max="100">60</param>
<param name="hor" type="float" gui-text="hor: red &lt; (H/W)" min="0.01" max="100">0.1</param> <param name="hor" type="float" gui-text="hor: red &lt; (H/W)" min="0.01" max="100">0.1</param>
<param name="ver" type="float" gui-text="ver: blue &gt; " min="1" max="100">10</param> <param name="ver" type="float" gui-text="ver: blue &gt;" min="1" max="100">10</param>
<effect> <effect>
<object-type>path</object-type> <object-type>path</object-type>
<effects-menu> <effects-menu>

View File

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

View File

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