W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2014

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

From: Justin Novosad <junov@google.com>
Date: Thu, 20 Mar 2014 13:52:12 -0400
Message-ID: <CABpaAqTns_2dugqa5H+3OVd3_+0RQogin-QchZAHEOUH-QJtOA@mail.gmail.com>
To: WHAT Working Group <whatwg@whatwg.org>
Hello all,

The recently added currentTransform attribute on CanvasRenderingContext2D
gives shared access to the rendering context's transform. By "shared", I

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);

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. Opinions? Perhaps we should also have an overload of
setTransform (or setCTM) that would take an SVGMatrix.

First of all, have any browsers shipped currentTransform yet?


    -Justin Novosad
Received on Thursday, 20 March 2014 17:59:54 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:17 UTC