Path: utzoo!attcan!uunet!husc6!mailrus!uwmcsd1!ig!agate!twinkies!lippin From: lippin@twinkies.berkeley.edu (The Apathist) Newsgroups: comp.sys.mac.programmer Subject: Re: flicker-free drawing Message-ID: <12549@agate.BERKELEY.EDU> Date: 26 Jul 88 01:47:00 GMT References: <5727@orstcs.CS.ORST.EDU> Sender: usenet@agate.BERKELEY.EDU Reply-To: lippin@math.berkeley.edu Organization: Authorized Service, Incorporated Lines: 45 Recently jasmerb@orstcs.CS.ORST.EDU (Bryce Jasmer) said: >I am writing a DA that needs to have flicker free drawing so I found >and decided to use Scott Knaster's trick of letting the Tickcount change >before drawing. Here is the code: >----- >aLong:=tickcount; >while aLong = tickcount do > ; >EraseRect( {about 50 x 10 pixels} ); >DrawString( {about 10-12 characters (9 point)} ); >----- >It works great while the small window is at the bottom of my screen but >flickers more and more the closer you move the window to the top of the >screen. A better way to avoid flicker is to skip the erasing that causes it, like this: TextMode(srcCopy); DrawString(whatever); EraseRgn(area outside the string); If you're replacing old text, you can do an EraseRect, using a procedure like this: void clearto(endofline) int endofline; { FontInfo info; Rect r; Point pen; GetFontInfo(&info); GetPen(&pen); SetRect(&r,pen.h,pen.v-info.ascent,endofline,pen.v+info.descent); EraseRect(&r); } The only hitch is that srcCopy for text doesn't exist for the most ancient hardware/system software combinations. --Tom Lippincott ..ucbvax!bosco!lippin "It's a multi-purpose shape: a box." --David Byrne