Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!rutgers!apple!voder!blia!mao From: mao@blia.BLI.COM (Mike Olson) Newsgroups: comp.windows.x Subject: smooth motion in "animated" Xlib applications Keywords: GXxor, drawing, animation Message-ID: <5354@blia.BLI.COM> Date: 20 Sep 88 15:02:13 GMT Organization: Britton Lee, Los Gatos, CA Lines: 50 I've got an application that needs to "animate" a circle on the screen. The circle moves in response to user events, and i want it to do so smoothly. Right now, I have the following code fragment: Window w; GC gc; unsigned long vmask; XGCValues xgcv; w = XCreateWindow(...); vmask = ... | GCFunction; xgcv.function = GXxor; gc = XCreateGC(dpy, w, vmask &xcgv); ... if ( /* the circle should move */ ) { /* newx, newy are new coords, oldx, oldy old coords */ XArc circ[2]; /* values are cast as appropriate; that's omitted here */ circ[0].x = oldx; circ[0].y = oldy; circ[1].x = newx; circ[1].y = newy; circ[0].angle1 = circ[1].angle1 = 0; circ[0].angle2 = circ[1].angle2 = 360 * 64; circ[0].width = circ[0].height = 20; circ[1].width = circ[1].height = 20; XFillArcs(dpy, w, gc, &circ[0], 2); } This erases the old circle and draws in the new one, the way you'd expect. The problem is that there's a nasty flicker (Sun 3/60 running X11R2, no patches, SunOS 3.5); both FillArcs are done to the screen, and you can see the circle flicker if the old one overlaps the new. As a possible fix, I drew to a Pixmap in memory, and copied the pixmap into the window (with GXcopy) when i was done. This gets rid of the flicker, but is annoyingly slow (twice as many server requests, for one thing). Does anyone know of a better way to do this? I know that it won't work for color displays (yet); i can fix that later, but i'm trying to get a monochrome version running now. Email me if you have a solution, or if you want to see the responses I get. If there's sufficient interest, I will post a summary. Mike Olson Britton Lee, Inc. ...!ucbvax!mtxinu!blia!mao