resvg-js icon indicating copy to clipboard operation
resvg-js copied to clipboard

feat: `.pixels` return type changed to Uint8ClampedArray

Open yisibl opened this issue 1 year ago • 1 comments

Part of #300

Now you can pass the resvg-js rendered pixels to the canvas in the browser via new ImageData().

const resvgJS = new resvg.Resvg(svgString)
const pngData = resvgJS.render()
const imageData = new ImageData(pngData.pixels, pngData.width, pngData.height)

let canvas = document.createElement('canvas')
canvas.width = imageData.width
canvas.height = imageData.height

let ctx = canvas.getContext('2d')
ctx.putImageData(imageData, 0, 0)
document.body.appendChild(canvas)

yisibl avatar Feb 28 '24 12:02 yisibl

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
resvg-js ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2024 0:51am

vercel[bot] avatar Feb 28 '24 12:02 vercel[bot]