path-rite

pathLength

Get the total arc length of a path.

pathLength(svgPath: string, accuracy: number): number

svgPath — SVG path d-attribute string.

accuracy — Computation accuracy. Smaller values give more precise results at the cost of performance. Typical value: 0.1.

Returns — The total length of the path in SVG units.

// Measure the perimeter of a 100x100 square
const len = pathRite.pathLength("M 0 0 L 100 0 L 100 100 L 0 100 Z", 0.1);
// len === 400