OpenPoly
OpenPoly
Start recording a polygon definition OpenPoly allocates and initializes an empty Polygon structure. It hides the pen. The endpoints of subsequent Line and LineTo operations are recorded into the polygon's data structure until you stop the recording via ClosePoly. Returns: a PolyHandle; a handle to a variable-length Polygon structure that is allocated and initialized by this call. The polySize field is set to 10 and the polyBBox field is set to the empty rectangle (0,0)(0,0).
Notes: This call begins accumulating the definition of a polygon by recording the
endpoints of the line segments drawn with Line and LineTo. Upon stopping recording (see ClosePoly), the polygon should be a series of connected lines:
Unlike OpenRgn, this call allocates the handle and data structure for you. However, many other features are similar:
• The pen is hidden (unless a previous call to ShowPen has not been balanced) and you can use ShowPen after opening the picture if you want to see the pen while drawing.
• To temporarily interrupt polygon-definition recording, you can switch to
polySave, and set it to NIL. Restore the saved value to resume recording.
Polygons are limited to 32K bytes (8192 vertices). Use GetHandleSize to track the size of an open polygon as it grows. After the polygon is closed,
you can read its size directly by accessing the polySize field of the Polygon structure.
The following example creates a triangular polygon, fills it, then discards
it.
Example
#include <Quickdraw.h>
PolyHandle thePoly;
thePoly = OpenPoly( ); „/* start recording */ MoveTo( 100,100 ); „/* start and end point */ LineTo( 50,200 ); „/* left side */ LineTo(150,200 ); „/* bottom */ LineTo(100,100 ); „/* right side */ FillPoly( thePoly, black ); /* fill inside */ KillPoly( thePoly ); „/* deallocate all memory used here */