Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!ncar!umigw!umbio.med.miami.edu!jherr From: jherr@umbio.med.miami.edu (Jack Herrington) Newsgroups: comp.sys.mac.programmer Subject: Re: Drawing Analog Clocks Summary: Use a unioned region Keywords: OpenRgn, CloseRgn, UnionRgn, CopyRgn Message-ID: <1990May3.145029.27051@umigw.miami.edu> Date: 3 May 90 14:50:29 GMT References: <550@fornax.UUCP> <1123@metaphor.Metaphor.COM> <1126@metaphor.Metaphor.COM> Sender: news@umigw.miami.edu (USENET News System) Distribution: na Organization: University of Miami Medical School, Department of Biomedical Computing Lines: 59 In article <1126@metaphor.Metaphor.COM> rimola@flamingo.metaphor.com (Carlos Rimola) writes: >In article <1123@metaphor.Metaphor.COM> rimola@flamingo.metaphor.com (Carlos Rimola) writes: >>There are two parts to these problem: 1) In the Mac environment, how do >>you preserve the previous contents of an arbitrary window area when you >>want to temporarily draw over it (are regions the only option?) and 2) >>What clever algorithms are there for implementing an analog clock. Draw the minutes and the hours as triangular regions, then union them into one region. Then paint that in XOR. You can't use alternating patterns. You could then do the seconds as a single XORed line. This will avoid offscreen BMAPs. And the most regions you would have would be 4. Something like this: { RgnHandle totalHands,hourHands,minuteHands,lastClock; totalHands = NewRgn(); hourHands = NewRgn(); minuteHands = NewRgn(); lastClock = NewRgn(); PenMode(patXor); PenPat(white); while(1) { if ( minutes or hours has changed ) { OpenRgn(); { Draw the hours } CloseRgn(hourHands); OpenRng(); { Draw the mintues } CloseRgn(minuteHands); UnionRgn(hourHands,minuteHands,totalHands); PaintRgn(lastClock); PaintRgn(totalHands); CopyRgn(totalHands,lastClock); } { Draw the seconds } } DisposeRgn(totalHands); DisposeRgn(hourHands); DisposeRgn(minuteHands); DisposeRgn(lastClock); } Damn, somebody should pay me for this. :-) -- "Aaaah, you gonna take me home tonight... Ahh, you gonna let it hang out, fat bottom girls, you make the rockin' world go 'round..." -Queen