From b117f85811e710b8029b023457ab27c061373c83 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler <49431240+abey79@users.noreply.github.com> Date: Sat, 20 Jun 2020 03:58:25 +0200 Subject: [PATCH] Fixed crash in line2pathd() (#101) * Fixed crash in line2pathd(). * Further fixed to support implicit attributes --- svgpathtools/svg_to_paths.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/svgpathtools/svg_to_paths.py b/svgpathtools/svg_to_paths.py index f9c3e79..46a66a2 100644 --- a/svgpathtools/svg_to_paths.py +++ b/svgpathtools/svg_to_paths.py @@ -90,8 +90,13 @@ def rect2pathd(rect): "".format(x0, y0, x1, y1, x2, y2, x3, y3)) return d + def line2pathd(l): - return 'M' + l['x1'] + ' ' + l['y1'] + 'L' + l['x2'] + ' ' + l['y2'] + return ( + 'M' + l.attrib.get('x1', '0') + ' ' + l.attrib.get('y1', '0') + + 'L' + l.attrib.get('x2', '0') + ' ' + l.attrib.get('y2', '0') + ) + def svg2paths(svg_file_location, return_svg_attributes=False,