Xah Lee, 2010-12-22
Spent few hours looking at HTML5 Canvas and Scalable Vector Graphics (SVG).
My conclusion is: i won't touch HTML5 Canvas. Here's some highlights:
Here's is a animated SVG you can view in your browser: soccer_ball_rotating.svg. (works in current versions Google Chrome (8.0.552.224), Opera (10.63), Safari (5.0.3), all on Windows. In Firefox (3.6.13), the soccer ball shows but does not rotate.) The source is from Source en.wikipedia.org
Be sure to view source of the above svg file. You can get a idea what svg format is like.
There's a wonderful vector graphics drawing tool Inkscape. I've been using it since few years ago. It is fantastic. I learned it quickly, and loved it. I have used Gimp much earlier, and have spend much more time with gimp, but find it rather more complex.
After you created a drawing in Inkscape and saved to a file, you can open the file in a text editor, and see the source code of the svg. This is a great way to learn about the svg format. You can create a simple circle and look at the file to see the svg syntax for that. Similarly, you can draw oval, square, path, text, color, fill, gradient, etc and view their syntax. Also, the tool lets you convert any bitmapped image to vector graphics.
For example, i've used Inkscape to create the following logos. The Emacs Logo ◇ Qi Language Logo ◇ LISP Logo ◇ Xah's Java Logo. You can view their svg source code.
There are several js libraries that create SVG for you. So, you call js functions to create images, without needing to know anything about SVG. With such a library, you don't have to worry about SVG syntax or browser support problems.
One of the most popular js svg library seems to be Raphaël (JavaScript Library). Quote:
Raphaël is a JavaScript library that draws SVG graphics for web sites. It also provides a VML alternative for cross-browser compatibility. Raphaël currently supports Firefox 3.0+, Safari 3.0+, Opera 9.5+ and Internet Explorer 6.0+.
Have a look at the demos on its home page at: http://raphaeljs.com/. They look pretty impressive.