diff options
| author | Lex Neva <github.com@lexneva.name> | 2023-07-20 21:53:45 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2023-07-20 21:53:45 -0400 |
| commit | cf2a1d6a3b6e40e85b839b90c3e8d424c390cabd (patch) | |
| tree | 093c43945ade5fb54d38d47163c43e693629c961 | |
| parent | 7389980fae6856116ccf7419d92dcc29a0411851 (diff) | |
add min/max split position
| -rw-r--r-- | lib/stitches/running_stitch.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/stitches/running_stitch.py b/lib/stitches/running_stitch.py index 47e4fa35..6c6a4d1d 100644 --- a/lib/stitches/running_stitch.py +++ b/lib/stitches/running_stitch.py @@ -53,16 +53,20 @@ 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) -> typing.List[shgeo.Point]: +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: - splits.append(progress) + if progress > min and progress < max: + splits.append(progress) progress += segment_length return [line.interpolate(x, normalized=False) for x in splits] |
