This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23050 - <canvas>: clarify the end point of ellipse
Summary: <canvas>: clarify the end point of ellipse
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-23 17:46 UTC by Dongseong Hwang
Modified: 2013-11-20 11:02 UTC (History)
4 users (show)

See Also:


Attachments
test html (1.37 KB, text/html)
2013-08-23 17:50 UTC, Dongseong Hwang
Details
expected result image file (27.08 KB, image/png)
2013-08-23 17:51 UTC, Dongseong Hwang
Details
line-arc-line-expected-results (7.92 KB, image/png)
2013-11-19 08:38 UTC, Dongseong Hwang
Details

Description Dongseong Hwang 2013-08-23 17:46:05 UTC
When endAngle-startAngle is greater than 2π, the spec defines the end point ambiguously.

http://www.w3.org/TR/2dcontext2/#dom-context-2d-arc
If the anticlockwise argument false and endAngle-startAngle is equal to or greater than 2π, or, if the anticlockwise argument is true and startAngle-endAngle is equal to or greater than 2π, then the arc is the whole circumference of this ellipse.

In that case,
WebKit, Firefox and IE regard the end point as the start point because they just draw the whole circumference.
Chromium determines the end point according to the end angle.

In my opinion, Chromium implementation is better.

I want the spec to clearly clarify the end point of ellipse when sweep angle is greater than 2π.
Comment 1 Dongseong Hwang 2013-08-23 17:50:48 UTC
Created attachment 1388 [details]
test html
Comment 2 Dongseong Hwang 2013-08-23 17:51:24 UTC
Created attachment 1389 [details]
expected result image file
Comment 3 Ian 'Hixie' Hickson 2013-08-23 21:35:02 UTC
Could you elaborate on what it is about "The points at startAngle and endAngle along this circle's circumference, measured in radians clockwise from the ellipse's semi-major axis, are the start and end points respectively" and "the arc is the path along the circumference of this ellipse from the start point to the end point, going anti-clockwise if the anticlockwise argument is true, and clockwise otherwise" that is ambiguous?
Comment 4 Dongseong Hwang 2013-08-25 14:54:15 UTC
(In reply to comment #3)
> Could you elaborate on what it is about "The points at startAngle and
> endAngle along this circle's circumference, measured in radians clockwise
> from the ellipse's semi-major axis, are the start and end points
> respectively" and "the arc is the path along the circumference of this
> ellipse from the start point to the end point, going anti-clockwise if the
> anticlockwise argument is true, and clockwise otherwise" that is ambiguous?

To me, it is not ambiguous. So I fixed chromium in https://codereview.chromium.org/18286007/

However, WebKit, Firefox and IE still determine the end point that equals the start point when the sweep angle is greater than 2pi. It said that someone might be confused. no offense.

I'll file this issue to WebKit, Firefox and IE.
Comment 5 rcabanie 2013-08-26 19:55:35 UTC
(In reply to comment #3)
> Could you elaborate on what it is about "The points at startAngle and
> endAngle along this circle's circumference, measured in radians clockwise
> from the ellipse's semi-major axis, are the start and end points
> respectively" and "the arc is the path along the circumference of this
> ellipse from the start point to the end point, going anti-clockwise if the
> anticlockwise argument is true, and clockwise otherwise" that is ambiguous?

It's still confusing in that you can't tell if the arc should be a closed path when the angle is equal or greater than 2pi.
The text is unclear which is why browsers have different behavior.
Comment 7 Peter Occil 2013-08-29 21:40:29 UTC
I believe that the reporter is arguing that an "arc" should wrap around an ellipse more than once.
Comment 8 rcabanie 2013-09-04 20:36:27 UTC
(In reply to comment #7)
> I believe that the reporter is arguing that an "arc" should wrap around an
> ellipse more than once.

I don't think so. 
the confusion lies in that when the angle is equal or greater than 2π, should the path be closed.
Comment 9 Dongseong Hwang 2013-09-05 04:54:24 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > I believe that the reporter is arguing that an "arc" should wrap around an
> > ellipse more than once.
> 
> I don't think so. 
> the confusion lies in that when the angle is equal or greater than 2π,
> should the path be closed.

You are right. Your summary is easy :)
In my opinion, arc should not be closed because the spec does not say about it.
Comment 10 Ian 'Hixie' Hickson 2013-09-17 17:29:49 UTC
Yeah there's nothing in the spec that I can see that would imply the path is closed. Why would it be closed?
Comment 11 Ian 'Hixie' Hickson 2013-11-19 00:06:28 UTC
So I finally figured out the confusion. The spec says that the arc is 2π in circumference if the points are more than 2π apart, but also says that the arc's start and end points are at the given points, even if they aren't a multiple of 2π apart. When they're more than 2π apart, these two conditions are mutually exclusive, if the subpath is to be continuous.

Here's a test case: http://goo.gl/CxK0ic

Most browsers (IE, Firefox, Safari) agree that the end point gets ignored in this case, so I've updated the spec to say that too.
Comment 12 contributor 2013-11-19 00:06:36 UTC
Checked in as WHATWG revision r8294.
Check-in comment: Make arc() match reality better and contradict itself less.
http://html5.org/tools/web-apps-tracker?from=8293&to=8294
Comment 13 Dongseong Hwang 2013-11-19 08:38:44 UTC
Created attachment 1416 [details]
line-arc-line-expected-results

The picture is the results of following script:

c.clearRect(0, 0, 640, 480);
c.save();
try {
  c.beginPath();
  c.moveTo(100,100);
  c.arc(200, 100, 50, Math.PI, 9/2*Math.PI, false);
  c.lineTo(200,200);
  c.stroke();
} finally {
  c.restore();
}

Chrome results in the left one.
IE, Firefox and Safari result in the right one.

The spec is changed to the right one.

Besides current browser status, I think the left one is more intuitive result. Do you think the right one is really better?
Comment 14 Ian 'Hixie' Hickson 2013-11-19 19:57:11 UTC
I think the right one is better because it's what most browsers do.

(Also, I don't really understand what the left one would mean. Does the line overlap itself? If so, it's clearly violating the part of the spec that says you can't draw an arc that's more than 2π in length. Is it creating a new subpath? In that case, would you get a cap in the middle of the arc suddenly?)
Comment 15 Dongseong Hwang 2013-11-19 20:10:19 UTC
(In reply to Ian 'Hixie' Hickson from comment #14)
> I think the right one is better because it's what most browsers do.
> 
> (Also, I don't really understand what the left one would mean. Does the line
> overlap itself? If so, it's clearly violating the part of the spec that says
> you can't draw an arc that's more than 2π in length. Is it creating a new
> subpath? In that case, would you get a cap in the middle of the arc
> suddenly?)

I see. I'll apply this spec changes to Chrome.

As explaining chrome's implementation, arc path overlapes itself, but does not draw twice on the overlaped part.
Comment 16 Ian 'Hixie' Hickson 2013-11-19 21:37:39 UTC
(In reply to Dongseong Hwang from comment #15)
> 
> As explaining chrome's implementation, arc path overlapes itself, but does
> not draw twice on the overlaped part.

How does that work when the path is dashed?
Comment 17 Dongseong Hwang 2013-11-20 11:02:14 UTC
(In reply to Ian 'Hixie' Hickson from comment #16)
> (In reply to Dongseong Hwang from comment #15)
> > 
> > As explaining chrome's implementation, arc path overlapes itself, but does
> > not draw twice on the overlaped part.
> 
> How does that work when the path is dashed?

Wow, it's very important question. overlapped.
http://jsfiddle.net/LDWBX/3/

I DID test only stroke with alpha. Now, I totally agree with this spec change. Thank you.