Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!brutus.cs.uiuc.edu!apple!claris!brendan From: brendan@claris.com (Brendan McCarthy) Newsgroups: comp.sys.mac.programmer Subject: Re: Animation Questions Keywords: CopyBits, VBlank Message-ID: <10611@claris.com> Date: 12 Oct 89 22:43:52 GMT References: <3123@crdgw1.crd.ge.com> Reply-To: brendan@claris.com (Brendan McCarthy) Organization: Claris Corporation, Santa Clara CA Lines: 54 >In Article 10142 in comp.sys.mac.programmer: >leue@galen.crd.ge.com (Bill Leue) writes: >First, the objects being animated are sometimes "sheared" horizontally, so >that they are torn into two pieces which don't quite track each other as the >object moves (say)horizontally. >I'm tenatively diagnosing this problem as a lack of synchronization with the >screen refresh. Am I right? Yes, you are right. There's a cheap way to synchronize with the VBL. It works well for pretty simple drawing tasks (like CopyBits). Here's a code fragment: VAR theTicks: LONGINT; BEGIN { your screen drawing routine } ... { sync with VBL task } theTicks := TickCount; REPEAT UNTIL theTicks <> TickCount; { do your drawing now } ... END; { your drawing routine } >Second, I am using "Classic" QuickDraw to perform limited color drawing. >I use ForeColor() and BackColor() calls along with a 50% grey pattern fill >to get a useful range of colors using dithering. In this way I can >get color objects on a color system, but don't have to make special code >for monochrome systems. It works fine, except that the objects which >are animated using CopyBits only display in black and white. Right. The reason you're getting black & white is that CopyBits only moves the bits (that's its name). Classic QD doesn't store colour information anywhere. It's part of the port's drawing mode. In order to get colour from CopyBits using old QD, you'll have to SetForeColor on the CopyBits call that draws from your offscreen bitmap to the screen. I'm assuming that you currently draw the different coloured portions of your image into one offscreen bitmap, and then CopyBits that to the screen. To get the effect you want, you'll need to create an offscreen bitmap for each colour of your image, and then do the ForeColor/CopyBits thing on to the screen. Brendan : CLARIS : ........:.................................................................... : : Brendan McCarthy : Software Architect : Planning Applications : UUCP: brendan@claris.com : InterNet: {ames,apple,portal,sun,voder}!claris!brendan :