kopia lustrzana https://github.com/inkstitch/inkstitch
bugfixes
* shift the design to the origin * don't include a bunch of extra END instructions at the end of a DSTpull/29/head
rodzic
a7a7c6cc92
commit
9c87b73e5b
18
PyEmb.py
18
PyEmb.py
|
@ -123,6 +123,12 @@ def get_flags(stitch):
|
|||
return flags
|
||||
|
||||
def write_embroidery_file(file_path, stitches):
|
||||
# Embroidery machines don't care about our canvas size, so we relocate the
|
||||
# design to the origin. It might make sense to center it about the origin
|
||||
# instead.
|
||||
min_x = min(stitch.x for stitch in stitches)
|
||||
min_y = min(stitch.y for stitch in stitches)
|
||||
|
||||
pattern = libembroidery.embPattern_create()
|
||||
threads = {}
|
||||
|
||||
|
@ -141,12 +147,18 @@ def write_embroidery_file(file_path, stitches):
|
|||
last_color = stitch.color
|
||||
|
||||
flags = get_flags(stitch)
|
||||
libembroidery.embPattern_addStitchAbs(pattern, stitch.x, -stitch.y, flags, 0)
|
||||
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, -stitch.y, flags & ~libembroidery.JUMP, 0)
|
||||
libembroidery.embPattern_addStitchAbs(pattern, stitch.x - min_x, stitch.y - min_y, flags & ~libembroidery.JUMP, 0)
|
||||
|
||||
libembroidery.embPattern_addStitchAbs(pattern, stitch.x, -stitch.y, libembroidery.END, 0)
|
||||
libembroidery.embPattern_addStitchAbs(pattern, stitch.x - min_x, stitch.y - min_y, libembroidery.END, 0)
|
||||
|
||||
# convert from pixels to millimeters
|
||||
libembroidery.embPattern_scale(pattern, 1/PIXELS_PER_MM)
|
||||
|
||||
# SVG and embroidery disagree on the direction of the Y axis
|
||||
libembroidery.embPattern_flipVertical(pattern)
|
||||
|
||||
libembroidery.embPattern_write(pattern, file_path)
|
||||
|
|
Ładowanie…
Reference in New Issue