From 3299b7450f847e9ecb0df9f8b8a5cd3da755a33b Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 30 Jun 2018 13:02:33 -0400 Subject: [PATCH 1/4] add extension to swap satin column rails --- inx/inkstitch_flip.inx | 17 +++++++++++++++++ lib/extensions/__init__.py | 1 + lib/extensions/flip.py | 34 ++++++++++++++++++++++++++++++++++ messages.po | 5 ++++- 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 inx/inkstitch_flip.inx create mode 100644 lib/extensions/flip.py 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 " From 8c009e381ef6bc0ea702dd59c7a91687043279eb Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 30 Jun 2018 13:05:11 -0400 Subject: [PATCH 2/4] add QR code patch --- .../examples/InkStitch Logo QR Code Patch.svg | 2312 +++++++++++++++++ 1 file changed, 2312 insertions(+) create mode 100644 images/examples/InkStitch Logo QR Code Patch.svg diff --git a/images/examples/InkStitch Logo QR Code Patch.svg b/images/examples/InkStitch Logo QR Code Patch.svg new file mode 100644 index 000000000..bcbeeef90 --- /dev/null +++ b/images/examples/InkStitch Logo QR Code Patch.svg @@ -0,0 +1,2312 @@ + +Fill stitch ending pointFill stitch starting pointimage/svg+xml"Ink/Stitch""1""400px QR code for Ink/Stitch""matrix(2.1218, 0, 0, 2.1218, -187.183, -187.183)""matrix(1.6617263999999998,0,0,1.6617263999999998,-191,-236)" \ No newline at end of file From ac84d7b0d4365b61b5a375b8c4497a81093cc734 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 7 Jul 2018 15:31:59 -0400 Subject: [PATCH 3/4] fix brain-o --- lib/extensions/flip.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/extensions/flip.py b/lib/extensions/flip.py index 75d8fe175..d8d78cb54 100644 --- a/lib/extensions/flip.py +++ b/lib/extensions/flip.py @@ -1,19 +1,25 @@ import sys import inkex import cubicsuperpath +from shapely import geometry as shgeo from .base import InkstitchExtension from ..i18n import _ from ..elements import SatinColumn class Flip(InkstitchExtension): + def subpath_to_linestring(self, subpath): + return shgeo.LineString() + def flip(self, satin): - csp = cubicsuperpath.parsePath(satin.node.get("d")) + csp = satin.path if len(csp) > 1: + flattened = satin.flatten(csp) + # find the rails (the two longest paths) and swap them indices = range(len(csp)) - indices.sort(key=lambda i: len(csp[i]), reverse=True) + indices.sort(key=lambda i: shgeo.LineString(flattened[i]).length, reverse=True) first = indices[0] second = indices[1]