diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2023-01-15 20:04:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-15 20:04:10 +0100 |
| commit | 1cdb3538a83a13d97907d08908750f0d85de6978 (patch) | |
| tree | ddccf347d43ff850f4e8eca0e4c541dbd3cf2e4f /lib/stitches/running_stitch.py | |
| parent | 4156c4adb4eadaf024b29df1df6bf1c91d3777a8 (diff) | |
Add bean stitch repeat pattern (#1938)
! backward compatibility warning:
Users need to fix their documents if they used comma separated values for multiple fill underlays (without a space)
Diffstat (limited to 'lib/stitches/running_stitch.py')
| -rw-r--r-- | lib/stitches/running_stitch.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/stitches/running_stitch.py b/lib/stitches/running_stitch.py index 34729109..e6a7d010 100644 --- a/lib/stitches/running_stitch.py +++ b/lib/stitches/running_stitch.py @@ -117,24 +117,35 @@ def running_stitch(points, stitch_length, tolerance): def bean_stitch(stitches, repeats): """Generate bean stitch from a set of stitches. - "Bean" stitch is made by backtracking each stitch to make it heaver. A + "Bean" stitch is made by backtracking each stitch to make it heavier. A simple bean stitch would be two stitches forward, one stitch back, two stitches forward, etc. This would result in each stitch being tripled. We'll say that the above counts as 1 repeat. Backtracking each stitch repeatedly will result in a heavier bean stitch. There will always be an odd number of threads piled up for each stitch. + + Repeats is a list of a repeated pattern e.g. [0, 1, 3] doesn't repeat the first stitch, + goes back and forth on the second stitch, goes goes 3 times back and forth on the third stitch, + and starts the pattern again by not repeating the fourth stitch, etc. """ if len(stitches) < 2: return stitches + repeat_list_length = len(repeats) + repeat_list_pos = 0 + new_stitches = [stitches[0]] for stitch in stitches: new_stitches.append(stitch) - for i in range(repeats): + for i in range(repeats[repeat_list_pos]): new_stitches.extend(copy(new_stitches[-2:])) + repeat_list_pos += 1 + if repeat_list_pos == repeat_list_length: + repeat_list_pos = 0 + return new_stitches |
