kopia lustrzana https://github.com/inkstitch/inkstitch
clean up PyEmb.Point
rodzic
055eb63bec
commit
1fedbc11b5
6
PyEmb.py
6
PyEmb.py
|
@ -34,18 +34,18 @@ class Point:
|
||||||
# dot product
|
# dot product
|
||||||
return self.x * other.x + self.y * other.y
|
return self.x * other.x + self.y * other.y
|
||||||
elif isinstance(other, (int, float)):
|
elif isinstance(other, (int, float)):
|
||||||
return self.mul(other)
|
return Point(self.x * other, self.y * other)
|
||||||
else:
|
else:
|
||||||
raise ValueError("cannot multiply Point by %s" % type(other))
|
raise ValueError("cannot multiply Point by %s" % type(other))
|
||||||
|
|
||||||
def __rmul__(self, other):
|
def __rmul__(self, other):
|
||||||
if isinstance(other, (int, float)):
|
if isinstance(other, (int, float)):
|
||||||
return self.mul(other)
|
return self.__mul__(other)
|
||||||
else:
|
else:
|
||||||
raise ValueError("cannot multiply Point by %s" % type(other))
|
raise ValueError("cannot multiply Point by %s" % type(other))
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "Pt(%s,%s)" % (self.x, self.y)
|
return "Point(%s,%s)" % (self.x, self.y)
|
||||||
|
|
||||||
def length(self):
|
def length(self):
|
||||||
return math.sqrt(math.pow(self.x, 2.0) + math.pow(self.y, 2.0))
|
return math.sqrt(math.pow(self.x, 2.0) + math.pow(self.y, 2.0))
|
||||||
|
|
|
@ -311,8 +311,8 @@ class Fill(EmbroideryElement):
|
||||||
rows = []
|
rows = []
|
||||||
|
|
||||||
while start < end:
|
while start < end:
|
||||||
p0 = center + normal.mul(start) + direction.mul(half_length)
|
p0 = center + normal * start + direction * half_length
|
||||||
p1 = center + normal.mul(start) - direction.mul(half_length)
|
p1 = center + normal * start - direction * half_length
|
||||||
endpoints = [p0.as_tuple(), p1.as_tuple()]
|
endpoints = [p0.as_tuple(), p1.as_tuple()]
|
||||||
grating_line = shgeo.LineString(endpoints)
|
grating_line = shgeo.LineString(endpoints)
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ class Stroke(EmbroideryElement):
|
||||||
along = (p1 - p0).unit()
|
along = (p1 - p0).unit()
|
||||||
|
|
||||||
# vector pointing to edge of stroke width
|
# vector pointing to edge of stroke width
|
||||||
perp = along.rotate_left().mul(stroke_width * 0.5)
|
perp = along.rotate_left() * (stroke_width * 0.5)
|
||||||
|
|
||||||
if stroke_width == 0.0 and last_segment_direction is not None:
|
if stroke_width == 0.0 and last_segment_direction is not None:
|
||||||
if abs(1.0 - along * last_segment_direction) > 0.5:
|
if abs(1.0 - along * last_segment_direction) > 0.5:
|
||||||
|
|
Ładowanie…
Reference in New Issue