added support for group/child handling for reverse order of subpaths
This commit is contained in:
parent
c7879f3daa
commit
782afcf3f6
@ -21,22 +21,25 @@ from inkex import PathElement, CubicSuperPath
|
|||||||
|
|
||||||
class ReverseOrderSubpaths(inkex.EffectExtension):
|
class ReverseOrderSubpaths(inkex.EffectExtension):
|
||||||
|
|
||||||
def effect(self):
|
def reverse(self, element):
|
||||||
"""Reverse order of subpaths (combined paths) without reversing node-order or order of paths"""
|
if element.tag == inkex.addNS('path','svg'):
|
||||||
if not self.svg.selected:
|
|
||||||
raise inkex.AbortExtension("Please select an object.")
|
|
||||||
for id, elem in self.svg.selection.id_dict().items():
|
|
||||||
|
|
||||||
new = []
|
new = []
|
||||||
sub=elem.path.to_superpath()
|
sub = element.path.to_superpath()
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(sub):
|
while i < len(sub):
|
||||||
new.append(sub[-1-i])
|
new.append(sub[-1-i])
|
||||||
i += 1
|
i += 1
|
||||||
|
element.path = CubicSuperPath(new).to_path(curves_only=True)
|
||||||
|
elif element.tag == inkex.addNS('g','svg'):
|
||||||
|
for child in element.getchildren():
|
||||||
|
self.reverse(child)
|
||||||
|
|
||||||
elem.path = CubicSuperPath(new).to_path(curves_only=True)
|
def effect(self):
|
||||||
|
"""Reverse order of subpaths (combined paths) without reversing node-order or order of paths"""
|
||||||
|
if not self.svg.selected:
|
||||||
|
raise inkex.AbortExtension("Please select an object.")
|
||||||
|
for element in self.svg.selection.values():
|
||||||
|
self.reverse(element)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
ReverseOrderSubpaths().run()
|
ReverseOrderSubpaths().run()
|
Reference in New Issue
Block a user