[comp.sys.mac.programmer] QuickDraw implementation

pepke@loligo.cc.fsu.edu (Eric Pepke) (08/09/89)

This is kind of far from the subject of the original question, but it is
kind of an interesting subject.  Everything about the way I think QuickDraw
does it is educated speculation, and I have no connection whatever with
anybody who knows for sure.  

I have been able almost exactly to duplicate the polygon fill in QuickDraw
by using a straight Bresenham approach with a half pixel offset.  It has
the same nice property of the QuickDraw routines in that adjacent polygons
will never overlap and never leave holes.  My algorithm seems to disagree
with QuickDraw on the occasional pixel, but the results are substantially 
the same (actually, I think that mine behaves better for some cases).  I 
think that they use the same algorithm to do lines by pretending that each
line is really a polygon with six sides.  This allows them to do rectangular
pens easily, but it is really bad for some cases.  (Try a Line(2, 5) to
see one of the worst.)

It is relatively easy to extend the concept of a filled polygon to the
concept of a filled curve, where the edges can be straight or curved lines,
and use substantially the same scan conversion process, using Bresenham
approaches for both straight and curved boundaries.  (You can also do 
regions this way, althought the method that QuickDraw uses is different and
has some disadvantages.  I did a graphics package with regions like this on
an ancient Zenith Z-100, and it was pretty zippy.)

So, I would guess that the arc drawing algorithm creates a closed curve with
two straight edges and two elliptical ones and then scan converts top to 
bottom, left to right, using half-pixel offset Bresenham runners on the
edges.  This would provide the observed behavior regarding the pen size,
and it would also explain the missing pixels in skinny ovals.

Eric Pepke                                     INTERNET: pepke@gw.scri.fsu.edu
Supercomputer Computations Research Institute  MFENET:   pepke@fsu
Florida State University                       SPAN:     scri::pepke
Tallahassee, FL 32306-4052                     BITNET:   pepke@fsu

Disclaimer: My employers seldom even LISTEN to my opinions.
Meta-disclaimer: Any society that needs disclaimers has too many lawyers.