here is my javascript code :
> var logoImg = new Image();
> logoImg.src = '../img/smiley.png';
>
> // Store the original width value so that we can keep the same width/height ratio later
> var originalWidth = logoImg.width;
>
> // Compute the new width and height values
> logoImg.width = Math.round((50 * document.body.clientWidth) / 100);
> logoImg.height = Math.round((logoImg.width * logoImg.height) / originalWidth);
>
> // Create an small utility object
> var logo = {
img : logoImg,
> x : (canvas.width / 2) - (logoImg.width / 2),
> y : (canvas.height / 2) - (logoImg.height / 2)
> }
>
> // Present the image
> c.drawImage(logo.img, logo.x, logo.y, logo.img.width, logo.img.height);
this code doesn't work the image isn't displayed .... i tried to trace the code and i found that the logoImg.width=0 and logoImg.height=0 ... any suggestions????? thanks in advance
You can put a time Interval. Eg :