I am trying to draw a few .png images to the HTML5 canvas using JavaScript. I currently have a function that will draw an image to the canvas, but the image is too large for the canvas, so only part of it displays.
The function I currently have is:
function drawImage(x, y){
var numberImage = new Image();
numberImage.src = imageSource;
context.drawImage(numberImage, x, y);
}
and I call the function by using:
var image1 = new Image();
image1.onLoad = function(){
context.drawImage(image1, 50, 50);
};
image1.src="1.png";
I was just wondering if anyone knows of a way of resizing an image when it's drawn to the canvas, so that I could just a thumbnail sized image?
Thanks in advance!
I have tried adding parameters in to the drawImage function to resize the image, but this doesn't seem to have made any difference...
var image1 = new Image();
image1.onLoad = function(){
context.drawImage(image1, 50, 50, 10, 10);
};
image1.src="1.png";