tamakisquare
tamakisquare

Reputation: 17067

Why would one use html5 canvas to draw an image instead of using <img>?

I was going over a tutorial on html5 canvas. One of the sections is teaching you how to draw canvas based on an image. While everything works out fine, I am puzzled about why using canvas over simply loading the image using <img>.

Upvotes: 1

Views: 343

Answers (2)

LetterEh
LetterEh

Reputation: 26696

Games which use sprites,
3D games with textured-polygons,
Image-editing functionality,
Cropping and scaling in real-time,
Image-filters in real-time...

If you're just using canvas to load an image, that's going to be a lot of work for absolutely no payoff, because you actually have to LOAD an image into an img element, or an Image() object, before you can even use it on the canvas.

Upvotes: 1

anotherdave
anotherdave

Reputation: 6744

You could do image manipulation to the original in this way: think Instagram-style filters or ChromaKey (green-screen).

Upvotes: 3

Related Questions