News for hackers. Stuff that matters.
Re:SVG vs Canvas, what format to choose? by mcdaid on Monday May 23, 2011 @05:08AM (#2575394)
On the topic of SVG and Canvas, I think it would be really useful if Canvas had a method similar to drawImage but instead could draw svg.

for example

var circle = document.createElementNS("http://www.w3.org/2000/svg, "circle"); circle.setAttribute("style", "fill:green"); circle.setAttribute("cx", 50); circle.setAttribute("cy", 50); circle.setAttribute("r", 25);

ctx.drawSvg(circle,x,y,w,h);

I think then we could have the best of both worlds, define complex shapes in svg, but use canvas for rendering. The advantage over just using svg is that every shape is in the dom, so if you want to draw 1000 similar shapes the dom gets cluttered.

Re:SVG vs Canvas, what format to choose? by wladimir on Monday May 23, 2011 @05:29AM (#2575423)
Yes, that'd be very useful as a built-in. In the meantime, you could use a SVG-on-canvas renderer such as:

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

Re:SVG vs Canvas, what format to choose? by justincormack on Monday May 23, 2011 @05:37AM (#2575436)
Some browsers can render images in canvas that are actually SVG files, but support is a bit patchy outside Webkit, and there are some other issues, but may work for you. http://www.svgopen.org/2010/papers/62-From_SVG_to_Canvas_and...
Re:SVG vs Canvas, what format to choose? by zeen on Monday May 23, 2011 @06:37AM (#2575521)
http://jsbin.com/ibuqi5

Looks great in Chrome for me, aliased in Firefox.