From e8017e0bcc0be2ef128bcea187f6528ed0a3d197 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Thu, 20 Jun 2024 10:45:53 -0700 Subject: auto-fill pull compensation (#2891) --- lib/elements/fill_stitch.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'lib/elements/fill_stitch.py') diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py index 188c2ad7..c539cf7e 100644 --- a/lib/elements/fill_stitch.py +++ b/lib/elements/fill_stitch.py @@ -596,6 +596,37 @@ class FillStitch(EmbroideryElement): def herringbone_width(self): return self.get_float_param('herringbone_width_mm', 0) + @property + @param( + 'pull_compensation_mm', + _('Pull compensation'), + tooltip=_('Fill stitch can pull the fabric together, resulting in a shape narrower than you draw in Inkscape. ' + 'This setting expands each row of stitches outward from the center of the row by a fixed length. ' + 'Two values separated by a space may be used for an asymmetric effect.'), + select_items=[('fill_method', 'auto_fill')], + unit=_('mm (each side)'), + type='float', + default=0, + sort_index=26) + @cache + def pull_compensation_px(self): + return np.maximum(self.get_split_mm_param_as_px("pull_compensation_mm", (0, 0)), 0) + + @property + @param( + 'pull_compensation_percent', + _('Pull compensation percentage'), + tooltip=_('Additional pull compensation which varies as a percentage of row width. ' + 'Two values separated by a space may be used for an asymmetric effect.'), + select_items=[('fill_method', 'auto_fill')], + unit=_('% (each side)'), + type='float', + default=0, + sort_index=27) + @cache + def pull_compensation_percent(self): + return np.maximum(self.get_split_float_param("pull_compensation_percent", (0, 0)), 0) + @property def color(self): # SVG spec says the default fill is black @@ -1027,6 +1058,8 @@ class FillStitch(EmbroideryElement): self.enable_random_stitch_length, self.random_stitch_length_jitter, self.random_seed, + self.pull_compensation_px, + self.pull_compensation_percent / 100, ) ) return [stitch_group] -- cgit v1.2.3