Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Imaging With QuickDraw /
Chapter 3 - QuickDraw Drawing / QuickDraw Drawing Reference
Routines / Creating and Managing Polygons


To begin defining a polygon, use the OpenPoly function.

FUNCTION OpenPoly:\xDD\xDDPolyHandle;
The OpenPoly function returns a handle to a new polygon and starts saving lines for processing as a polygon definition. While a polygon is open, all calls to the Line and LineTo procedures affect the outline of the polygon. Only the line endpoints affect the polygon definition; the pattern mode, pattern, and size do not affect it. The OpenPoly function calls the HidePen procedure, so no drawing occurs on the screen while the polygon is open (unless you call the ShowPen procedure just after calling OpenPoly, or you called ShowPen previously without balancing it by a call to HidePen).

A polygon should consist of a sequence of connected lines. The OpenPoly function stores the definition for a polygon in a Polygon record.

When a polygon is open, the current graphics port's polySave field contains a handle to information related to the polygon definition. If you want to temporarily disable the polygon definition, you can save the current value of this field, set the field to NIL, and later restore the saved value to resume the polygon definition.

Even though the onscreen presentation of a polygon is clipped, the definition of a polygon is not; you can define a polygon anywhere on the coordinate plane.

When you are finished calling the line-drawing routines that define your polygon, use the ClosePoly procedure, described next.

Do not call OpenPoly while a region or another polygon is already open.

Polygons are limited to 64 KB. You can determine the polygon size while it's being formed by calling the Memory Manager function GetHandleSize, which is described in Inside Macintosh: Memory.

The OpenPoly function may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.

Listing 3-10 on page 3-26 illustrates how to use this function to create a triangle. The Polygon record is described on page 3-33.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996