diff options
| -rw-r--r-- | lib/elements/fill_stitch.py | 9 | ||||
| -rw-r--r-- | lib/stitches/linear_gradient_fill.py | 11 |
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py index 4e5503ca..04ddeaea 100644 --- a/lib/elements/fill_stitch.py +++ b/lib/elements/fill_stitch.py @@ -496,7 +496,8 @@ class FillStitch(EmbroideryElement): select_items=[('fill_method', 'auto_fill'), ('fill_method', 'contour_fill'), ('fill_method', 'guided_fill'), - ('fill_method', 'circular_fill')], + ('fill_method', 'circular_fill'), + ('fill_method', 'linear_gradient_fill'),], default=False, sort_index=44) def enable_random_stitch_length(self): @@ -511,7 +512,8 @@ class FillStitch(EmbroideryElement): select_items=[('fill_method', 'auto_fill'), ('fill_method', 'contour_fill'), ('fill_method', 'guided_fill'), - ('fill_method', 'circular_fill')], + ('fill_method', 'circular_fill'), + ('fill_method', 'linear_gradient_fill'),], default=10, sort_index=46) def random_stitch_length_jitter(self): @@ -736,7 +738,8 @@ class FillStitch(EmbroideryElement): ('fill_method', 'contour_fill'), ('fill_method', 'guided_fill'), ('fill_method', 'circular_fill'), - ('fill_method', 'meander_fill')], + ('fill_method', 'meander_fill'), + ('fill_method', 'linear_gradient_fill')], type='random_seed', default='', sort_index=100) diff --git a/lib/stitches/linear_gradient_fill.py b/lib/stitches/linear_gradient_fill.py index 3b2d0938..2fb03bf9 100644 --- a/lib/stitches/linear_gradient_fill.py +++ b/lib/stitches/linear_gradient_fill.py @@ -12,14 +12,18 @@ from shapely import segmentize from shapely.affinity import rotate from shapely.geometry import LineString, MultiLineString, Point, Polygon +from lib.utils import prng + from ..stitch_plan import StitchGroup from ..svg import get_node_transform +from ..utils.geometry import Point as InkstitchPoint from ..utils.geometry import ensure_multi_line_string from ..utils.threading import check_stop_flag from .auto_fill import (build_fill_stitch_graph, build_travel_graph, find_stitch_path, graph_make_valid) from .circular_fill import path_to_stitches from .guided_fill import apply_stitches +from .running_stitch import random_running_stitch def linear_gradient_fill(fill, shape, starting_point, ending_point): @@ -117,7 +121,12 @@ def _get_lines(fill, shape, bounding_box, angle): # stagger stitched lines according to user settings staggered_lines = [] for i, line in enumerate(lines): - staggered_line = apply_stitches(LineString(line), fill.max_stitch_length, fill.staggers, fill.row_spacing, i) + if fill.enable_random_stitch_length: + points = [InkstitchPoint(*x) for x in line] + staggered_line = LineString(random_running_stitch( + points, fill.max_stitch_length, fill.running_stitch_tolerance, fill.random_stitch_length_jitter, prng.join_args(fill.random_seed, i))) + else: + staggered_line = apply_stitches(LineString(line), fill.max_stitch_length, fill.staggers, fill.row_spacing, i) staggered_lines.append(staggered_line) return staggered_lines, bottom_line |
