-
-
Notifications
You must be signed in to change notification settings - Fork 656
Description
Description
parseSVGPath currently treats the entire SVG string as a single continuous path. SVG strings containing multiple M (moveTo) commands are not handled as separate sub-paths, which causes incorrect fill results for shapes with holes or disconnected regions (e.g. a donut, text outlines, a shield with an inner emblem).
Current behavior
All points from multiple M commands are merged into one flat array, and triangulatePath (earcut) treats them as a single polygon. This produces wrong triangulation for shapes that require holes or separate regions.
Expected behavior
Multiple M commands should define separate sub-paths. The first sub-path is the outer boundary, and subsequent sub-paths are treated as holes. triangulatePath should pass hole indices to earcut for correct triangulation.
Implementation notes
- Track sub-path start indices when a new
Mcommand is encountered - Pass hole start indices to earcut via its second parameter
- Canvas renderer replay should insert
moveToat each sub-path boundary instead of continuouslineTo - WebGL GL_LINES stroke rendering already works with paired points, but needs
moveTogaps between sub-paths
Related: #1198 (SVG arc support)