added polyline and polygon functions (points --> Path of Line objects)

pull/8/merge
Andy 2017-04-26 01:54:44 -07:00
parent a3a529899c
commit a094f92b3a
1 changed files with 15 additions and 0 deletions

View File

@ -97,6 +97,21 @@ def bbox2path(xmin, xmax, ymin, ymax):
return Path(b, r, t.reversed(), l.reversed())
def polyline(*points):
"""Converts a list of points to a Path composed of lines connecting those
points (i.e. a linear spline or polyline). See also `polygon()`."""
return Path(*[Line(points[i], points[i+1])
for i in range(len(points) - 1)])
def polygon(*points):
"""Converts a list of points to a Path composed of lines connecting those
points, then closes the path by connecting the last point to the first.
See also `polyline()`."""
return Path(*[Line(points[i], points[(i + 1) % len(points)])
for i in range(len(points))])
# Conversion###################################################################
def bpoints2bezier(bpoints):