More snow

Published

I was reading through some web pages over the weekend that suggested ways of improving the performance of Javascript when doing things with HTML5 canvas-based applications. I was using the snow script to try them out on, with a slight modification to allow me to use it for benchmarking. Some of the changes made measureable improvements, but the one change that made the greatest improvement was not on the list - probably because it is blatantly obvious: don't copy more of an image than you need!

My snowflake is created on an offscreen canvas and then copied to the canvas that sits behind the main page. The snowflake itself only takes up 40x40 pixels, but I had set the size of the canvas to 400x400 pixels. Every time the snowflake was being drawn over 150,000 useless blank pixels were being checked to see if they contained anything to be copied to the main canvas. Reducing the size of the snowflake canvas to 40x40 pixels improved things significantly.

The updated script is on the snow page - the bookmarklet link has not changed, so if you are using that you should find the new script is picked up straight away (or when the old script expires from your browser cache).

« Previous: TagCanvas 1.6 Next: TagCanvas 1.6.1 »

This site uses cookies - details here.