summaryrefslogtreecommitdiff
path: root/lib/stitches/fill.py
diff options
context:
space:
mode:
authorGeorge Steel <george.steel@gmail.com>2022-10-27 23:01:05 -0400
committerGitHub <noreply@github.com>2022-10-27 23:01:05 -0400
commit0032e5cdd0bf26e5061d460903ffaaf34c120de0 (patch)
treed2cba9647dca3baa490b84c8db1438d964101242 /lib/stitches/fill.py
parent27d2fcecaaec7ab3b153981a77f53a9eda8a8add (diff)
parent1cc0eab91189227371c5bb78d9e1f1f06deaeaf5 (diff)
Merge pull request #1874 from inkstitch/george-steel/fractional-stagger
Add support for fractional-length stagger cycles in fills
Diffstat (limited to 'lib/stitches/fill.py')
-rw-r--r--lib/stitches/fill.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py
index 7c07b5c2..ed4ff655 100644
--- a/lib/stitches/fill.py
+++ b/lib/stitches/fill.py
@@ -37,9 +37,11 @@ def row_num(point, angle, row_spacing):
def adjust_stagger(stitch, angle, row_spacing, max_stitch_length, staggers):
+ if staggers == 0:
+ staggers = 1 # sanity check to avoid division by zero.
this_row_num = row_num(stitch, angle, row_spacing)
- row_stagger = this_row_num % staggers
- stagger_offset = (float(row_stagger) / staggers) * max_stitch_length
+ stagger_phase = (this_row_num / staggers) % 1
+ stagger_offset = stagger_phase * max_stitch_length
offset = ((stitch * east(angle)) - stagger_offset) % max_stitch_length
return stitch - offset * east(angle)