[whatwg] [Canvas] Behavior on non-invertable CTM

Justin Novosad junov at google.com
Thu Feb 6 14:14:09 PST 2014


On Tue, Jul 23, 2013 at 2:11 PM, Ian Hickson <ian at hixie.ch> wrote:

>
> > >> The second does setTransform(0,0,0,0,0,0), which should reset the CTM
> > >> to a zero matrix (again, not invertible). IE, Opera and FF draw a
> > >> line to 0,0 and close the path afterwards (which kind of makes sense,
> > >> since the universe is convoluted to one point). WebKit refuses the
> > >> lineTo command and closes the path as expected.
> > >
> > > WebKit seems to just be wrong here, and the others right.
> >
> > Since this is not written in the spec
>
> As far as I can tell, it _is_ written in the spec. scale(0,0) would reduce
> all coordinates and lines and so forth to 0,0. That's what the spec
> requires. I don't see the problem here.
>
>
I am looking into correcting Chrome's behavior to make it spec-compliant in
this case.  There is one specific primitive that is proving problematic:
arcTo
The problem is that the algorithm needs to bring the last point in the
subpath into the arc's local coordinate space, which requires inverting the
CTM.

I would like to suggest a small amendment to the spec:

Current text:
If the point (x0, y0) is equal to the point (x1, y1), or if the point (x1,
y1) is equal to the point (x2, y2), or if both radiusX and radiusY are
zero, then the method must add the point (x1, y1) to the subpath, and
connect that point to the previous point (x0, y0) by a straight line.

Suggested addition:
If the current transformation matrix is not invertible, then the method
must add the point (x1, y1) to the subpath, and connect that point to the
previous point in the subpath by a straight line.

Note: I used "previous point in the subpath" rather than "(x0, y0)",
because the point is only defined in global space, and not in local space
due to the CTM being singular.

I have not yet investigated what other browsers are doing in this case.
Feedback from other implementers would be appreciated.

As far as I can tell, quadraticCurveTo and bezierCurveTo do not have this
problem because the curves can be computed by first transforming all points
to global coordinate space, to compute the curves in global space.

Thanks,

     Justin


More information about the whatwg mailing list