diff options
| author | Lex Neva <github.com@lexneva.name> | 2023-01-17 21:44:23 -0500 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2023-02-20 15:27:55 -0500 |
| commit | 847e133f97d570e2967dfa7dcfc16a212dc2bbbc (patch) | |
| tree | df2fb20547bea95ad437155a1fac91290a9d07f3 /lib/elements | |
| parent | e2965e78f03fb41c9a02c92ef120caf038b837ae (diff) | |
meander fill: more work
Diffstat (limited to 'lib/elements')
| -rw-r--r-- | lib/elements/fill_stitch.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py index fbaab0c2..790eec5c 100644 --- a/lib/elements/fill_stitch.py +++ b/lib/elements/fill_stitch.py @@ -5,6 +5,7 @@ import logging import math +import numpy as np import re import sys import traceback @@ -142,7 +143,7 @@ class FillStitch(EmbroideryElement): @property @param('smoothness_mm', _('Smoothness'), tooltip=_( - 'Smooth the stitch path. Smoothness limits how far the smoothed stitch path ' + + 'Smooth the stitch path. Smoothness limits approximately how far the smoothed stitch path ' + 'is allowed to deviate from the original path. Hint: a lower stitchc tolerance may be needed too.' ), type='integer', @@ -159,12 +160,22 @@ class FillStitch(EmbroideryElement): return self.get_boolean_param('clockwise', True) @property - @param('meander_pattern', _('Meander Pattern'), type='dropdown', default=0, + @param('meander_pattern', _('Meander Pattern'), type='select', default=0, options=[tile.name for tile in tiles.all_tiles()], select_items=[('fill_method', 4)], sort_index=3) def meander_pattern(self): return self.get_param('meander_pattern', None) @property + @param('meander_scale_percent', _('Meander pattern scale'), type='float', unit="%", default=100, select_items=[('fill_method', 4)], sort_index=4) + def meander_scale(self): + return np.maximum(self.get_split_float_param('meander_scale_percent', (100, 100)), (10, 10)) / 100 + + @property + @param('meander_padding_mm', _('Meander padding'), type='float', unit="mm", default=0, select_items=[('fill_method', 4)], sort_index=5) + def meander_padding(self): + return self.get_float_param('meander_padding_mm', 0) + + @property @param('angle', _('Angle of lines of stitches'), tooltip=_('The angle increases in a counter-clockwise direction. 0 is horizontal. Negative angles are allowed.'), @@ -593,7 +604,7 @@ class FillStitch(EmbroideryElement): stitch_groups.extend(underlay_stitch_groups) fill_shapes = self.fill_shape(shape) - for fill_shape in fill_shapes.geoms: + for i, fill_shape in enumerate(fill_shapes.geoms): if self.fill_method == 0: stitch_groups.extend(self.do_auto_fill(fill_shape, previous_stitch_group, start, end)) if self.fill_method == 1: @@ -601,7 +612,7 @@ class FillStitch(EmbroideryElement): elif self.fill_method == 2: stitch_groups.extend(self.do_guided_fill(fill_shape, previous_stitch_group, start, end)) elif self.fill_method == 4: - stitch_groups.extend(self.do_meander_fill(fill_shape, start, end)) + stitch_groups.extend(self.do_meander_fill(fill_shape, i, start, end)) except ExitThread: raise except Exception: @@ -733,11 +744,11 @@ class FillStitch(EmbroideryElement): )) return [stitch_group] - def do_meander_fill(self, shape, starting_point, ending_point): + def do_meander_fill(self, shape, i, starting_point, ending_point): stitch_group = StitchGroup( color=self.color, tags=("meander_fill", "meander_fill_top"), - stitches=meander_fill(self, shape, starting_point, ending_point)) + stitches=meander_fill(self, shape, i, starting_point, ending_point)) return [stitch_group] @cache |
