Path.area() calls poly() on each segment, but Arc() doesn't provide that method. The area can be approximated using linear interpolation of the Arc:
def approximate_path_area(path):
"""Approximates the path area by converting each Arc to 1,000
Lines."""
assert(path.isclosed())
tmp = svgpathtools.path.Path()
for seg in path:
if type(seg) == svgpathtools.path.Arc:
for i in range(0, 1000):
t0 = i/1000.0
t1 = (i+1)/1000.0
l = svgpathtools.path.Line(start=seg.point(t0), end=seg.point(t1))
tmp.append(l)
else:
tmp.append(seg)
return tmp.area()
Path.area() calls poly() on each segment, but Arc() doesn't provide that method. The area can be approximated using linear interpolation of the Arc: