From d32a8fd4661331da0affb15623a2ec9a9eac5c44 Mon Sep 17 00:00:00 2001 From: George Steel Date: Sun, 5 May 2024 13:55:33 -0400 Subject: Add randomized running and fill stitches (#2830) Add a mode to running stitch that uses randomized phase and stitch length instead of even spacing. This greatly reduces moire effects when stitching closely-spaced curves in running-stitch-based fills. Add option for randomized running stitch to: ripple stitch circular fill contour fill guided fill auto-fill When is randomization is not selected, ripple stitch will use even running stitch when staggers are set to 0 (default) and the stagger algorithm from guided fill (which does not look nice with a stagger period of 0) when staggers is nonzero. Also includes fix for satin contour underlays (missing tolerance default) mentioned in #2814. This sets the default tolerance to 0.2mm, which is the largest tolerance guaranteed to be backwards-compatible with existing designs using the default inset of 0.4mm. Original commits: * fix satin underlay tolerance default * Add randomized running stitch, make available in ripple stitch, circular, and contour * add randomized guided fill * make ripple stitch use even stitching when not staggering or randomizing. * add random auto-fill and switch jitter parameter to a percentage (matches satin) * fix comments --- lib/elements/satin_column.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/elements/satin_column.py') diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index a33afb8b..9cf7bc73 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -372,10 +372,11 @@ class SatinColumn(EmbroideryElement): unit='mm', group=_('Contour Underlay'), type='float', + default=0.2, ) def contour_underlay_stitch_tolerance(self): - tolerance = self.get_float_param("contour_underlay_stitch_tolerance_mm", self.contour_underlay_stitch_length) - return max(tolerance, 0.01) + tolerance = self.get_float_param("contour_underlay_stitch_tolerance_mm", 0.2) + return max(tolerance, 0.01 * PIXELS_PER_MM) # sanity check to prevent crash from excessively-small values @property @param('contour_underlay_inset_mm', @@ -428,11 +429,12 @@ class SatinColumn(EmbroideryElement): ), unit='mm', group=_('Center-Walk Underlay'), - type='float' + type='float', + default=0.2 ) def center_walk_underlay_stitch_tolerance(self): - tolerance = self.get_float_param("center_walk_underlay_stitch_tolerance_mm", self.contour_underlay_stitch_length) - return max(tolerance, 0.01) + tolerance = self.get_float_param("center_walk_underlay_stitch_tolerance_mm", 0.2) + return max(tolerance, 0.01 * PIXELS_PER_MM) @property @param('center_walk_underlay_repeats', @@ -1171,12 +1173,12 @@ class SatinColumn(EmbroideryElement): self.contour_underlay_stitch_tolerance, -self.contour_underlay_inset_px, -self.contour_underlay_inset_percent/100) - first_side = running_stitch.running_stitch( + first_side = running_stitch.even_running_stitch( [points[0] for points in pairs], self.contour_underlay_stitch_length, self.contour_underlay_stitch_tolerance ) - second_side = running_stitch.running_stitch( + second_side = running_stitch.even_running_stitch( [points[1] for points in pairs], self.contour_underlay_stitch_length, self.contour_underlay_stitch_tolerance @@ -1209,7 +1211,7 @@ class SatinColumn(EmbroideryElement): (0, 0), inset_prop) points = [points[0] for points in pairs] - stitches = running_stitch.running_stitch(points, self.center_walk_underlay_stitch_length, self.center_walk_underlay_stitch_tolerance) + stitches = running_stitch.even_running_stitch(points, self.center_walk_underlay_stitch_length, self.center_walk_underlay_stitch_tolerance) for i in range(self.center_walk_underlay_repeats - 1): if i % 2 == 0: -- cgit v1.2.3