News for hackers. Stuff that matters.
Re:SVG vs Canvas, what format to choose? by andrewcooke on Monday May 23, 2011 @09:54AM (#2575901)
The big difference is that for SVG the structure "remains", while with canvas it is "forgotten". That makes SVG more complex, but also easier to manipulate.

Here's an SVG site I wrote (it'll take a while to load and will only display in recent browsers). The way that it responds to mouse-overs is (relatively) easy to program in SVG because you can associate events with structure in the image - http://practi.cl/en/proj/pysrc/lepl/lepl#pkg-tab=b-dependenc... (it's showing package dependencies for a Python library).

To do something similar with canvas you would redraw sections instead of simply changing the properties of arcs, etc (and handling user clicks is lower-level - instead of getting the action associated with some "thing" in the image, you get a coordinate). Which is "best" depends on the application. The link above makes more sense in SVG because you've got logically distinct, overlapping components. But if you want a more static image, canvas is probably going to be simpler.

There are no comments on this comment yet.