1var imageHeight=100;
2var imageWidth=100;
3context.drawImage(image, 0, 0,imageHeight,imageWidth);
1/*Generally you can't resize drawn element in canvas, but you can redraw
2it with changed parameters. Something like this.*/
3
4function clearDrawAndGrow ( multiplier ){
5 context.clear(0,0,canvas.width,canvas.height);
6 /*Whats important that you should not change size of the origin
7 image, but sizes on "drawImage()" method as below*/
8 context.drawImage(image, 0, 0, image.width * multiplier, image.height * multiplier);
9}
10
11//Example code that change image size every 2 sec:
12var image = document.getElementById("image");
13var canvas = document.getElementById("canvas");
14var context = canvas.getContext("2d");
15var size = 1;
16
17function draw(){
18 clearDrawAndGrow(size);
19 size *= 1.1;
20}
21
22setInterval(draw, 2000);