properly insert color changes

pull/29/head
Lex Neva 2018-01-20 23:00:27 -05:00
rodzic 9c87b73e5b
commit 928b20f738
1 zmienionych plików z 10 dodań i 2 usunięć

Wyświetl plik

@ -136,6 +136,9 @@ def write_embroidery_file(file_path, stitches):
for stitch in stitches:
if stitch.color != last_color:
if last_color is not None:
stitch.stop = True
if stitch.color not in threads:
thread = make_thread(stitch.color)
thread_index = add_thread(pattern, thread)
@ -150,8 +153,13 @@ def write_embroidery_file(file_path, stitches):
libembroidery.embPattern_addStitchAbs(pattern, stitch.x - min_x, stitch.y - min_y, flags, 0)
if flags & libembroidery.JUMP:
# I'm not sure this is right, but this is how the old version did it.
libembroidery.embPattern_addStitchAbs(pattern, stitch.x - min_x, stitch.y - min_y, flags & ~libembroidery.JUMP, 0)
# In C, I'd do flags &= ~(libembroidery.JUMP|libembroidery.STOP).
# Python bitwise not (~) works on signed integers, which really
# isn't what we want. This is effectively the same:
flags &= 0xFFFF - (libembroidery.JUMP|libembroidery.STOP)
# I'm not sure this is right, but the old version added a stitch after the jump.
libembroidery.embPattern_addStitchRel(pattern, 0, 0, flags, 0)
libembroidery.embPattern_addStitchAbs(pattern, stitch.x - min_x, stitch.y - min_y, libembroidery.END, 0)