Files
lucide/docs/.vitepress/lib/SvgPreview/path-to-points.ts
Jakob Guddas 57714e36ea feat(SvgPreview): add features from lucide studio (#3365)
* feat(SvgPreview): add features from lucide studio

* Update docs/.vitepress/lib/SvgPreview/index.tsx

---------

Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
2025-07-30 16:20:24 +02:00

20 lines
562 B
TypeScript

import memoize from 'lodash/memoize';
import SVGPathCommander from 'svg-path-commander';
import { Path } from './types';
function pathToPoints({ d, prev, next }: Path, interval = 1) {
const commander = new SVGPathCommander(d);
const points = [];
try {
const totalLength = commander.getTotalLength();
points.push(prev);
for (let i = interval; i < totalLength - interval; i += interval) {
points.push(commander.getPointAtLength(i));
}
points.push(next);
} catch (err) {}
return points;
}
export default memoize(pathToPoints);