subpixel
Re: Overwriting text that has motion OR Clearing State
Reply #3 - Apr 24th , 2009, 7:12pm
Clearing the entire display using background(0) is fast and not worth worrying about. This is great for a simple object (in your case some text) on a solid background. If you're worried about what to do when you have a complicated background, consider this: The display is like a mosaic. When you change the image (display text, lines, circles, whatever), you are removing the existing mosaic tiles and replacing them with new ones. If you want to go back to what was there before, you need to either start over, or remember just the ones you changed and change them back. If you have a complicated background that takes time to compute, but once computed doesn't change (eg if you had a fractal in the background that didn't zoom or anything), you can save a copy of the image and blast that onto the screen for each frame (instead of painting black, for instance). The only other option is to do the calculations again. The "undo" operation in most types of program (graphical or otherwise) requires memory to be reserved for the thing (eg picture) you are changing. That's just the way things are. Having said that, your idea to draw an image over the place where the text was is a good notion - if you had a complex image in the background (such as the fractal example), redrawing only the part that needed to be redrawn is a good optimisation. How you manage that is, of course a different matter. Saving the entire image and selectively redrawing just part of it is one option, and will generally be faster. One thing you might like to try is drawing a black rectangle at less than 100% opacity. The result will give you a sort of trail after text. -spxl