soulwire / Coffee-Physics

A simple, lightweight physics engine written in CoffeeScript
MIT License
1.06k stars 89 forks source link

Canvas renderer caching #10

Closed schteppe closed 11 years ago

schteppe commented 11 years ago

Hi, Nice work with the engine! Regarding the demo CanvasRenderer, I see you rerender circles very often. By caching the ones of same size + color and doing ctx.drawImage( cachedCanvas, x, y ), you can speed up things a lot.

For an example, see http://iainlobb.com/bunnies/bunnies.html Or: http://www.professorcloud.com/mainsite/cache-canvas.htm

Stefan