I've created a potentially beautiful double buffered Canvas class that has less flicker than others I've tried however there is one major problem: I can't animate a canvas that has translucent masks like a shadow. I'm looking for a work around before I release the class into the wild.

Here's an example. Lets say you are animating a spinning beach ball with a shadow.

Steps:
1) Assign a circular mask with translucent shadow to a new picture in memory for buffering. 2) Copy State1 (a graphic) to the Buffer. (State1 is a beach ball surrounded by black. The mask turns part of the black into a shadow.)
3) Draw the Buffer to the screen
(so far so good.)
4) Clear the buffer. Copy State2 to the Buffer.
5) Draw the Buffer to the screen.

Ooops!  Here's where it goes wrong.

We are drawing State2 literally over top of the existing graphic. The beach ball itself looks fine because it is entirely replaced. However the translucent shadow is drawn over top of the existing shadow adding them together. Each step darkens the shadow until it's black. This is because we don't copy a square buffer to the screen. It smartly copies only the masked images as it should.

Hmmm... What if we erased the image first?
Well, we could erase the canvas and then copy the buffer but that creates flicker on Windows. We could mess with Refresh but that gives the same result. Erasing the buffer first doesn't help because in the end we always copy a masked buffer to the Canvas. (You can't mask the canvas directly.)

Joe Strout gets away with this successfully in his famous Three Ways to Animate http://www.rblibrary.com/index.php?main_page=product_info&products_id=7 because he is animating over a known fixed background of stars and copies the masked rocket ship into a non masked buffer that already contains the fixed starry background. The non masked, rectangular buffer then gets copied to the Canvas. Alas, this won't work if you don't know what might be behind your canvas.

I seem to be a dead end and can only conclude it's not possible in RB to do flicker-free canvas based animations with translucency against an arbitrary background. I'd love to be proven wrong and welcome any suggestions.

Cheers!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to