summaryrefslogtreecommitdiff
path: root/lib/stitch_plan/trim.py
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-05-01 20:37:51 -0400
committerLex Neva <github.com@lexneva.name>2018-05-01 20:37:51 -0400
commit1b31806423c8fec4040fed6d1009db016860b763 (patch)
tree71ccac169471e76685a7fa0b9910f64555dc73a7 /lib/stitch_plan/trim.py
parent5b7f14d092456a941dbd189e61ed38d9b16d388b (diff)
rename inkstitch/ to lib/
You can't have a module and a package named the same thing. PyInstaller wants to import the main script as if it were a module, and this doesn't work unless there's no directory of the same name with a __init__.py in it.
Diffstat (limited to 'lib/stitch_plan/trim.py')
-rw-r--r--lib/stitch_plan/trim.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/stitch_plan/trim.py b/lib/stitch_plan/trim.py
new file mode 100644
index 00000000..f692a179
--- /dev/null
+++ b/lib/stitch_plan/trim.py
@@ -0,0 +1,23 @@
+def process_trim(color_block, next_stitch):
+ """Handle the "trim after" checkbox.
+
+ DST (and maybe other formats?) has no actual TRIM instruction.
+ Instead, 3 sequential JUMPs cause the machine to trim the thread.
+
+ To support both DST and other formats, we'll add a TRIM and two
+ JUMPs. The TRIM will be converted to a JUMP by libembroidery
+ if saving to DST, resulting in the 3-jump sequence.
+ """
+
+ delta = next_stitch - color_block.last_stitch
+ delta = delta * (1/4.0)
+
+ pos = color_block.last_stitch
+
+ for i in xrange(3):
+ pos += delta
+ color_block.add_stitch(pos.x, pos.y, jump=True)
+
+ # first one should be TRIM instead of JUMP
+ color_block.stitches[-3].jump = False
+ color_block.stitches[-3].trim = True