W3C home > Mailing lists > Public > www-svg@w3.org > July 2009

Re: Canvas and Interactivity

From: Robert O'Callahan <robert@ocallahan.org>
Date: Wed, 15 Jul 2009 14:50:23 +1200
Message-ID: <11e306600907141950w2fa75c05oc3dc45ff7f3eb4e1@mail.gmail.com>
To: anthony.grasso@cisra.canon.com.au
Cc: Jeff Schiller <codedread@gmail.com>, www-svg <www-svg@w3.org>
On Tue, Jul 14, 2009 at 12:27 PM, Anthony Grasso <
anthony.grasso@cisra.canon.com.au> wrote:

> I agree it would be good to reuse existing markups and DOM if possible.
> From the IRC discussion, I'm not sure which part or aspect of SVG is
> considered "crappy". Finding that out would be a good start.

Some of the issues are browser implementation issues.

Many of the issues are around the SVG DOM APIs. For example, consider adding
a circle to the page:
var c = document.createElementNS(... SVG namespace that I can never remember
..., "circle");
c.cx.baseVal.value = 20;
c.cy.baseVal.value = 20;
c.r.baseVal.value = 20;
c.style.fill = "lime";

With canvas:
ctx.fillStyle = "lime";
ctx.arc(20, 20, 20, 0, Math.PI*2, true);

Some of the DOM issues are generic DOM issues, but some of them are
SVG-specific. In particular setting the three circle attributes via the SVG
API requires 6 getters and 3 setters --- 9 round trips from JS to browser
and back. Even worse, it requires creation of 6 temporary objects!
(Actually, in every implementation I know of, it creates at least 12
temporary objects, a "native object" and some kind of JS wrappper.)

I think it would have been a good idea to forget about units in SVG
coordinates, just have user space. Then since access to animated values is
rare, move it to a separate interface (e.g. c.animated.cx). Then you could
c.cx = 20;
c.cy = 20;
c.r = 20;
Much better... Oh well.

"He was pierced for our transgressions, he was crushed for our iniquities;
the punishment that brought us peace was upon him, and by his wounds we are
healed. We all, like sheep, have gone astray, each of us has turned to his
own way; and the LORD has laid on him the iniquity of us all." [Isaiah
Received on Wednesday, 15 July 2009 02:51:00 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:23 UTC