panzoom icon indicating copy to clipboard operation
panzoom copied to clipboard

Implement Zooming by ctx.scale() rather than CSS scale in Canvas

Open naseemshah opened this issue 5 years ago • 1 comments

I have a project using Canvas. I Implemented Panzoom in it, works fine except we need to fine tune zooming in canvas so that it doesn't Blur/Pixilate. I know that Canvas is raster images/Pixels raher than vector. But we have ctx.scale() function where we can scale the whole canvas so that we get crisp images. Can someone implement zomming such that ctx.scale() is used to scale rather than CSS scale?

naseemshah avatar Apr 13 '20 14:04 naseemshah

Yup, totally possible - would have to implement via custom panController. SVG and DOM elements already have their controllers. See here:

https://github.com/anvaka/panzoom/blob/c52e8e6cbb614ae57f11d4e28ebcb9cf799e872f/index.js#L15-L16

you can follow the same steps to make it work for canvas.

Please let me know if you need help!

anvaka avatar Apr 14 '20 16:04 anvaka