svg-path-converter

1.0.12 • Public • Published

svg-path-converter npm version

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.

Installation

npm install --save svg-path-converter

Updates

Version 1.0.12

  • Fixed bug related to trailing zeroes in path when using precision > 0 (Thanks to SkylerLipthay)
  • Changed default precision from 0 to 4

Version 1.0.11

  • Fixed path 'm' commands with more than 2 parameters
  • Fixed some <rect> elements not being converted correctly

Version 1.0.8

  • Bug fixes
  • Changed options syntax

Usage

svgToPath(svgElement, [options])

import svgToPath from 'svg-path-converter';
let svg = document.querySelector("svg");
let path = svgToPath(svg);

Options

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

License

This project is licensed under the MIT License - see the LICENSE file for details

Readme

Keywords

none

Package Sidebar

Install

npm i svg-path-converter

Weekly Downloads

117

Version

1.0.12

License

MIT

Unpacked Size

27.1 kB

Total Files

6

Last publish

Collaborators

  • fulanko