canvas set image height
var imageHeight=100;
var imageWidth=100;
context.drawImage(image, 0, 0,imageHeight,imageWidth);
canvas set image height
var imageHeight=100;
var imageWidth=100;
context.drawImage(image, 0, 0,imageHeight,imageWidth);
change image size in canvas
/*Generally you can't resize drawn element in canvas, but you can redraw
it with changed parameters. Something like this.*/
function clearDrawAndGrow ( multiplier ){
context.clear(0,0,canvas.width,canvas.height);
/*Whats important that you should not change size of the origin
image, but sizes on "drawImage()" method as below*/
context.drawImage(image, 0, 0, image.width * multiplier, image.height * multiplier);
}
//Example code that change image size every 2 sec:
var image = document.getElementById("image");
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
var size = 1;
function draw(){
clearDrawAndGrow(size);
size *= 1.1;
}
setInterval(draw, 2000);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us