The library powering the SvgPathEditor app.
import { SvgPath } from 'svg-path-editor-lib';
// Throw an error if path is invalid
const parsedPath = new SvgPath(path);
parsedPath.asString(
decimals, // default `4`
minifyOutput // default `false`
)
Scale:
parsedPath.scale(x, y);
Translate:
parsedPath.translate(x, y);
Rotate:
parsedPath.rotate(x, y, angle);
Convert to relative:
parsedPath.setRelative(true);
Convert to absolute:
parsedPath.setRelative(false);
Reverse:
import { reversePath } from 'svg-path-editor-lib';
reversePath(parsedPath);
Advanced optimizations:
import { optimizePath } from 'svg-path-editor-lib';
optimizePath(parsedPath, {
removeUselessComponents, // default `false`
useShorthands, // default `false`
useHorizontalAndVerticalLines, // default `false`
useRelativeAbsolute, // default `false`
useReverse, // default `false`
removeOrphanDots , // default `false`, may be destructive
});