diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2019-07-04 15:35:31 +0200 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2019-07-04 10:52:30 -0400 |
| commit | f039ef4c8d05628ebf6e13fb011ec054dc4c8740 (patch) | |
| tree | 5161acf9ce67227315519f938e1a2906e8c159ab | |
| parent | 23ac0a4f7fb6d7c47728d42a03085a732cb75a10 (diff) | |
respect trim commands
| -rw-r--r-- | lib/extensions/input.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/extensions/input.py b/lib/extensions/input.py index fbc37bd7..9f1314eb 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -18,10 +18,21 @@ class Input(object): for raw_stitches, thread in pattern.get_as_colorblocks(): color_block = stitch_plan.new_color_block(thread) + trim_after = False + jump_counter = 0 for x, y, command in raw_stitches: - # let's ignore commands for now if command == pyembroidery.STITCH: + if trim_after: + color_block.add_stitch(trim=True) + trim_after = False color_block.add_stitch(x * PIXELS_PER_MM / 10.0, y * PIXELS_PER_MM / 10.0) + jump_counter = 0 + elif len(color_block) > 0: + # some file formats use 3 or more jump stitches in a row to indicate a trim + if command == pyembroidery.JUMP: + jump_counter += 1 + if command == pyembroidery.TRIM or jump_counter >=3: + trim_after = True extents = stitch_plan.extents svg = etree.Element("svg", nsmap=inkex.NSS, attrib={ |
