Re: elliptical canvas.arc?

On 5/10/2011 8:30 PM, Ian Hickson wrote:
> What is the use case for a dedicated ellipse API rather than using bezier?

A fair question, with a pretty simple two-fold answer: 1) bezier arc 
approximation is an approximation, using very expensive operations to 
approximate a very cheap operation instead (and if you want to do it 
right, there's first the particularly nasty business of working out the 
math that tells you how many bezier segments you even need to get an 
approximation with an precision-error lower than ...). That doesn't make 
a lot of sense. 2) why would people have to reinvent the wheel time and 
time again just to get an ellipse or elliptical arc? That's just bad API 
design =)

If that question underlines why there is no elliptical arc, then I could 
of course retort with "good point: why is there a circular arc? you can 
approximate it with bezier curves too." -- however the math for circular 
arc approximation is just as hard as the math for elliptical arc 
approximation. And it'll always be much more expensive to perform than 
dedicated, actually correct, elliptical/circular arc functions.

A lack of implementation desire should not be much of a problem here - 
implementing the elliptical arc, given that people already implement the 
circular arc, is not a lot of work. Implementing it as a bezier 
approximation, on the other hand, is very much a lot of work. It would 
be a pretty good idea to make sure that only a handful of 
implementations are needed for an elementary shape, rather than forcing 
everyone who wants to draw one to reinvent the wheel, and end up with 
something that isn't actually wheel, but more of a polygon.

If you offer an arc (which I think you should for a 2D graphics API, 
because it makes life for the people using that API much easier, keeping 
them creatively busy instead of bogged down trying to work out math for 
what should be elementary drawing operations) then offering an 
elliptical arc as "main" arc just makes sense. Even if you, as designer 
can only think of circles, the rest of the world is bigger. An 
elliptical lets you draw circles, so you get what you want, and it can 
also draw a literally infinitely more diverse family of shapes, which 
are essential to many people who aren't you.

I actually looked up how to get a message to this list, because I hear 
everyone around me complain that there's no ellipse command, and that 
the Canvas API people should do something about it. When asked if 
they've posted to your list, the responses are invariably "no, I'm not 
subscribed" or "they won't listen anyway". So I hope to prove the latter 
wrong by arguing the case for an elliptical arc command. It just makes 
sense to have one.

- Mike

Received on Wednesday, 11 May 2011 04:17:50 UTC