summaryrefslogtreecommitdiff
path: root/lib/elements/stroke.py
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-08-16 16:36:39 -0400
committerLex Neva <github.com@lexneva.name>2018-08-16 16:36:39 -0400
commit284748a682d4aa95c91cc215d5945181c833de15 (patch)
tree6334f284489243be5634fc811401de10631a87dd /lib/elements/stroke.py
parent64062f7cd7eee9ed5701209618b0564a211c494b (diff)
parent0f882f07eb0fc263fcb8e05c1a212199902863da (diff)
Merge branch 'master' into lexelby-no-embroider-command
Diffstat (limited to 'lib/elements/stroke.py')
-rw-r--r--lib/elements/stroke.py46
1 files changed, 41 insertions, 5 deletions
diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py
index e8eb4783..e84d5e79 100644
--- a/lib/elements/stroke.py
+++ b/lib/elements/stroke.py
@@ -4,7 +4,7 @@ import shapely.geometry
from .element import param, EmbroideryElement, Patch
from ..i18n import _
from ..utils import cache, Point
-from ..stitches import running_stitch
+from ..stitches import running_stitch, bean_stitch
from ..svg import parse_length_with_units
warned_about_legacy_running_stitch = False
@@ -27,18 +27,45 @@ class Stroke(EmbroideryElement):
return self.get_style("stroke-dasharray") is not None
@property
- @param('running_stitch_length_mm', _('Running stitch length'), unit='mm', type='float', default=1.5)
+ @param('running_stitch_length_mm',
+ _('Running stitch length'),
+ tooltip=_('Length of stitches in running stitch mode.'),
+ unit='mm',
+ type='float',
+ default=1.5,
+ sort_index=3)
def running_stitch_length(self):
return max(self.get_float_param("running_stitch_length_mm", 1.5), 0.01)
@property
- @param('zigzag_spacing_mm', _('Zig-zag spacing (peak-to-peak)'), unit='mm', type='float', default=0.4)
+ @param('bean_stitch_repeats',
+ _('Bean stitch number of repeats'),
+ tooltip=_('Backtrack each stitch this many times. A value of 1 would triple each stitch (forward, back, forward). A value of 2 would quintuple each stitch, etc. Only applies to running stitch.'),
+ type='int',
+ default=0,
+ sort_index=2)
+ def bean_stitch_repeats(self):
+ return self.get_int_param("bean_stitch_repeats", 0)
+
+ @property
+ @param('zigzag_spacing_mm',
+ _('Zig-zag spacing (peak-to-peak)'),
+ tooltip=_('Length of stitches in zig-zag mode.'),
+ unit='mm',
+ type='float',
+ default=0.4,
+ sort_index=3)
@cache
def zigzag_spacing(self):
return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01)
@property
- @param('repeats', _('Repeats'), type='int', default="1")
+ @param('repeats',
+ _('Repeats'),
+ tooltip=_('Defines how many times to run down and back along the path.'),
+ type='int',
+ default="1",
+ sort_index=1)
def repeats(self):
return self.get_int_param("repeats", 1)
@@ -58,7 +85,12 @@ class Stroke(EmbroideryElement):
return shapely.geometry.MultiLineString(line_strings)
@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)
+ @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,
+ sort_index=0)
def manual_stitch_mode(self):
return self.get_boolean_param('manual_stitch')
@@ -152,6 +184,10 @@ class Stroke(EmbroideryElement):
patch = Patch(color=self.color, stitches=path, stitch_as_is=True)
elif self.is_running_stitch():
patch = self.running_stitch(path, self.running_stitch_length)
+
+ if self.bean_stitch_repeats > 0:
+ patch.stitches = bean_stitch(patch.stitches, self.bean_stitch_repeats)
+
else:
patch = self.simple_satin(path, self.zigzag_spacing, self.stroke_width)