Canvas

Drawing Sprites with Canvas

Drawing Sprites with Canvas

One of the first articles I wrote on this blog back in May 2010 was about how useful sprites are and how to use them with CSS. It’s can be an absolute headache to implement simple spriting with CSS. Thankfully drawing sprites is implemented natively within the canvas api.

Getting ready

Before I go in to specifics of drawing on a canvas all of these examples expect a 2D context to be available. I won’t repeat this for each example so here is a quick example of how to get it.