From 3f7485c62edabc6bf335399f3ecc307dd3f586f0 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Fri, 26 May 2023 10:18:27 +0200 Subject: [PATCH] Possible fix for parallel offset in guided fill for macOS (#2321) * fix parallel offset in guided fill for macOS * ripple grid start position * circular ripple grid --- lib/stitches/guided_fill.py | 6 +++++- lib/stitches/ripple_stitch.py | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/stitches/guided_fill.py b/lib/stitches/guided_fill.py index b741ac00e..b733e7a0a 100644 --- a/lib/stitches/guided_fill.py +++ b/lib/stitches/guided_fill.py @@ -247,7 +247,11 @@ def intersect_region_with_grating_guideline(shape, line, row_spacing, num_stagge translate_amount = translate_direction * row * row_spacing offset_line = translate(line, xoff=translate_amount.x, yoff=translate_amount.y) elif strategy == 1: - offset_line = line.parallel_offset(row * row_spacing, 'left', join_style=shgeo.JOIN_STYLE.round) + offset = row * row_spacing + if offset == 0: + # this is needed for macOS builds + offset = 0.0001 + offset_line = line.parallel_offset(offset, 'left', join_style=shgeo.JOIN_STYLE.round) offset_line = clean_offset_line(offset_line) diff --git a/lib/stitches/ripple_stitch.py b/lib/stitches/ripple_stitch.py index 90dc7cbc7..156059e93 100644 --- a/lib/stitches/ripple_stitch.py +++ b/lib/stitches/ripple_stitch.py @@ -36,7 +36,7 @@ def ripple_stitch(stroke): stitches.reverse() if stroke.grid_size != 0: - stitches.extend(_do_grid(stroke, helper_lines, skip_start, skip_end)) + stitches.extend(_do_grid(stroke, helper_lines, skip_start, skip_end, is_linear)) return _repeat_coords(stitches, stroke.repeats) @@ -229,7 +229,7 @@ def _target_point_helper_lines(stroke, outline): return helper_lines -def _adjust_helper_lines_for_grid(stroke, helper_lines, skip_start, skip_end): +def _adjust_helper_lines_for_grid(stroke, helper_lines, skip_start, skip_end, is_linear): num_lines = len(helper_lines[0]) count = num_lines - skip_start - skip_end @@ -239,19 +239,26 @@ def _adjust_helper_lines_for_grid(stroke, helper_lines, skip_start, skip_end): (not stroke.reverse and skip_start % 2 != 0))): count += 1 + if not is_linear: + count = 1 + if stroke.reverse: + count = 0 + if count % 2 != 0: helper_lines.reverse() return helper_lines -def _do_grid(stroke, helper_lines, skip_start, skip_end): - helper_lines = _adjust_helper_lines_for_grid(stroke, helper_lines, skip_start, skip_end) +def _do_grid(stroke, helper_lines, skip_start, skip_end, is_linear): + helper_lines = _adjust_helper_lines_for_grid(stroke, helper_lines, skip_start, skip_end, is_linear) grid = [] for i, helper in enumerate(helper_lines): end = len(helper) - skip_end points = helper[skip_start:end] if stroke.reverse: points.reverse() + if len(helper_lines) - skip_start - skip_end % 2 != 0: + points.reverse() grid.append(points) grid = _get_staggered_stitches(stroke, grid, 0) return grid