[whatwg] Canvas arcTo
Ian Hickson
ian at hixie.ch
Thu Jan 31 13:51:36 PST 2008
On Mon, 2 Jul 2007, Philip Taylor wrote:
>
> As implemented, the operation of arcTo in Firefox (2, 3) and Opera (9.2,
> 9.5) is utterly unrelated to the spec and arguably crazy. At least Opera
> has the right spirit and tries drawing arcs between points, though
> they're the wrong points and they're always semicircles. Safari nearly
> matches the spec, and it's still sensible when it disagrees with the
> spec, so that's the only one that's relevant to consider. There are some
> examples at <http://canvex.lazyilluminati.com/misc/arcto.html>.
>
> "If the point (x2, y2) is on the line defined by the points (x0, y0) and
> (x1, y1) then the method must do nothing, as no arc would satisfy the
> above constraints." - why would no arc satisfy the constraints? If P0,
> P1, P2 are collinear and non-coincident, then (I think) any of the
> (infinitely many) circles which have the given radius and touch
> tangential to the line P0->P2 will satisfy the constraints (i.e. being
> tangential to P0->P1 at some point and to P1->P2 at some point).
The idea is to just take the two (infinite) lines that are defined by the
points (end at P1, cross P0 and P2), and draw a circle with the given
radius between them.
When the lines are the same line (i.e. P0->P1 is parallel to P1->P2) then
no circle with a finite non-zero radius can touch the line tangentially at
more than two points, since for each half of the circle, every point has a
different tangent, and the two points on opposite sides of the circle are
tangents to parallel but distinct lines unless the radius is zero.
No?
> When P0->P1 and P1->P2 are parallel and the same direction, Safari just
> draws the line P0->P1. When they are parallel but opposing directions,
> it instead draws a line from P0 to a point infinitely far from P0 in the
> direction P1->P2. That is sensible in both cases since it's equal to the
> limit as the two lines tend towards parallelism.
Indeed. I've required this now.
> If P0=P1 (and either P2=P1 or P2!=P1) then Safari does nothing at all
> and does not add any points to the subpath (or, equivalently, it does
> add the point P1 to the subpath, which has no effect since the line
> P0->P1 has zero length). If P1=P2 and P0!=P1, then it adds the point P1
> to the subpath. Both of these seem generally sane - there's no sensible
> limit as the points tend towards coincidence, so there's no real correct
> answer, and drawing the straight line P0->P1 seems an adequate thing to
> do.
Ok, done.
> "Negative or zero values for radius must cause the implementation to
> raise an INDEX_SIZE_ERR exception." - why not allow zero? You just get
> an arc at P1 with zero length, with the start and end tangent points
> both at P1, so the effect would be a straight line from P0 to P1,
> without needing to handle it as a special case. Safari works like that.
Done.
> So, I think the following definition would cover all the cases and match
> Safari: [...]
(BTW, it's actually easier for me to end up rewriting the text in response
to feedback, than it is for me to handle suggested replacement text. One
major reason for this is that if the text has been changed in response to
other feedback, I risk losing those changes if I just replace it.)
Cheers,
--
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