summaryrefslogtreecommitdiff
path: root/lib/stitches
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2023-09-11 16:57:23 -0400
committerGitHub <noreply@github.com>2023-09-11 16:57:23 -0400
commit5e208661d2c1b1a7c2343120754b2e5eb0149a50 (patch)
treee654f9ef53901fa01ad93daa278b887807149c21 /lib/stitches
parent0c681958485cd3401b9ffa017fb1f13191925cdd (diff)
parentc90064d0d3cf926bf54e0fbc1c70eaa9628757e4 (diff)
Merge pull request #2431 from inkstitch/lexelby/split-satin-stagger
stagger split satin rows
Diffstat (limited to 'lib/stitches')
-rw-r--r--lib/stitches/running_stitch.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/stitches/running_stitch.py b/lib/stitches/running_stitch.py
index b6262a45..6c6a4d1d 100644
--- a/lib/stitches/running_stitch.py
+++ b/lib/stitches/running_stitch.py
@@ -53,6 +53,24 @@ def split_segment_random_phase(a, b, length: float, length_sigma: float, random_
return [line.interpolate(x, normalized=False) for x in splits]
+def split_segment_stagger_phase(a, b, segment_length: float, num_staggers: int, this_segment_num: int, min=0, max=None) \
+ -> typing.List[shgeo.Point]:
+ line = shgeo.LineString([a, b])
+ distance = line.length
+ stagger_phase = (this_segment_num / num_staggers) % 1
+ stagger_offset = stagger_phase * segment_length
+ if max is None:
+ max = distance
+
+ splits = []
+ progress = stagger_offset
+ while progress < distance:
+ if progress > min and progress < max:
+ splits.append(progress)
+ progress += segment_length
+ return [line.interpolate(x, normalized=False) for x in splits]
+
+
class AngleInterval():
# Modular interval containing either the entire circle or less than half of it
# partially based on https://fgiesen.wordpress.com/2015/09/24/intervals-in-modular-arithmetic/