mathandy / svgpathtools

A collection of tools for manipulating and analyzing SVG Path objects and Bezier curves.
MIT License
548 stars 138 forks source link

reopening of issue #125 error in colors for wsvg #131

Closed piscvau closed 3 years ago

piscvau commented 3 years ago

AN error is generated by wsvg when using an instance of Path as paths and a list as colors. ` from svgpathtools.path import Line, Path as sPath from svgpathtools.paths2svg import wsvg from svgpathtools.parser import parse_path

path = parse_path(f"M 50, 200 a 100, 50 0 0 0 250,50") line1 = Line(start=55 + 250j, end=350 + 200j) line2 = Line(start=75 + 270j, end=360 + 210j) todisplay = sPath(path[0], line1, line2) colors = ('black', 'green', 'blue') filename = 'essai' wsvg(todisplay, filename=filename, colors=colors )

`

mathandy commented 3 years ago

This is the expected behavior -- that said, there's a simple workaround:

Simply change todisplay --> todisplay._segments

` from svgpathtools.path import Line, Path as sPath from svgpathtools.paths2svg import wsvg from svgpathtools.parser import parse_path

path = parse_path(f"M 50, 200 a 100, 50 0 0 0 250,50") line1 = Line(start=55 + 250j, end=350 + 200j) line2 = Line(start=75 + 270j, end=360 + 210j) todisplay = sPath(path[0], line1, line2) colors = ('black', 'green', 'blue') filename = 'essai' wsvg(todisplay._segments, filename=filename, colors=colors ) `