kopia lustrzana https://github.com/inkstitch/inkstitch
use get_pattern_interpolate_trim
This has the same inaccuracy as the previous version, but we can actually use a pyembroidery function to turn a specific number of jumps into trims.pull/487/head
rodzic
62d4e35be9
commit
1b18d915a9
|
@ -12,6 +12,7 @@ class Input(object):
|
||||||
def affect(self, args):
|
def affect(self, args):
|
||||||
embroidery_file = args[0]
|
embroidery_file = args[0]
|
||||||
pattern = pyembroidery.read(embroidery_file)
|
pattern = pyembroidery.read(embroidery_file)
|
||||||
|
pattern = pattern.get_pattern_interpolate_trim(2)
|
||||||
|
|
||||||
stitch_plan = StitchPlan()
|
stitch_plan = StitchPlan()
|
||||||
color_block = None
|
color_block = None
|
||||||
|
@ -19,20 +20,14 @@ class Input(object):
|
||||||
for raw_stitches, thread in pattern.get_as_colorblocks():
|
for raw_stitches, thread in pattern.get_as_colorblocks():
|
||||||
color_block = stitch_plan.new_color_block(thread)
|
color_block = stitch_plan.new_color_block(thread)
|
||||||
trim_after = False
|
trim_after = False
|
||||||
jump_counter = 0
|
|
||||||
for x, y, command in raw_stitches:
|
for x, y, command in raw_stitches:
|
||||||
if command == pyembroidery.STITCH:
|
if command == pyembroidery.STITCH:
|
||||||
if trim_after:
|
if trim_after:
|
||||||
color_block.add_stitch(trim=True)
|
color_block.add_stitch(trim=True)
|
||||||
trim_after = False
|
trim_after = False
|
||||||
color_block.add_stitch(x * PIXELS_PER_MM / 10.0, y * PIXELS_PER_MM / 10.0)
|
color_block.add_stitch(x * PIXELS_PER_MM / 10.0, y * PIXELS_PER_MM / 10.0)
|
||||||
jump_counter = 0
|
if len(color_block) > 0 and command == pyembroidery.TRIM:
|
||||||
elif len(color_block) > 0:
|
trim_after = True
|
||||||
# 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
|
extents = stitch_plan.extents
|
||||||
svg = etree.Element("svg", nsmap=inkex.NSS, attrib={
|
svg = etree.Element("svg", nsmap=inkex.NSS, attrib={
|
||||||
|
|
Ładowanie…
Reference in New Issue