# [whatwg] Canvas arcTo method

Michael Day mikeday at yeslogic.com
Wed Sep 12 00:07:12 PDT 2012

```Hi Ian,

> Yeah, that's why the spec hand-waves to transform the line too... but I
> agree that that doesn't really work.
>
> Do you have any suggestion of how to spec this better?

This is the most general arcTo situation:

setTransform(M0)
lineTo(x0, y0)
setTransform(M)
arcTo(x1, y1, x2, y2, radius, ...)

To generate the arc we need three points: P0, P1, P2, all in the same
coordinate system. The three points are:

P0 = inverse(M) * M0 * (x0, y0)
P1 = (x1, y1)
P2 = (x2, y2)

We are transforming (x0, y0) by M0, which is the transform current at
the time the point was added to the path. This gives us a point in
canvas coordinates that we can transform by the inverse of M, which is
the transform current at the time the arc is added to the path. This
gives us a point in the same coordinate space as P1 and P2.

In the common case where M = M0, the transforms cancel each other out
and P0 = (x0, y0).

Once we have the three points in the same coordinate space we can
generate the arc and then apply M to all of the points in the generated
arc to draw the arc in canvas coordinates.

Does this make sense?

I don't think it is possible to specify this process without requiring
an inverse transformation somewhere, to get all three points into the
same coordinate space. If so, it is probably best to describe this
explicitly, rather than ambiguously implying the need for it.

Best regards,

Michael

```