From 2312e43f469de7b1f58fa6d8ec404237ebc3eb50 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sun, 23 Apr 2023 07:03:23 +0200 Subject: add pull compensation param to zigzag stitches (#2228) --- lib/elements/stroke.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lib/elements/stroke.py') diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py index fd5983d5..8651133d 100644 --- a/lib/elements/stroke.py +++ b/lib/elements/stroke.py @@ -156,6 +156,20 @@ class Stroke(EmbroideryElement): def zigzag_spacing(self): return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01) + @property + @param('pull_compensation_mm', + _('Pull compensation'), + tooltip=_('Zigzag stitches pull the fabric together, resulting in a column narrower than you draw in Inkscape. ' + 'This widens the zigzag line width.'), + unit='mm', + type='float', + default=0, + select_items=[('stroke_method', 'zigzag_stitch')], + sort_index=6) + @cache + def pull_compensation(self): + return self.get_float_param("pull_compensation_mm", 0) + @property @param('line_count', _('Number of lines'), @@ -365,7 +379,7 @@ class Stroke(EmbroideryElement): else: return self.shape.centroid - def simple_satin(self, path, zigzag_spacing, stroke_width): + def simple_satin(self, path, zigzag_spacing, stroke_width, pull_compensation): "zig-zag along the path at the specified spacing and wdith" # `self.zigzag_spacing` is the length for a zig and a zag @@ -377,6 +391,7 @@ class Stroke(EmbroideryElement): # of points in turn, and move perpendicular to them, # alternating left and right. + stroke_width = stroke_width + pull_compensation offset = stroke_width / 2.0 for i in range(len(patch) - 1): @@ -473,7 +488,7 @@ class Stroke(EmbroideryElement): patch.stitches = self.do_bean_repeats(patch.stitches) # simple satin elif self.stroke_method == 'zigzag_stitch': - patch = self.simple_satin(path, self.zigzag_spacing, self.stroke_width) + patch = self.simple_satin(path, self.zigzag_spacing, self.stroke_width, self.pull_compensation) if patch: patches.append(patch) -- cgit v1.2.3