Skip to content

v2.0.0-alpha.3

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 01 Mar 11:24
· 238 commits to main since this release

What's Changed

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`)

New Contributors

Full Changelog: v1.4.0...v2.0.0-alpha.3