[whatwg] Canvas Path.addPath SVGMatrix not optimal?

Dirk Schulze dschulze at adobe.com
Wed Mar 19 22:06:52 PDT 2014



On Mar 19, 2014, at 10:48 PM, "Rik Cabanier" <cabanier at gmail.com<mailto:cabanier at gmail.com>> wrote:




On Wed, Mar 19, 2014 at 2:22 PM, Justin Novosad <junov at google.com<mailto:junov at google.com>> wrote:
On Wed, Mar 19, 2014 at 4:46 PM, Dirk Schulze <dschulze at adobe.com<mailto:dschulze at adobe.com>> wrote:

> Hi,
>
> I just looked at the definition of Path.addPath[1]:
>
>     void addPath(Path path, SVGMatrix? transformation);
>
> SVGMatrix is nullable but can not be omitted all together. Why isn't it
> optional as well? I think it should be optional, especially because
> creating an SVGMatrix at the moment means writing:
>
>     var matrix = document.createElementNS('http://www.w3.org/2000/svg
> ','svg').createSVGMatrix();
>
> Greetings,
> Dirk
>
> [1]
> http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#path


I agree it should be optional, but just to play devil's advocate : you can
create an identity SVGMatrix with a simpler bit of code. Just do this right
after creating a canvas rendering context: var identity =
context.currentTransform;

Hi Justin,

did Blink already expose this property?
As currently specified, this must return a live SVGMatrix object, meaning that as you change the CTM on the 2d context, your reference to the SVGMatrix should change as well. [1]

It's unlikely that you actually want this...
This API should be renamed to get/setCurrentTransform() and return a copy.

It could be called getCTM() which SVG offers on SVGElements and also returns an SVGMatrix object. But I agree that it would be easier if we return a copy instead of a live object.

What does Blink do?

Greetings,
Dirk


1: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-currenttransform


More information about the whatwg mailing list