kopia lustrzana https://github.com/inkstitch/inkstitch
Use path instead of points for polyline elements (#1661)
* use polyline-path instead of points * handle empty polylinespull/1666/head
rodzic
a4f8191dc2
commit
dec43b9c5f
|
@ -46,20 +46,10 @@ class Polyline(EmbroideryElement):
|
||||||
def polyline(self):
|
def polyline(self):
|
||||||
return self.get_boolean_param("polyline")
|
return self.get_boolean_param("polyline")
|
||||||
|
|
||||||
@property
|
|
||||||
def points(self):
|
|
||||||
# example: "1,2 0,0 1.5,3 4,2"
|
|
||||||
|
|
||||||
points = self.node.get('points').strip()
|
|
||||||
points = points.split(" ")
|
|
||||||
points = [[float(coord) for coord in point.split(",")] for point in points]
|
|
||||||
|
|
||||||
return points
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@cache
|
@cache
|
||||||
def shape(self):
|
def shape(self):
|
||||||
return shgeo.LineString(self.points)
|
return shgeo.LineString(self.path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path(self):
|
def path(self):
|
||||||
|
@ -68,9 +58,12 @@ class Polyline(EmbroideryElement):
|
||||||
# svg transforms that is in our superclass, we'll convert the polyline
|
# svg transforms that is in our superclass, we'll convert the polyline
|
||||||
# to a degenerate cubic superpath in which the bezier handles are on
|
# to a degenerate cubic superpath in which the bezier handles are on
|
||||||
# the segment endpoints.
|
# the segment endpoints.
|
||||||
path = self.node.get_path()
|
if self.node.get('points', None):
|
||||||
|
path = self.node.get_path()
|
||||||
|
else:
|
||||||
|
# Set path to (0, 0) for empty polylines
|
||||||
|
path = 'M 0 0'
|
||||||
path = Path(path).to_superpath()
|
path = Path(path).to_superpath()
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -99,7 +92,7 @@ class Polyline(EmbroideryElement):
|
||||||
return stitches
|
return stitches
|
||||||
|
|
||||||
def validation_warnings(self):
|
def validation_warnings(self):
|
||||||
yield PolylineWarning(self.points[0])
|
yield PolylineWarning(self.path[0][0][0])
|
||||||
|
|
||||||
def to_stitch_groups(self, last_patch):
|
def to_stitch_groups(self, last_patch):
|
||||||
patch = StitchGroup(color=self.color)
|
patch = StitchGroup(color=self.color)
|
||||||
|
|
Ładowanie…
Reference in New Issue