summaryrefslogtreecommitdiff
path: root/lib/stitches/running_stitch.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2018-08-05 20:25:54 -0400
committerGitHub <noreply@github.com>2018-08-05 20:25:54 -0400
commit0f826fbd2409b16faa170dd7ac7dde8f910d8cc3 (patch)
tree1acb2fd292be575247f778ae5d34d96ccee2c285 /lib/stitches/running_stitch.py
parent1ab23cd8742b023ddaa832cb84d73f48b5950a14 (diff)
parentc72a1d761f8bb427b78896b2546257cfc7aa1f69 (diff)
Merge pull request #248 from inkstitch/lexelby-bean-stitch
add bean stitch option
Diffstat (limited to 'lib/stitches/running_stitch.py')
-rw-r--r--lib/stitches/running_stitch.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/stitches/running_stitch.py b/lib/stitches/running_stitch.py
index 96075e7a..5f8ed21e 100644
--- a/lib/stitches/running_stitch.py
+++ b/lib/stitches/running_stitch.py
@@ -1,3 +1,6 @@
+from copy import copy
+
+
""" Utility functions to produce running stitches. """
@@ -64,3 +67,29 @@ def running_stitch(points, stitch_length):
output.append(segment_start)
return output
+
+
+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
+ 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.
+ """
+
+ if len(stitches) < 2:
+ return stitches
+
+ new_stitches = [stitches[0]]
+
+ for stitch in stitches:
+ new_stitches.append(stitch)
+
+ for i in xrange(repeats):
+ new_stitches.extend(copy(new_stitches[-2:]))
+
+ return new_stitches