I am currently using JavaScript to create drawing software.
So I want to create a zoom function, but it doesn't work.
Below is the code
function zoom(x,y)
{
varcanvas= document.getElementById('canvas');
varctx = canvas.getContext('2d');
var width = canvas.width;
var height = canvas.height;
var ImageData=ctx.getImageData(0,0, width, height);
ctx.setTransform(x,0,0,y,0,0);
ctx.putImageData(ImageData,0,0);
}
I changed the zoom function x and y arbitrarily, but it doesn't work.
After changing the magnification, I pasted the image using drawImage
and found the magnification specified.
Can't I use getImageData
or putImageData
?
There are many ways to change the magnification, but I would like to use setTransform
for future production.
Why can't I do it well?
If you understand, please give us some advice or suggestions.
javascript html
Instead of using the canvas context setTransform.
I increased the size of the canvas itself using transform of css.
I was able to do this by setting the overflow:hidden in
I used this as a reference.
http://am-yu.net/2014/04/13/canvas-pbbs-expansion/
545 PHP ssh2_scp_send fails to send files as intended
682 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
524 Uncaught (inpromise) Error on Electron: An object could not be cloned
543 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.