I like to change some canvas image (hat and jacket)
here is the code
document.ready = function() {
canvas = document.getElementById('canvasspace');
ctx = canvas.getContext('2d');
drawImage();
}
function drawImage(){
var tempimage = new Image();
tempimage.src = jackets_images[jacket_to_draw];
tempimage.onload = function (){ ctx.drawImage(tempimage, 0, 0); };
var tempimage2 = new Image();
tempimage2.src = hats_images[hat_to_draw];
tempimage2.onload = function (){ ctx.drawImage(tempimage2, 0, 0); };
}
the two image show up one over the other one, but making 2 time the code with 2 new Image(); does not seem fine to my eye ! but i dont know better.. please show me the light
1 Answer