diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-01-28 08:48:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-28 08:48:44 +0100 |
| commit | 92ac7986937c14b224a24aa483d668557ee8ba53 (patch) | |
| tree | 00b306678e1523021f037e09dc4e1798f09e3d03 /lib/elements | |
| parent | 33b0cdab9e6b7f94e42bd4c2ee13ef8dc5a9f549 (diff) | |
add zigzag option to meander (#2699)
Diffstat (limited to 'lib/elements')
| -rw-r--r-- | lib/elements/fill_stitch.py | 26 | ||||
| -rw-r--r-- | lib/elements/stroke.py | 25 |
2 files changed, 29 insertions, 22 deletions
diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py index 593791e5..267dbbd5 100644 --- a/lib/elements/fill_stitch.py +++ b/lib/elements/fill_stitch.py @@ -423,6 +423,32 @@ class FillStitch(EmbroideryElement): return self.get_multiple_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', + select_items=[('fill_method', 'meander_fill')], + default=0, + sort_index=35) + @cache + def zigzag_spacing(self): + return self.get_float_param("zigzag_spacing_mm", 0) + + @property + @param('zigzag_width_mm', + _('Zigzag width'), + tooltip=_('Width of the zigzag line.'), + unit='mm', + type='float', + select_items=[('fill_method', 'meander_fill')], + default=3, + sort_index=36) + @cache + def zigzag_width(self): + return self.get_float_param("zigzag_width_mm", 0) + + @property def color(self): # SVG spec says the default fill is black return self.get_style("fill", "#000000") diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py index e6bcba5c..a4df5118 100644 --- a/lib/elements/stroke.py +++ b/lib/elements/stroke.py @@ -13,7 +13,8 @@ from ..i18n import _ from ..marker import get_marker_elements from ..stitch_plan import StitchGroup from ..stitches.ripple_stitch import ripple_stitch -from ..stitches.running_stitch import bean_stitch, running_stitch +from ..stitches.running_stitch import (bean_stitch, running_stitch, + zigzag_stitch) from ..svg import get_node_transform, parse_length_with_units from ..svg.clip import get_clip_path from ..threads import ThreadColor @@ -444,27 +445,7 @@ class Stroke(EmbroideryElement): # that length: patch = self.running_stitch(path, zigzag_spacing / 2.0, self.running_stitch_tolerance) - # Now move the points left and right. Consider each pair - # 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): - start = patch.stitches[i] - end = patch.stitches[i + 1] - # sometimes the stitch results into zero length which cause a division by zero error - # ignoring this leads to a slightly bad result, but that is better than no output - if (end - start).length() == 0: - continue - segment_direction = (end - start).unit() - zigzag_direction = segment_direction.rotate_left() - - if i % 2 == 1: - zigzag_direction *= -1 - - patch.stitches[i] += zigzag_direction * offset + patch.stitches = zigzag_stitch(patch.stitches, zigzag_spacing, stroke_width, pull_compensation) return patch |
