fix: svgparser creates polygon with no points #133
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
This pull request refactors the
SvgParserclass to improve handling of SVG elements and introduces new functionality for detecting self-intersecting polygons. The key changes include simplifying the replacement logic forcircleandrectelements, adding a self-intersection check for polygons, and handling degenerate shapes more robustly.Refactoring and Simplification:
circleandrectelements by removing redundant transformation code and directly applying transformations to the new elements. Degenerate shapes (e.g., circles with radius 0 or rectangles with width/height 0) are now identified and removed with a warning. (main/svgparser.js, main/svgparser.jsL1099-R1162)New Features:
isPolygonSelfIntersecting) for polygons. This checks if a polygon's edges intersect inappropriately, and skips processing of self-intersecting paths with a warning. (main/svgparser.js, main/svgparser.jsR1510-R1594)Debugging Enhancements:
console.logandconsole.warnstatements to provide insights into the processing of paths, including degenerate shapes and self-intersections. (main/svgparser.js, main/svgparser.jsR1510-R1594)