Showing posts with label html5. Show all posts
Showing posts with label html5. Show all posts

Tuesday, 7 December 2010

html5 canvas speed notes

Setting fill and Stroke style can have a negative performance impact even if you dont use them and are setting them to what they used to be. (Firefox)

ctx.fillStyle
ctx.strokeStyle



Also I can't make dirty rectangles code run as fast as just doing a big clearRect for the whole canvas. This is for frantic - a space invaders style game where nearly every sprite will have moved since the last paint

ctx.clearRect(0,0,width,height);


Drawing text on canvas:
fillText about twice as fast as strokeText

HTML5 Canvas multiple layers

You can use several canvases on top of each other each one with a different zindex attribute and use them as layers.

Nice simple example of multiple canvases