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

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

From: Justin Novosad <junov@google.com>
Date: Fri, 7 Feb 2014 06:44:10 -0800
Message-ID: <CABpaAqTNJvTG-AUEiVFiEtQ4jZyppUR2okUxTp6C5WoEO-N=kA@mail.gmail.com>
To: Ian Hickson <ian@hixie.ch>
Cc: Dirk Schulze <dschulze@adobe.com>, WHATWG List <whatwg@whatwg.org>
On Thu, Feb 6, 2014 at 2:55 PM, Ian Hickson <ian@hixie.ch> wrote:

> On Thu, 6 Feb 2014, Justin Novosad wrote:
> >
> > 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.
> >
> > 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.
>
> I don't understand why this needs the last point in the subpath to be
> converted to the arc's local coordinate space, rather than the other way
> around. Can you elaborate? why can't you convert all the points to the
> current coordinate space before doing the comparisons?
>

The arc is expected to be circular (as opposed to elliptical) in local
space.  If we apply the construction algorithm post-transform, you may not
get the same result. For example, a non-uniform scale will mess things up.


> (I'm probably missing something critical here.)
>
>
> > 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.
>
> Why is this not the case for arcs?
>

With arcs (as opposed to arcTo), the last point in the subpath does not
enter into the curve construction algorithm (we just draw a straight line
from the last point in the subpath to the starting point of the arc).
 Therefore, all the points use for constructing the curve are in the same
coordinate space.  With arcTo, the first point (x0, y0) may have been added
to the current subpath using a different CTM. So to bring it into the local
space of the current primitive, we need an invertible CTM.


> --
> Ian Hickson               U+1047E                )\._.,--....,'``.    fL
> http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
> Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
>
Received on Friday, 7 February 2014 14:44:37 UTC

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