From ed10bf466d7a5a3fd8a4e1d5b105338cac25b0ea Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Sat, 15 May 2021 15:35:30 +0200 Subject: [PATCH] fixed spirograph to work with textext; some cleanings in colorize paths --- .../pathselection/pathselection.inx | 11 +- .../pathselection/pathselection.py | 120 ++++++++++-------- .../inkscapeMadeEasy/inkscapeMadeEasy_Draw.py | 2 +- 3 files changed, 71 insertions(+), 62 deletions(-) diff --git a/extensions/fablabchemnitz/pathselection/pathselection.inx b/extensions/fablabchemnitz/pathselection/pathselection.inx index 4efd9088..79ac44e3 100644 --- a/extensions/fablabchemnitz/pathselection/pathselection.inx +++ b/extensions/fablabchemnitz/pathselection/pathselection.inx @@ -3,16 +3,17 @@ Colorize Path Lengths fablabchemnitz.de.pathselection - - + + - 12 + + 12 25 40 60 - 60 + 60 0.1 - 10 + 10 path diff --git a/extensions/fablabchemnitz/pathselection/pathselection.py b/extensions/fablabchemnitz/pathselection/pathselection.py index 7836c876..bd74e18f 100644 --- a/extensions/fablabchemnitz/pathselection/pathselection.py +++ b/extensions/fablabchemnitz/pathselection/pathselection.py @@ -69,62 +69,70 @@ 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 node.tag == inkex.addNS('path','svg'): - l1,l2,l3,l4,l5=[],[],[],[],[] - p = paths.CubicSuperPath(inkex.paths.Path(node.get('d'))) - slengths= csplength(p) - b=[slengths, p] - - # path length select - for x in range(0,len(slengths)): - if sum(b[0][x])sum(b[0][x])>=self.options.len1 : - l2.append(b[1][x]) - if self.options.len3>sum(b[0][x])>=self.options.len2 : - l3.append(b[1][x]) - if self.options.len4>sum(b[0][x])>=self.options.len3 : - l4.append(b[1][x]) - if sum(b[0][x])>=self.options.len4 : - l5.append(b[1][x]) - - # make path - lensel=[l1,l2,l3,l4,l5] - strlen=['#FF0001','#00FF02','#AAFF03','#87CEE4','#000FF5'] - for i,x in zip(strlen,lensel): - s = {'stroke-linejoin': 'miter', 'stroke-width': '0.5px', - 'stroke-opacity': '1.0', 'fill-opacity': '1.0', - '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) - - if self.options.selection=="Path_slantselection": - for id, node in self.svg.selected.items(): - if node.tag == inkex.addNS('path','svg'): - hor1,ver2,slan3=[],[],[] - p = paths.CubicSuperPath(inkex.paths.Path(node.get('d'))) - - # path slant select - for i,x in enumerate(p): - tn=roughBBox(x) - if tnself.options.ver: - ver2.append(p[i]) - else: - slan3.append(p[i]) - - # make path - slnsel=[hor1,ver2,slan3] - strsln=['#FF0001','#00FF02','#000FF5'] - for i,x in zip(strsln,slnsel): - s = {'stroke-linejoin': 'miter', 'stroke-width': '0.5px', - 'stroke-opacity': '1.0', 'fill-opacity': '1.0', - '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) + 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'))) + slengths= csplength(p) + b=[slengths, p] + + # path length select + for x in range(0,len(slengths)): + if sum(b[0][x])sum(b[0][x])>=self.options.len1 : + l2.append(b[1][x]) + if self.options.len3>sum(b[0][x])>=self.options.len2 : + l3.append(b[1][x]) + if self.options.len4>sum(b[0][x])>=self.options.len3 : + l4.append(b[1][x]) + if sum(b[0][x])>=self.options.len4 : + l5.append(b[1][x]) + + # make path + lensel=[l1,l2,l3,l4,l5] + strlen=['#FF0001','#00FF02','#AAFF03','#87CEE4','#000FF5'] + for i,x in zip(strlen,lensel): + s = {'stroke-linejoin': 'miter', 'stroke-width': '0.5px', + 'stroke-opacity': '1.0', 'fill-opacity': '1.0', + '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": + 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'))) + + # path slant select + for i,x in enumerate(p): + tn=roughBBox(x) + if tnself.options.ver: + ver2.append(p[i]) + else: + slan3.append(p[i]) + + # make path + slnsel=[hor1,ver2,slan3] + strsln=['#FF0001','#00FF02','#000FF5'] + for i,x in zip(strsln,slnsel): + s = {'stroke-linejoin': 'miter', 'stroke-width': '0.5px', + 'stroke-opacity': '1.0', 'fill-opacity': '1.0', + '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() \ No newline at end of file diff --git a/extensions/fablabchemnitz/spirograph/inkscapeMadeEasy/inkscapeMadeEasy_Draw.py b/extensions/fablabchemnitz/spirograph/inkscapeMadeEasy/inkscapeMadeEasy_Draw.py index d9839709..664b6324 100644 --- a/extensions/fablabchemnitz/spirograph/inkscapeMadeEasy/inkscapeMadeEasy_Draw.py +++ b/extensions/fablabchemnitz/spirograph/inkscapeMadeEasy/inkscapeMadeEasy_Draw.py @@ -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