From 8386b76eda844b42eb6730417dfc57d028057e68 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Sun, 25 Apr 2021 23:29:07 +0200 Subject: [PATCH] added reverse subpaths and number subpaths extensions --- .../animate_order/animate_order.html | 18 - .../fablabchemnitz/animate_order/drawing.svg | 494 ------------------ .../fablabchemnitz/path_number_subpaths.inx | 27 + .../fablabchemnitz/path_number_subpaths.py | 84 +++ .../fablabchemnitz/reverse_order_subpaths.inx | 17 + .../fablabchemnitz/reverse_order_subpaths.py | 42 ++ 6 files changed, 170 insertions(+), 512 deletions(-) delete mode 100644 extensions/fablabchemnitz/animate_order/animate_order.html delete mode 100644 extensions/fablabchemnitz/animate_order/drawing.svg create mode 100644 extensions/fablabchemnitz/path_number_subpaths.inx create mode 100644 extensions/fablabchemnitz/path_number_subpaths.py create mode 100644 extensions/fablabchemnitz/reverse_order_subpaths.inx create mode 100644 extensions/fablabchemnitz/reverse_order_subpaths.py diff --git a/extensions/fablabchemnitz/animate_order/animate_order.html b/extensions/fablabchemnitz/animate_order/animate_order.html deleted file mode 100644 index 6f72a19f..00000000 --- a/extensions/fablabchemnitz/animate_order/animate_order.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - Animate Order - joinery_2021-4-25_1.24.3.svg - - - - -
- - - - - diff --git a/extensions/fablabchemnitz/animate_order/drawing.svg b/extensions/fablabchemnitz/animate_order/drawing.svg deleted file mode 100644 index 52f3ff71..00000000 --- a/extensions/fablabchemnitz/animate_order/drawing.svg +++ /dev/null @@ -1,494 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/fablabchemnitz/path_number_subpaths.inx b/extensions/fablabchemnitz/path_number_subpaths.inx new file mode 100644 index 00000000..df441d72 --- /dev/null +++ b/extensions/fablabchemnitz/path_number_subpaths.inx @@ -0,0 +1,27 @@ + + + Number Subpaths + fablabchemnitz.de.number_subpaths + + + 10px + 10px + false + Green dot = start, red dot = end. + + + This extension mark the selection's start and endnodes for each subpath and number the subpaths. + + + + path + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz/path_number_subpaths.py b/extensions/fablabchemnitz/path_number_subpaths.py new file mode 100644 index 00000000..03613488 --- /dev/null +++ b/extensions/fablabchemnitz/path_number_subpaths.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2005 Aaron Spike, aaron@ekips.org +# Modified by Ellen Wasbo, ellen@wasbo.net 2021 - number subpaths and mark start/end node with green/red dot +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +import math +import inkex +from inkex import TextElement, Circle + +class NumberSubpaths(inkex.EffectExtension): + """Mark start and end nodes with numbered dots according to the options""" + def add_arguments(self, pars): + pars.add_argument("--dotsize", default="10px", help="Size of the dots on the path nodes") + pars.add_argument("--fontsize", default="10px", help="Size of node labels") + pars.add_argument("--showID", type=inkex.Boolean, default=False) + pars.add_argument("--tab", help="The selected UI-tab when OK was pressed") + + def effect(self): + if not self.svg.selected: + raise inkex.AbortExtension("Please select an object.") + for id, node in self.svg.selection.id_dict().items(): + self.add_dot(node) + + def add_dot(self, node): + """Add a dot label for this path element""" + group = node.getparent().add(inkex.Group()) + dot_group = group.add(inkex.Group()) + num_group = group.add(inkex.Group()) + group.transform = node.transform + + styleStart = inkex.Style({'stroke': 'none', 'fill': '#00ff00'}) + styleEnd = inkex.Style({'stroke': 'none', 'fill': '#ff0000'}) + + idTxt='' + if self.options.showID==True: + idTxt=node.get('id')+', ' + + cc=0 + for sub in node.path.to_superpath(): + x=sub[0][1][0] + y=sub[0][1][1] + circle = dot_group.add(Circle(cx=str(x), cy=str(y), r=str(self.svg.unittouu(self.options.dotsize) / 2))) + circle.style = styleStart + num_group.append(self.add_text( + x + (self.svg.unittouu(self.options.dotsize) / 3), + y - (self.svg.unittouu(self.options.dotsize) / 3), idTxt+str(cc))) + x=sub[-1][1][0] + y=sub[-1][1][1] + circle = dot_group.add(Circle(cx=str(x), cy=str(y), r=str(self.svg.unittouu(self.options.dotsize) *0.9 / 2))) + circle.style = styleEnd + num_group.append(self.add_text( + x + (self.svg.unittouu(self.options.dotsize) / 3), + y - (self.svg.unittouu(self.options.dotsize) / 3), idTxt+str(cc))) + cc+=1 + + def add_text(self, x, y, text): + """Add a text label at the given location""" + elem = TextElement(x=str(x), y=str(y)) + elem.text = str(text) + elem.style = { + 'font-size': self.svg.unittouu(self.options.fontsize), + 'fill-opacity': '1.0', + 'stroke': 'none', + 'font-weight': 'normal', + 'font-style': 'normal', + 'fill': '#999'} + return elem + +if __name__ == '__main__': + NumberSubpaths().run() diff --git a/extensions/fablabchemnitz/reverse_order_subpaths.inx b/extensions/fablabchemnitz/reverse_order_subpaths.inx new file mode 100644 index 00000000..c3134c72 --- /dev/null +++ b/extensions/fablabchemnitz/reverse_order_subpaths.inx @@ -0,0 +1,17 @@ + + + Reverse Order Of Subpaths + fablabchemnitz.de.reverse_order_subpaths + Reverse order of subpaths (combined paths) without reversing the node order nor the order of the paths. + + path + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz/reverse_order_subpaths.py b/extensions/fablabchemnitz/reverse_order_subpaths.py new file mode 100644 index 00000000..5740efd6 --- /dev/null +++ b/extensions/fablabchemnitz/reverse_order_subpaths.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# +# Copyright (C) Ellen Wasbo, cutlings.wasbo.net 2021 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +import inkex +from inkex import PathElement, CubicSuperPath + +class ReverseOrderSubpaths(inkex.EffectExtension): + + 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 id, elem in self.svg.selection.id_dict().items(): + + new=[] + sub=elem.path.to_superpath() + + i=0 + while i