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

On Mar 24, 2014, at 4:43 PM, Rik Cabanier <cabanier@gmail.com> wrote:

> 
> 
> 
> On Mon, Mar 24, 2014 at 8:34 AM, Simon Sarris <simon.sarris@gmail.com> wrote:
> 
> On Mon, Mar 24, 2014 at 11:26 AM, Hwang, Dongseong <dongseong.hwang@intel.com> wrote:
> 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
> 
> 
> I'm heavily in favor of option 1.
> 
> I think using "Current" in the naming convention is silly. The transform just as much a part of state as lineWidth/etc, but nobody would propose naming lineWidth something like currentLineWidth! There's no way to get a *non-current* transformation matrix (or lineWidth), so I think the distinction is unnecessary.
> 
> CTM only seems like a good idea if we're worried that the name is too long, but since "Current" is redundant/extraneous, I don't think an initialism is worth the added layer of confusion.

I suggested getCTM() because it is already exposed to the Web stack. Adding yet another function with the same behavior and return value but different name has not much value IMO.

Btw. there is a difference of the current transformation matrix and a normal transformation matrix. CTM is much more explicit in general and therefore used in specifications.

> 
> +1  
> There's already a "transform" function that takes an array that works the same way. 

transform is different and appends a matrix to the CTM, it is not a CTM nor does it set the CTM. That is why you can not compare it. setTransform is different which takes 6 doubles and actually sets the CTM. Also, there is no equivalent for a setter in SVG. That is why I do not care much about the name of the setter.

Greetings,
Dirk

Received on Monday, 24 March 2014 21:18:12 UTC