/ Playing with Canvas: Starfields in Firefox

I’ve been itching to play with Canvas for a while now and tonight I finally had the time and energy to actually do something with it*.

Granted it’s very basic in terms of what Canvas can do, but I’ve been in love with starfields ever since I coded my first one years ago in Quick Basic and I’ve been dying to do one in JavaScript for a long time now. Canvas gave me the opportunity to generate and move real pixels around–instead of DOM elements!

For those of you who want to pick the code apart, note the easy instantiation of the Starfield class. With literally 3 lines of code you can add another starfield to the page. :-)

* In case you didn’t catch it in the post title, this only works in Safari and recent Gecko based browsers like Firefox and Opera.


Read more from the archive.