views:

514

answers:

6

Are there any tools to transform SVG (XML) data to Canvas friendly input?

+2  A: 

No I don't think so. SVG is actually rather different to Canvas. SVG is a vector graphics description language, whereas Canvases are programmatically "drawn" by sets of instructions. Also, Canvas isn't actually vector based at all.

Take a look at the Raphael Javascript Library. Its API will draw SVG/Canvas/VML depending on the capabilities of the browser.

nickf
nice library indeed.
Robert Gould
+1  A: 

Dojo also has support for rendering SVG.

See the dojoX package. link text

jeff porter
A: 

Take a look at XSLT.

harley.333
Yeah, I know I can do it with XSLT, however writing the transformer isn't trivial. So I was looking for a tool that already does this for me, or something similar
Robert Gould
+1  A: 

Take a look at this article from the svg open conference. Somewhere in the middle it discusses a method to combine svg and canvas using server side rendering.

Evgeny
+1  A: 

Take a look at canvg. It is a JavaScript library that will parse SVG and render into a specified canvas element:

http://code.google.com/p/canvg/

There's also an Ajaxian article (but I can only post one link per post) It's titled "CanVG: Using Canvas to render SVG files"

Sean Gilligan
The Ajaxian article is here: http://ajaxian.com/archives/canvg-using-canvas-to-render-svg-files
Sean Gilligan
A: 

I used Canvg as a basis to create this online tool:

www.professorcloud.com/svg-to-canvas

It creates JavaScript Canvas functions from SVG input. Doesn't do the whole SVG spec, but enough to be useful.

Professor Cloud