summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inx/inkstitch_flip.inx17
-rw-r--r--lib/extensions/__init__.py1
-rw-r--r--lib/extensions/flip.py34
-rw-r--r--messages.po5
4 files changed, 56 insertions, 1 deletions
diff --git a/inx/inkstitch_flip.inx b/inx/inkstitch_flip.inx
new file mode 100644
index 00000000..f129b8d9
--- /dev/null
+++ b/inx/inkstitch_flip.inx
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Flip Satin Columns</_name>
+ <id>org.inkstitch.flip_satins</id>
+ <dependency type="executable" location="extensions">inkstitch.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="extension" type="string" gui-hidden="true">flip</param>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Embroidery"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">inkstitch.py</command>
+ </script>
+</inkscape-extension>
diff --git a/lib/extensions/__init__.py b/lib/extensions/__init__.py
index b8951e12..b11ba1a4 100644
--- a/lib/extensions/__init__.py
+++ b/lib/extensions/__init__.py
@@ -6,3 +6,4 @@ from simulate import Simulate
from input import Input
from output import Output
from zip import Zip
+from flip import Flip
diff --git a/lib/extensions/flip.py b/lib/extensions/flip.py
new file mode 100644
index 00000000..75d8fe17
--- /dev/null
+++ b/lib/extensions/flip.py
@@ -0,0 +1,34 @@
+import sys
+import inkex
+import cubicsuperpath
+
+from .base import InkstitchExtension
+from ..i18n import _
+from ..elements import SatinColumn
+
+class Flip(InkstitchExtension):
+ def flip(self, satin):
+ csp = cubicsuperpath.parsePath(satin.node.get("d"))
+
+ if len(csp) > 1:
+ # find the rails (the two longest paths) and swap them
+ indices = range(len(csp))
+ indices.sort(key=lambda i: len(csp[i]), reverse=True)
+
+ first = indices[0]
+ second = indices[1]
+ csp[first], csp[second] = csp[second], csp[first]
+
+ satin.node.set("d", cubicsuperpath.formatPath(csp))
+
+ def effect(self):
+ if not self.get_elements():
+ return
+
+ if not self.selected:
+ inkex.errormsg(_("Please select one or more satin columns to flip."))
+ return
+
+ for element in self.elements:
+ if isinstance(element, SatinColumn):
+ self.flip(element)
diff --git a/messages.po b/messages.po
index d6f156f2..72b60bb0 100644
--- a/messages.po
+++ b/messages.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2018-06-28 20:32-0400\n"
+"POT-Creation-Date: 2018-06-30 13:02-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -198,6 +198,9 @@ msgid ""
"Seeing a 'no such option' message? Please restart Inkscape to fix."
msgstr ""
+msgid "Please select one or more satin columns to flip."
+msgstr ""
+
msgid ""
"Ink/Stitch can install files (\"add-ons\") that make it easier to use "
"Inkscape to create machine embroidery designs. These add-ons will be "