+ 2

How to zoom in and zoom out a canvas image ?

I have done something but i am not sure if this is the right way to do it or if it even works!! https://code.sololearn.com/WMXk3QVy6MrH/?ref=app Ty in advance!

5th Aug 2021, 11:26 AM
Abhay
Abhay - avatar
4 Answers
+ 3
scale function would transform the position proportionally, need to refactor it if origin point is not at 0,0. Use setTransform to reset the transform https://code.sololearn.com/W0zH09bPaUV5/?ref=app https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/scale
5th Aug 2021, 1:25 PM
CalviŐ˛
CalviŐ˛ - avatar
+ 2
You could zoom in and out by changing a scale() function. Ex. Change zoom on click or on scroll
5th Aug 2021, 11:31 AM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
0
CalviŐ˛ tyvm !
5th Aug 2021, 2:52 PM
Abhay
Abhay - avatar
- 1
Aleksei Radchenkov kindly read the description. And i know i can use scale and touch or scroll(that's a different topic), and in fact i have used it as well here but it's not easy to scale things up and down when it comes to canvas and that is what my question is about . Ty though!
5th Aug 2021, 11:35 AM
Abhay
Abhay - avatar