Skip to content

l1553k/path-that-svg

 
 

Repository files navigation

Path that SVG!

Sometimes is useful to have an svg done with paths instead of elements
such as rect, circle, ellipse, line, polyline or polygon.
Like when you apply Compound Path in Adobe Illustrator.

Install

yarn add path-that-svg

Usage

String|Buffer svg

const { pathThatSvg } = require('path-that-svg')

fs.readFile('./elements.svg', (err, input) => {
  pathThatSvg(input).then((convertedFromBuffer) => {
    console.log({ convertedFromBuffer })
  })
})

pathThatSvg(`<svg viewBox="0 0 500 200">
  <rect 
    x="200" 
    y="50" 
    fill="#F16362" 
    stroke="#30456B" 
    stroke-width="5" 
    stroke-linecap="round" 
    stroke-linejoin="round" 
    width="100" height="100"/>
</svg>`).then((convertedFromString) => {
  console.log(convertedFromString)
})

Related

element-to-path Convert SVG element into path

About

Path that SVG!

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%