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

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

From: Rik Cabanier <cabanier@gmail.com>
Date: Thu, 6 Feb 2014 15:24:00 -0800
Message-ID: <CAGN7qDAJAJjAtU8a7M6AA5_MoqkfZVFNMODCO7tycLOyY28-hw@mail.gmail.com>
To: Justin Novosad <junov@google.com>
Cc: Dirk Schulze <dschulze@adobe.com>, WHATWG List <whatwg@whatwg.org>, Ian Hickson <ian@hixie.ch>
On Thu, Feb 6, 2014 at 2:14 PM, Justin Novosad <junov@google.com> wrote:

> On Tue, Jul 23, 2013 at 2:11 PM, Ian Hickson <ian@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.


Wow. That would be really impressive!
Given the algorithm for 'tracing a path' [1], what would the following
fiddle look like? http://jsfiddle.net/bn3LF/4/



> 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.
>

1:
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#trace-a-path
Received on Thursday, 6 February 2014 23:24:27 UTC

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