[2.0.0-alpha.3] - 2022-03-01
Added
- feat: add
.width
and .height
to get the original size of the SVG. - feat: add
toString()
to convert SVG shapes or text to path.
Changed
-
refactor: change to Class API, now instead use new Resvg()
to create the constructor.
With the new Class API, we can avoid rendering the SVG again when getting the SVG size. It also makes it easier to extend new APIs.
Before
const { render } = require('@resvg/resvg-js')
const svg = '' // svg buffer or string
const pngData = render(svg, opts)
After
const { Resvg } = require('@resvg/resvg-js')
const svg = '' // svg buffer or string
const resvg = new Resvg(svg, opts)
const pngData = resvg.render()
// New!
console.info('Simplified svg string \n', resvg.toString())
console.info('SVG original size:', `${resvg.width} x ${resvg.height}px`)