/* Sample Macintosh C program: put up a window, draw a nested set of rectangles, exit when the mouse button goes down */ #include "WindowMgr.h" #include "EventMgr.h" #include "QuickDraw.h" main() { int xA, yA, xB, yB, xC, yC, xD, yD, xxA, yyA, xxB, yyB, xxC, yyC, xxD, yyD; float p, q; int i; WindowPtr myWindow; EventRecord myEvent; static Rect bounds = { 10, 10, 400, 400 }; InitGraf(&thePort); InitFonts(); InitWindows(); InitCursor(); myWindow = NewWindow(0, &bounds, "\pSample Window", 1, 0, -1, 1, 0); p = 0.95; q = 1.0 - p; xA = 25; yA = 25; xB = 300; yB = 300; xC = 300; yC = 300; xD = 25; yD = 300; for (i = 0; i < 50; i++) { MoveTo(xA, yA); LineTo(xB, yB); LineTo(xC, yC); LineTo(xD, yD); LineTo(xA, yA); xxA = p * xA + q * xB; yyA = p * yA + q * yB; xxB = p * xB + q * xC; yyB = p * yB + q * yC; xxC = p * xC + q * xD; yyC = p * yC + q * yD; xxD = p * xD + q * xA; yyD = p * yD + q * yA; xA = xxA; xB = xxB; xC = xxC; xD = xxD; yA = yyA; yB = yyB; yC = yyC; yD = yyD; } MoveTo(25, 350); DrawString("\pPunch the mouse to exit . . ."); for (;;) { GetNextEvent(everyEvent, &myEvent); if (myEvent.what == mouseDown) return; } }