Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Canvas tag - drawarc vs image

I've implemented a canvas element that uses drawarc to create the effect of bubbles rising up at various speeds on the background (it's an underwater themed site for an underwater-themed client) - It looks really good and I'm pretty pleased with it, but I'm noticing a slight performance issue in some browsers (specifically IE9).

I'm drawing the bubbles using drawarc to create semi translucent circles - can anyone tell me if this is more or less expensive (in terms of client side performance) to stamp images/sprites onto the canvas instead?

-Mike

like image 325
Mikey Hogarth Avatar asked Dec 28 '22 15:12

Mikey Hogarth


1 Answers

Drawing arcs / circles is much more expensive than drawing images. Drawing images is most likely the most efficient method for drawing anything to a canvas. I wrote my Bachelor Thesis on this subject. It is in german, but basicly when drawing arcs using arc and arcTo you get less than 15.000 operations / sec in IE9. When drawing images you get more than 160.000 operations per second.

like image 112
Daniel Baulig Avatar answered Dec 30 '22 08:12

Daniel Baulig