@mocanvas/editor · function

getSvgPathFromPoints

declare function getSvgPathFromPoints(points: readonly VecLike[], closed?: boolean): string

SVG path data through a list of points.

With closed, the path is closed with Z, which is not the same as repeating the first point: only Z makes the join at the start a proper corner rather than two overlapping line caps.

Coordinates are rounded to two decimals. At canvas scale that is far below a device pixel, and it keeps an exported path from being three times longer than it needs to be because of float dust.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.