summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-04-02 22:11:57 -0400
committerLex Neva <github.com@lexneva.name>2018-04-02 22:11:57 -0400
commitdb64531d244c1c4adfaa820f2409e3558e9bc8cf (patch)
tree88ff42756a4dcec9f1cab8160501bf9a89622b87
parent95df3c7c44357c6ba31caed0b8bfd1b0e4d9b3b8 (diff)
add manual stitch mode
-rw-r--r--inkstitch/elements/element.py15
-rw-r--r--inkstitch/elements/stroke.py16
-rw-r--r--messages.po10
3 files changed, 27 insertions, 14 deletions
diff --git a/inkstitch/elements/element.py b/inkstitch/elements/element.py
index 7a029eac..a6db7189 100644
--- a/inkstitch/elements/element.py
+++ b/inkstitch/elements/element.py
@@ -203,25 +203,18 @@ class EmbroideryElement(object):
# apply the combined transform to this node's path
simpletransform.applyTransformToPath(transform, path)
-
return path
+ def strip_control_points(self, subpath):
+ return [point for control_before, point, control_after in subpath]
+
def flatten(self, path):
"""approximate a path containing beziers with a series of points"""
path = deepcopy(path)
-
cspsubdiv(path, 0.1)
- flattened = []
-
- for comp in path:
- vertices = []
- for ctl in comp:
- vertices.append((ctl[1][0], ctl[1][1]))
- flattened.append(vertices)
-
- return flattened
+ return [self.strip_control_points(subpath) for subpath in path]
@property
@param('trim_after',
diff --git a/inkstitch/elements/stroke.py b/inkstitch/elements/stroke.py
index b0e7d23f..f245f370 100644
--- a/inkstitch/elements/stroke.py
+++ b/inkstitch/elements/stroke.py
@@ -37,7 +37,17 @@ class Stroke(EmbroideryElement):
@property
def paths(self):
- return self.flatten(self.parse_path())
+ path = self.parse_path()
+
+ if self.manual_stitch_mode:
+ return [self.strip_control_points(subpath) for subpath in path]
+ else:
+ return self.flatten(path)
+
+ @property
+ @param('manual_stitch', _('Manual stitch placement'), tooltip=_("Stitch every node in the path. Stitch length and zig-zag spacing are ignored."), type='boolean', default=False)
+ def manual_stitch_mode(self):
+ return self.get_boolean_param('manual_stitch')
def is_running_stitch(self):
# stroke width <= 0.5 pixels is deprecated in favor of dashed lines
@@ -99,7 +109,9 @@ class Stroke(EmbroideryElement):
for path in self.paths:
path = [Point(x, y) for x, y in path]
- if self.is_running_stitch():
+ if self.manual_stitch_mode:
+ patch = Patch(color=self.color, stitches=path)
+ elif self.is_running_stitch():
patch = self.stroke_points(path, self.running_stitch_length, stroke_width=0.0)
else:
patch = self.stroke_points(path, self.zigzag_spacing / 2.0, stroke_width=self.stroke_width)
diff --git a/messages.po b/messages.po
index 92630bb0..aa2a0523 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-03-30 20:26-0400\n"
+"POT-Creation-Date: 2018-04-02 22:11-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"
@@ -272,6 +272,14 @@ msgstr ""
msgid "Repeats"
msgstr ""
+msgid "Manual stitch placement"
+msgstr ""
+
+msgid ""
+"Stitch every node in the path. Stitch length and zig-zag spacing are "
+"ignored."
+msgstr ""
+
msgid ""
"Unable to autofill. This most often happens because your shape is made "
"up of multiple sections that aren't connected."