Skip to content

Commit dfac122

Browse files
HKPTechNGExplorer
authored andcommitted
MGG-1402 [#ccc] svgpathtools:bugfix: Skip the end path in a polyline if no dedicated end path is provided
References: MGG-1402, MGG-1448 Introduce an 'is_polygon' flag in 'polygon2pathd' function to handle the end path in polyline and polygon if path string or is_polygon flag is enableed then append path given in input if path string and is_polygon flag is enable then append 'z' path Signed-off-by: Harikrushna Parmar <harikrushna.parmar@nxp.com>
1 parent 5a863dc commit dfac122

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

svgpathtools/svg_to_paths.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def polyline2pathd(polyline, is_polygon=False):
9393
# The `parse_path` call ignores redundant 'z' (closure) commands
9494
# e.g. `parse_path('M0 0L100 100Z') == parse_path('M0 0L100 100L0 0Z')`
9595
# This check ensures that an n-point polygon is converted to an n-Line path.
96-
if is_polygon and closed:
96+
if is_polygon or closed:
9797
points.append(points[0])
9898

9999
d = 'M' + 'L'.join('{0} {1}'.format(x,y) for x,y in points)
@@ -102,13 +102,13 @@ def polyline2pathd(polyline, is_polygon=False):
102102
return d
103103

104104

105-
def polygon2pathd(polyline):
105+
def polygon2pathd(polyline, is_polygon=True):
106106
"""converts the string from a polygon points-attribute to a string
107107
for a Path object d-attribute.
108108
Note: For a polygon made from n points, the resulting path will be
109109
composed of n lines (even if some of these lines have length zero).
110110
"""
111-
return polyline2pathd(polyline, True)
111+
return polyline2pathd(polyline, is_polygon)
112112

113113

114114
def rect2pathd(rect):
@@ -230,7 +230,7 @@ def dom2dict(element):
230230
# path strings, add to list
231231
if convert_polygons_to_paths:
232232
pgons = [dom2dict(el) for el in doc.getElementsByTagName('polygon')]
233-
d_strings += [polygon2pathd(pg) for pg in pgons]
233+
d_strings += [polygon2pathd(pg, True) for pg in pgons]
234234
attribute_dictionary_list += pgons
235235

236236
if convert_lines_to_paths:

0 commit comments

Comments
 (0)