From cf81db3670dd985583b2d158dd1214f8f2e717e0 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 13 Feb 2016 22:13:47 -0500 Subject: [PATCH] add END stitch --- PyEmb.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/PyEmb.py b/PyEmb.py index 4e5861351..44fcc7e46 100644 --- a/PyEmb.py +++ b/PyEmb.py @@ -19,6 +19,21 @@ class Point: def mul(self, scalar): return Point(self.x*scalar, self.y*scalar) + def __mul__(self, other): + if isinstance(other, Point): + # dot product + return self.x * other.x + self.y * other.y + elif isinstance(other, (int, float)): + return self.mul(other) + else: + raise ValueError("cannot multiply Point by %s" % type(other)) + + def __rmul__(self, other): + if isinstance(other, (int, float)): + return self.mul(other) + else: + raise ValueError("cannot multiply Point by %s" % type(other)) + def __repr__(self): return "Pt(%s,%s)" % (self.x,self.y) @@ -170,6 +185,7 @@ class Embroidery: self.str += '"*","JUMP","%f","%f"\n' % (stitch.x, stitch.y) self.str += '"*","STITCH","%f","%f"\n' % (stitch.x, stitch.y) lastStitch = stitch + self.str += '"*","END","%f","%f"\n' % (lastStitch.x, lastStitch.y) return self.str def export_gcode(self, dbg):