Path: news.uiowa.edu!news.physics.uiowa.edu!math.ohio-state.edu!howland.reston.ans.net!newsfeed.internetmci.com!news.msfc.nasa.gov!sgigate.sgi.com!enews.sgi.com!decwrl!waikato!comp.vuw.ac.nz!asgard.actrix.gen.nz!atlantis.actrix.gen.nz!not-for-mail From: dempson@atlantis.actrix.gen.nz (David Empson) Newsgroups: comp.sys.apple2.programmer Subject: Re: Polygons in Quickdraw? Date: 22 Apr 1996 00:12:39 +1200 Organization: Actrix - Internet Services Lines: 74 Message-ID: <4ld8nn$ra9@atlantis.atlantis.actrix.gen.nz> References: <4kj0jb$4pa@styx.uwa.edu.au> <4klv08$ok4@styx.uwa.edu.au> <4l84st$hml@styx.uwa.edu.au> NNTP-Posting-Host: atlantis.actrix.gen.nz In article <4l84st$hml@styx.uwa.edu.au>, Joseph Turner wrote: > [snip] > I am wondering how you actually _get_ the handle that a function gives you > when you call a function such as OpenPoly();. OpenPoly internally calls NewHandle, and returns the handle to you. The contents of the handle are updated automatically as you draw the lines that make up the polygon. > Also how would I actually refer to this definition of the shape once > it is defined? I assume you just put in the handle in the brackets. Correct. Something like this (ignoring details such as error handling). Handle SetupMyPoly(void) { Handle thePoly; /* You might need to hide the pen here */ thePoly = OpenPoly(); MoveTo(100, 100); LineTo(200, 100); LineTo(200, 200); LineTo(100, 200); LineTo(100, 100); ClosePoly(); /* You might need to show the pen here */ return thePoly; } void DrawIt(void) { Handle myPoly; int i; myPoly = SetupMyPoly(); for (i = 100; i < 200; i += 10) { MoveTo(i, i); FramePoly(myPoly); } KillPoly(myPoly); } > And that would mean that you have to define this handle as a Global > variable at the beginning ...right? Assuming you wanted to keep it around for a while without to pass it in and out of functions, yes. You could also use a local (auto) variable, as in my example above. > Really want I would appreciate is a little code that could get me > started(Little). #include #include #include /* insert above functions here */ int main(void) { startgraph(640); SetPenSize(2, 1); DrawIt(); getchar(); endgraph(); return 0; } Press RETURN to terminate the program. -- David Empson dempson@actrix.gen.nz Snail mail: P.O. Box 27-103, Wellington, New Zealand