summaryrefslogtreecommitdiff
path: root/PyEmb.py
diff options
context:
space:
mode:
authorLex Neva <github@lexneva.name>2016-02-13 22:13:47 -0500
committerLex Neva <github@lexneva.name>2016-02-13 22:13:47 -0500
commitcf81db3670dd985583b2d158dd1214f8f2e717e0 (patch)
tree0237393b2ea594cc321625a8339b6247a3a5b6c0 /PyEmb.py
parent5635eca31555b8feda58036e35f1112310821616 (diff)
add END stitch
Diffstat (limited to 'PyEmb.py')
-rw-r--r--PyEmb.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/PyEmb.py b/PyEmb.py
index 4e586135..44fcc7e4 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):