Jump to content

Possible Error in HTML5 Canvas Example


Guest elispene

Recommended Posts

Guest elispene

Not quit sure where to post this and there doesn't appear to be any contact information on the W3Schools main site...Anyhow, I think there is an error in one of the canvas example where an image is being dawn onto a canvas (link).If you are already on the page with the list of examples, you may notice that the last example actually shows up as a blank canvas but when you go into the actual example the image shows up. From here, if you got back to the previous page (Back button, Alt + left arrow, whichever...) then the image would show up.Moreover, I tried copying the code (and the image, of course) onto my machine and then run it - nothing. After fiddling around a little and Googling for a bit there seems to be a pre-loading problem with the example on W3Schools.One solution I have found so far is to add, after the lines:var img = new Image();img.src = "img_flwr.png"The lines:img.onload = function(){ context.drawImage(img, 0, 0);}Apologies in advance if I made a mistake - beginner here. :)Oh, also, because of that an animation example that I was working on didn't quite work out for me - feel free to drop a hint or two. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...