HTML5 Canvas vs SVG

Advertise Here

, , …,

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:

Sample Animated SVG

Here's is a animated SVG.

soccer ball rotating
rotating soccer ball in SVG. img src

Works in all browsers as of .

Be sure to view source of the above SVG file. You can get a idea what SVG format is like.

Use Inkscape to Learn and Create SVG

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 LogoQi Language LogoLISP LogoXah's Java Logo. You can view their SVG source code.

JavaScript Library for SVG

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 JavaScript 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: Source raphaeljs.com. They look pretty impressive.

blog comments powered by Disqus