From 3e3d54008937e0195c88143986ab6dc44c21facb Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 8 Jan 2016 22:56:10 -0500 Subject: major revamp * properly process transform parameters (ungrouping no longer necessary!) * handle satin on beziers properly * previously beziers were stroked as straight line segments that included control points * allow overriding parameters on individual paths by adding extra svg params * embroider_angle, embroider_stitch_length, embroider_zigzag_spacing, embroider_row_spacing, etc * set using "Edit XML" * default to 10 pixels per millimeter * properly write CSV files in millimeters (was dividing by 10) * always translate pattern to origin to fit in hoop * add "running stitch length" for < 0.5 stroke width) * don't traceback if no paths were selected * add "repeats" option for stroke (satin/running stitch) to go back and forth over the line * good for a double line of center-line underlay below satin --- PyEmb.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'PyEmb.py') diff --git a/PyEmb.py b/PyEmb.py index 0423b583..af118e25 100644 --- a/PyEmb.py +++ b/PyEmb.py @@ -63,9 +63,14 @@ class Embroidery: maxy = max(maxy,p.y) sx = maxx-minx sy = maxy-miny + + self.translate(-minx, -miny) + return (minx, miny) + + def translate(self, dx, dy): for p in self.coords: - p.x -= minx - p.y -= miny + p.x += dx + p.y += dy def scale(self, sc): if not isinstance(sc, (tuple, list)): @@ -160,11 +165,11 @@ class Embroidery: int(stitch.color[3:5], 16), int(stitch.color[5:7], 16)) if stitch.jumpStitch: - self.str += '"*","JUMP","%f","%f"\n' % (stitch.x/10, stitch.y/10) + self.str += '"*","JUMP","%f","%f"\n' % (stitch.x, stitch.y) if lastColor != None and stitch.color != lastColor: # not first color choice, add color change record - self.str += '"*","COLOR","%f","%f"\n' % (stitch.x/10, stitch.y/10) - self.str += '"*","STITCH","%f","%f"\n' % (stitch.x/10, stitch.y/10) + self.str += '"*","COLOR","%f","%f"\n' % (stitch.x, stitch.y) + self.str += '"*","STITCH","%f","%f"\n' % (stitch.x, stitch.y) lastColor = stitch.color return self.str -- cgit v1.2.3