NPM module for converting svgs to single paths.
This can be useful for icons and other monochromatic SVGs.
<text>
is currently not supported.
Initial code based on svgcrush.
npm install --save svg-path-converter
- Fixed bug related to trailing zeroes in path when using precision > 0 (Thanks to SkylerLipthay)
- Changed default precision from 0 to 4
- Fixed path 'm' commands with more than 2 parameters
- Fixed some
<rect>
elements not being converted correctly
- Bug fixes
- Changed options syntax
svgToPath(svgElement, [options])
import svgToPath from 'svg-path-converter';
let svg = document.querySelector("svg");
let path = svgToPath(svg);
Option | Type | Default | Note |
---|---|---|---|
width | Float | input SVG width | Scale output SVG to given width while preserving aspect ratio |
height | Float | input SVG height | Scale output SVG to given height while preserving aspect ratio |
precision | Integer | 4 | Number of digits after comma for path values |
This project is licensed under the MIT License - see the LICENSE file for details