add extension to swap satin column rails

pull/219/head
Lex Neva 2018-06-30 13:02:33 -04:00
rodzic 5a85cf4c3c
commit 3299b7450f
4 zmienionych plików z 56 dodań i 1 usunięć

Wyświetl plik

@ -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>

Wyświetl plik

@ -6,3 +6,4 @@ from simulate import Simulate
from input import Input
from output import Output
from zip import Zip
from flip import Flip

Wyświetl plik

@ -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)

Wyświetl plik

@ -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 "