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

Justin Novosad junov at google.com
Fri Feb 7 06:44:10 PST 2014


On Thu, Feb 6, 2014 at 2:55 PM, Ian Hickson <ian at 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.   `._.-(,_..'--(,_..'`-.;.'
>



More information about the whatwg mailing list