Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!psuvax1!xavier!jackiw From: jackiw@cs.swarthmore.edu (Nick Jackiw) Newsgroups: comp.sys.mac.programmer Subject: Re: Drawing Analog Clocks Message-ID: Date: 2 May 90 14:56:22 GMT References: <550@fornax.UUCP> <1123@metaphor.Metaphor.COM> Sender: jeremy@xavier.swarthmore.edu (Jeremy Brest) Reply-To: jackiw@cs.swarthmore.edu (Nick Jackiw) Distribution: na Organization: Visual Geometry Project, Swarthmore College, PA Lines: 52 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. > 1) The easiest way is to use patXor mode when drawing your hands. Drawing the same thing twice with patXor will leave your background the way it was before drawing anything. (Draw once to display, once to 'erase'.) Unfortunately, this is also the cheesiest method, in that patXor won't draw your hands as solid black, but rather as some odd intersection of each hand with its neighbors and with the background. > BTW, for question 1, I know about off-screen bitmaps but have found > them to be inefficient when the number of on-screen windows that need > to be updates is high (e.g. 10 clock windows showing different times). > I find this hard to believe. Short of writing directly to the screen memory, nothing will be faster than copyBits if used correctly. If your bitmapped backgrounds exist offscreen, bit-aligned, at the appropriate color depth, and registered to unclipped areas of your windows, you can easily redraw the entire screen in under a second. The number of windows on the screen is moot--the number of pixels per screen is fixed. I posted code on bitmap alignment a while back; there are also technotes discussing technique. For the smoothest action possible, I'd recommend for each clock one static bitmap of the clock background one scratch bitmap your window All three should be aligned and at the same depth. Each time you need to reorient your hands, copy the background into the scratch bitmap, draw the hands (patCopy) into the scratch bitmap, and then copy the whole thing to the screen. Precomputing the endpoints of the hands, rather than using trigonometric functions while redrawing, will make things considerably more speedy. > Please respond via mail if possible.. -- ------------------------ Nick Jackiw jackiw@cs.swarthmore.edu "Every minute of the future Visual Geometry Project jackiw@swarthmr.bitnet is a memory of the past." Swarthmore College, PA 19081-1397 -Laivach