[comp.sys.mac.programmer] INIT for better ellipse algorithm?

jurjen@cwi.nl (Jurjen N.E. Bos) (02/24/89)

Hi,
I am searching for an INIT that replaces the algorithm used by 
QuickDraw to draw ellipse frames (to be accurate: FrameOval).
The current algorithm has problems with very slim ellipses (say,
5*200) that get holes in them.  You can see it while using Moire, for
example.
It this program already written?  Is this bug removed in the newer systems?
-- 
  -- Jurjen N.E. Bos (jurjen@cwi.nl)

keith@Apple.COM (Keith Rollin) (02/25/89)

In article <7928@boring.cwi.nl> jurjen@cwi.nl (Jurjen N.E. Bos) writes:
>
>Hi,
>I am searching for an INIT that replaces the algorithm used by 
>QuickDraw to draw ellipse frames (to be accurate: FrameOval).
>The current algorithm has problems with very slim ellipses (say,
>5*200) that get holes in them.  You can see it while using Moire, for
>example.
>It this program already written?  Is this bug removed in the newer systems?

This problem was discussed up here a couple of months ago. While the holes in
skinny or flat ovals are obviously undesirable, there is a reason for them. The
way an oval is framed is to first generate the list of points that surround
the oval, inset the framing rect by the pensize, and then generate the set of
points of the inner oval. Everything in between is plotted. With this kind of
frame generation, you can accurately nest concentric ovals/circles.

I tried changing this by implementing a modification of the Bresenham circle
drawing algorithm, which works by drawing a cirle of a given radius. The first
thing I did was modify it to draw ovals. So far, it worked pretty well. However
the next step was a little more difficult (in terms of algorithm simplicity
and speed). Since the Bresenham algorithm takes as input a radius, this means
that in QuickDraw terms, your bounding rectangle always had to be even. Modify-
ing Bresenham's algorithm to draw the equivalent of an oval in an odd sized
rectangle was more than I cared to do. However, if you wished to do so, I 
would recommend this method as an alternative to QuickDraw's.

------------------------------------------------------------------------------

Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions