From 3de1e0559bcf35a28e4872cc147fbf2f35abf354 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Thu, 20 Aug 2020 02:59:53 +0200 Subject: [PATCH] no message --- extensions/fablabchemnitz_drawdirections.py | 27 ++++++++++++--------- extensions/fablabchemnitz_migrategroups.inx | 1 + extensions/fablabchemnitz_migrategroups.py | 2 ++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/extensions/fablabchemnitz_drawdirections.py b/extensions/fablabchemnitz_drawdirections.py index 610bf66e..42053a0f 100644 --- a/extensions/fablabchemnitz_drawdirections.py +++ b/extensions/fablabchemnitz_drawdirections.py @@ -4,29 +4,32 @@ import inkex from inkex.paths import Path from inkex import Circle -# Draws red points at the path's beginning and blue point at the path's end - class StartEndPoints(inkex.Effect): + def drawCircle(self, group, color, point): + style = inkex.Style({'stroke': 'none', 'fill': color}) + startCircle = group.add(Circle(cx=str(point[0]), cy=str(point[1]), r=str(self.svg.unittouu(str(self.options.dotsize/2) + "px")))) + startCircle.style = style + def __init__(self): inkex.Effect.__init__(self) self.arg_parser.add_argument("--dotsize", type=int, default=10, help="Dot size (px) for self-intersecting points") def effect(self): - dot_group = node.getparent().add(inkex.Group()) + dot_group = self.svg.add(inkex.Group()) - for node in self.svg.selection.values(): - + for node in self.svg.selection.filter(inkex.PathElement): points = list(node.path.end_points) start = points[0] end = points[len(points) - 1] - - style = inkex.Style({'stroke': 'none', 'fill': '#FF0000'}) - startCircle = dot_group.add(Circle(cx=str(start[0]), cy=str(start[1]), r=str(self.svg.unittouu(str(self.options.dotsize/2) + "px")))) - startCircle.style = style + + if start[0] == end[0] and start[1] == end[1]: + self.drawCircle(dot_group, '#00FF00', start) + self.drawCircle(dot_group, '#FFFF00', points[1]) #draw one point which gives direction of the path + else: #open contour with start and end point + self.drawCircle(dot_group, '#FF0000', start) + self.drawCircle(dot_group, '#0000FF', end) - style = inkex.Style({'stroke': 'none', 'fill': '#0000FF'}) - endCircle = dot_group.add(Circle(cx=str(end[0]), cy=str(end[1]), r=str(self.svg.unittouu(str(self.options.dotsize/2) + "px")))) - endCircle.style = style + StartEndPoints().run() \ No newline at end of file diff --git a/extensions/fablabchemnitz_migrategroups.inx b/extensions/fablabchemnitz_migrategroups.inx index 9743b4f6..c7a6da92 100644 --- a/extensions/fablabchemnitz_migrategroups.inx +++ b/extensions/fablabchemnitz_migrategroups.inx @@ -4,6 +4,7 @@ fablabchemnitz.de.migrategroups + true true true true diff --git a/extensions/fablabchemnitz_migrategroups.py b/extensions/fablabchemnitz_migrategroups.py index 9a52175c..25d6f642 100644 --- a/extensions/fablabchemnitz_migrategroups.py +++ b/extensions/fablabchemnitz_migrategroups.py @@ -21,6 +21,7 @@ class MigrateGroups(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) + self.arg_parser.add_argument("--svg", type=inkex.Boolean, default=True, help="svg") self.arg_parser.add_argument("--rect", type=inkex.Boolean, default=True, help="rect") self.arg_parser.add_argument("--circle", type=inkex.Boolean, default=True, help="circle") self.arg_parser.add_argument("--ellipse", type=inkex.Boolean, default=True, help="ellipse") @@ -35,6 +36,7 @@ class MigrateGroups(inkex.Effect): def effect(self): namespace = [] + namespace.append("{http://www.w3.org/2000/svg}svg") if self.options.svg else "" namespace.append("{http://www.w3.org/2000/svg}rect") if self.options.rect else "" namespace.append("{http://www.w3.org/2000/svg}circle") if self.options.circle else "" namespace.append("{http://www.w3.org/2000/svg}ellipse") if self.options.ellipse else ""