svg-path-editor-lib
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Svg-path-editor-lib

The library powering the SvgPathEditor app.

Usage

Parse path

import { SvgPath } from 'svg-path-editor-lib';

// Throw an error if path is invalid
const parsedPath = new SvgPath(path);

Generate path

parsedPath.asString(
    decimals,       // default `4`
    minifyOutput    // default `false`
)

Operations

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
});

Package Sidebar

Install

npm i svg-path-editor-lib

Weekly Downloads

2

Version

1.0.1

License

Apache-2.0

Unpacked Size

202 kB

Total Files

39

Last publish

Collaborators

  • yqnn