diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-11-30 17:27:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-30 17:27:48 +0100 |
| commit | a980ed0dbc32e2f8039ee7a563f3c1ffa6c8a05b (patch) | |
| tree | 1d2128bf96b80c5372ab8f884e5d6f89caec9fb1 /lib/stitches | |
| parent | 7390a702ecb58b0de14c679b1e7e612e957e1907 (diff) | |
add randomization options to linear gradient fill (#3311)
Diffstat (limited to 'lib/stitches')
| -rw-r--r-- | lib/stitches/linear_gradient_fill.py | 11 |
1 files changed, 10 insertions, 1 deletions
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 |
