首页 > 解决方案 > Parse SVG path from string in JavaScript

问题描述

I need to parse a SVG path composed of M and C commands:

M 9.50,12.787 
C 10 10 10 90 10 90 
C 10 90 90 90 90 90
C 90 90 90 10 90 10
C 90 10 10 10 10 10
C 10 10 10 10 10 10
M 20,20 
C 20 20 80 80 80 80 
C 80 80 20 80 20 80
C 20 80 20 20 20 20
C 20 20 20 20 20 20

I need to convert the string into an array containing the commands and the associated points. I'm not familiar with parsing, and I don't know what is the best practice to avoid building a labyrinthine system.

标签: javascriptparsingsvg

解决方案


推荐阅读