[whatwg] canvas 2d's ellipse

Ian Hickson ian at hixie.ch
Tue Sep 17 10:30:38 PDT 2013


On Tue, 20 Aug 2013, Tab Atkins Jr. wrote:
> On Tue, Aug 20, 2013 at 3:46 PM, Ian Hickson <ian at hixie.ch> wrote:
> > On Tue, 30 Apr 2013, Rik Cabanier wrote:
> >> I think the API should look like this:
> >>
> >> void ellipse(unrestricted double x, optional unrestricted double y, 
> >> unrestricted double radiusX, optional unrestricted double radiusY, 
> >> optional unrestricted double rotation, optional unrestricted double 
> >> startAngle, optional unrestricted double endAngle, optional boolean 
> >> anticlockwise);
> >>
> >> with the following behavior:
> >> - if radiusY is omitted, it's the same as radiusX
> >> - if rotation is omitted, it's equal to 0
> >> - if startAngle is omitted, it's equal to 0
> >> - if endAngle is omitted, it's equal to 0
> >> - if anticlockwise is omitted, it's equal to false
> >
> > We could do this, sure. How much do people want something like this? 
> > Does anyone else think it's a good idea?
> 
> I can tell you that specifying all of the arguments in SVG's ellipse 
> path command is rather annoying.  Having good defaults would be a good 
> thing.

The problem here is since the arguments are positional, it doesn't let you 
just omit the ones you want to omit, only the last few that you don't need.

If implementors want to do it, I'm happy to spec it, but it doesn't seem 
to be something many people feel strongly about...


On Tue, 20 Aug 2013, Rik Cabanier wrote:
> > >
> > > So, if you want to draw a simple circle, you have to supply 8 
> > > parameters, even though only 3 are needed.
> >
> > If you just want a circle, you can use arc().
> 
> OK. What if you want to draw a simple ellipse?

What's a "simple" ellipse?


> Here's an example of the issue: http://jsfiddle.net/2N85k/2/
> Because the stroke is using square caps, you can't draw a circle or an
> ellipse unless you do a closePath.

Yes? Why is this a problem?


> Chrome is doing an implicit closePath if start and end angle meet, but 
> none of the other browsers do.

Then Chrome is buggy. Nothing in the spec says to implicitly close the 
path.


> However the spec should be clearer on what happens if the arc is 2 π for
> arc and ellipse.
> Chrome believes that case should have a 'closePath' which seems reasonable.
> Maybe someone on that team can tell us if this was intentional.

I'm tracking this issue here:

   https://www.w3.org/Bugs/Public/show_bug.cgi?id=23050

I don't really understand what's ambiguous about the spec. Please do 
elaborate on this in the bug.


> > On Tue, 30 Apr 2013, Rik Cabanier wrote:
> > >
> > > I think the exception on negative radius should also be removed.
> >
> > What would a negative radius mean?
> 
> Either treat it as zero, or use the absolute value. Avoiding exceptions 
> will make web apps more robust.

Or more buggy, because authors won't notice their errors.

I'm not a fan of "sweep it under the carpet" bug handling, personally. It 
drives me crazy that JavaScript has no type checking, no argument 
checking, etc. So many bugs that should be caught at compile time, or at 
least at runtime when the code is reached, are instead caught only after 
careful testing.

-- 
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