diff --git a/inx/inkstitch_flip.inx b/inx/inkstitch_flip.inx new file mode 100644 index 000000000..f129b8d9c --- /dev/null +++ b/inx/inkstitch_flip.inx @@ -0,0 +1,17 @@ + + + <_name>Flip Satin Columns + org.inkstitch.flip_satins + inkstitch.py + inkex.py + flip + + all + + + + + + diff --git a/lib/extensions/__init__.py b/lib/extensions/__init__.py index b8951e12a..b11ba1a4d 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 000000000..75d8fe175 --- /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 d6f156f29..72b60bb05 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 \n" "Language-Team: LANGUAGE \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 "