[whatwg] Proposal: change 2D canvas currentTransform to getter method

Hwang, Dongseong dongseong.hwang at intel.com
Thu Mar 20 11:14:49 PDT 2014


I totally agree on Justin.

On Thu, Mar 20, 2014 at 7:52 PM, Justin Novosad <junov at google.com> wrote:

> Hello all,
>
> The recently added currentTransform attribute on CanvasRenderingContext2D
> gives shared access to the rendering context's transform. By "shared", I
> mean:
>
> a) this code modifies the CTM:
> var matrix = context.currentTransform;
> matrix.a = 2;
>
> b) In this code, the second line modifies matrix:
> var matrix = context.currentTransform;
> context.scale(2, 2);
>

Sharing internal c++ object and javascript object seems to prevent further
optimization. SVG dev seems to feel that exposing SVG object is mistake
even if exposed SVG object is readonly.
For example,
interface SVGTransform {
   readonly attribute SVGMatrix matrix;
}


> This behavior is probably not what most developers would expect.
> I would like to propose changing this to a getter method instead.  We
> already have a setter method (setTransform).
>
> In another thread entitled "Canvas Path.addPath SVGMatrix not optimal",
> Dirk Schulze proposed using the name getCTM, which would be consistent with
> the SVGLocatable interface, where getCTM returns an SVGMatrix. On the other
> hand, we could call it getTransform to be consistent with the existing
> setTransform on CRC2D.


getTransform looks nice.

DS


More information about the whatwg mailing list