Re: new SVGMatrix() should return the identity matrix

I can understand the rational which may have lead to this current
design.  Since unlike the proposed (and now gone) CSSMatrix, SVGMatrix
takes floats as an argument.  If those arguments are missing,
presumably undefined is assumed and undefined evaluates to 0.  That's
definitely less magical to some set of JS ninjas than having the no
argument version give you the identity (at the cost of the no argument
version instead giving you a much less useful zero-matrix).

I guess authors can learn to do:

var identity = new SVGMatrix(1, 0, 0, 1, 0, 0);

instead (assuming I even typed that correctly from memory?)

identity.scale(2);

in all their code.  Bleh.

On Sat, Nov 30, 2013 at 11:07 PM, Eric Seidel <eseidel@chromium.org> wrote:
> Currently SVGMatrix() returns the zero matrix [1]
>
> Yet SVGTransform() returns an identity transform [2]
>
> CSSMatrix (when it was briefly specced [3] returned the identity as
> does WebKitCSSMatrix and I suspect MSCSSMatrix).
>
> It seems to me it would make more sense for SVGMatrix() to return the
> identity matrix rather than the zero matrix.
>
> It's much more common that you would want to start with the entity and
> then modify it, rather than the zero matrix.
>
> For example: "(new SVGMatrix).scale(2)" seems totally reasonable, and
> would work perfectly if new SVGMatrix returned the identity.
>
>
> 1. http://www.w3.org/TR/SVG2/coords.html#InterfaceSVGMatrix
> 2. http://www.w3.org/TR/SVG2/coords.html#InterfaceSVGTransform
> 3. http://www.w3.org/TR/2011/WD-css3-2d-transforms-20111215/

Received on Monday, 2 December 2013 21:18:20 UTC