SVG (Scalable Vector Graphics) is awesome.
This is just shout-out for anyone interested in, but yet to use SVG on the web to Get On It.
SVG is an XML based web standard for creating native vector graphics on the web - As I understand it, it’s fully supported in all the latest and greatest versions of the major browsers, and will be in IE9.
I believe IE’s lack of support is what has stunted it’s uptake amongst developers.
IE6-8 will be around for quite some time to come so it’s not really an option right now is it?
Absolutely.
Dmitry Baranovskiy, an Australian javascript developer has created Raphaël, a neat library to provide a javascript interface for creating / manipulating SVG that support every browser worth mentioning.
Two examples that shows it’s capability well are:
Every part of an SVG graphic is a DOM element - so you can attach events and respond to user actions like in the pie chart above.
Canvas is an another option for drawing graphics on the web but it just isn’t as cool.
Firstly, vectors are cooler than pixels
Vectors require less information to draw shapes because the graphics are simply encoded path strings which the browser then translates into pixels on the screen.
If you’re not from a design background vectors are good for solid shapes like logos - not for creating images like photographs.
SVG is scalable
Ever since I first opened up Illustrator and starting drawing, paths, zooming, my graphics maintaining their crystal clarity I’ve had a thing for vectors.
They also print much better than images because their dimensions can scale to fit the page where pixels just get squashed.
SVG is made up of real objects
The canvas api doesn’t provide any form of saving a collection of pixels as an object, all you ever have with canvas is a series of javascript calls that tell the browser to push pixels around on a canvas. For this reason if you want to animate a moving square you need to draw the square, clear the canvas, redraw the square, clear the canvas and so on.
With SVG you can simply update the position of the one object.
I haven’t watched it myself yet but I hear this is a good getting started guide to Raphael if you are interested:
http://peepcode.com/products/raphaeljs
I’m going to have a think about a cool usage of SVG and write a plugin for raphael.
If anyone has a good idea of something they would like to see with vectors let me know.
Or, if you would like to have a go with me have a look at Dmitry’s g.raphael plugins to see how it can be done. e.g.
http://github.com/DmitryBaranovskiy/g.raphael/blob/master/g.line.js?raw=true