Christmas comes around once again and the thoughts of web developers the world over turn to festivising their websites. Festivising is probably not a real word, but I expect you know what I mean.
This year I decided to make some simple falling snow to liven up a page,
and I used the HTML5
canvas element to do it with - which means
it won't work in every browser (i.e. not IE < 9).
I'm giving the source away completely free of any license, so you
can do whatever you want with it. I suggest changing the
function to vary the shape, but that's up to you. Here it is: snow.js.
Here is the code to add snow to a page:
options all have default values, so setting them is not required.
If you would like to try out the snow on your own site (or any other site for that matter) I have prepared this bookmarklet: Snow!
Drag it to your bookmark bar, add it to your bookmarks list or however you add bookmarks, then when you visit the page you want to add snow to, load the bookmark. The snow.js file will be loaded and snow will start falling on the page. The snow uses a toggle function, so hitting the bookmark again will turn it back off (or you could just reload the page or navigate away - it does not persist).
Update 02/02/2011 - I've made an improvement to the script, making it a bit more efficient and with some variation in the size of the flakes and the way they fall.