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

Looking over this thread, we make a consensus not to
expose currentTransform attribute.

Now, all we have to decide is API

Option 1,
SVGMatrix getTransform();
void setTransform(SVGMatrix);  <-- it overrides void
setTransform(unrestricted double a, unrestricted double b, unrestricted
double c, unrestricted double d, unrestricted double e, unrestricted double
f);

Option 2,
SVGMatrix getCTM();
void setCTM(SVGMatrix);

Option 3,
SVGMatrix getCurrentTransform();
void setCurrentTransform(SVGMatrix);

Which is the best?

Greetings, DS


On Sat, Mar 22, 2014 at 9:45 AM, Dirk Schulze <dschulze@adobe.com> wrote:

>
>
> Sent from my iPhone
>
> > On Mar 22, 2014, at 5:11 AM, "Rik Cabanier" <cabanier@gmail.com> wrote:
> >
> > On Thu, Mar 20, 2014 at 11:18 AM, Simon Sarris <simon.sarris@gmail.com
> >wrote:
> >
> >> On Thu, Mar 20, 2014 at 1:52 PM, Justin Novosad <junov@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);
> >>>
> >>> 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?
> >>>
> >>> Thoughts?
> >>>
> >>>    -Justin Novosad
> >>
> >>
> >> FF (at least Aurora/Nightlies) has for some time had mozCurrentTransform
> >> (and mozCurrentTransformInverse), which return an Array (so not
> >> spec-compliant, since spec wants SVGMatrix). It is not shared, so it
> does
> >> not do what your a) and b) examples do.
> >>
> >> I agree that changing it to a getter method would be better, it would be
> >> more intuitive and clear for developers.
> >
> > Looking over this thread, getTransform gets the most support.
> > we could add the following methods:
> >
> > SVGMatrix getTransform();
> >
> > void setTransform(SVGMatrix);
>
> The getter does. I would still vote for interoperability and name it
> getCTM() which returns an SVGMatrix in SVG too.
>
> Greetings
> Dirk
> ---------------------------------------------------------------------
> Intel Finland Oy
> Registered Address: PL 281, 00181 Helsinki
> Business Identity Code: 0357606 - 4
> Domiciled in Helsinki
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
>

Received on Monday, 24 March 2014 15:54:31 UTC