path-rite

parsePath

Parse an SVG path d-attribute string into structured path data.

parsePath(svgPath: string): PathData

svgPath — SVG path d-attribute string (e.g. "M 0 0 L 100 0 L 100 100 Z").

Returns — A PathData object containing an elements array of path commands (MoveTo, LineTo, QuadTo, CurveTo, ClosePath).

// Parse a triangle path
const data = pathRite.parsePath("M 0 0 L 100 0 L 50 80 Z");
// data.elements = [
//   { type: "MoveTo", x: 0, y: 0 },
//   { type: "LineTo", x: 100, y: 0 },
//   { type: "LineTo", x: 50, y: 80 },
//   { type: "ClosePath" }
// ]