Re: Fast ways to draw brush outlines on a DrawingArea



On Sun, 2007-09-30 at 10:56 +0100, Keith Feesh wrote:
Hello, I have been developing a drawing application for quite some time now
Interesting, which one? :-)

[...]

The way that I do things now includes redrawing the entire canvas every time
the mouse is moved, in order to clear the old
outline's drawing, and then to redraw the outline once again. 

A likely first optimization is to find the minimum bounding box of the
brush, remember where you last drew it, and redraw only that region.
You may also need to do this when the drawing window gets obscured
by another window and then exposed again, depending on platform and
hardware.

A second is that before you draw the brush, you save what's underneath,
on a hidden canvas, and copy that back afterwards.

I think someone also mentioned the problem with this approach -- it
would cause visible flicker as the brush outline was drawn, undrawn,
drawn again repeatedly -- so you end up with double buffering,
requiring an off-screen canvas large enough to hold as much of
the drawing as contains both the drawing under the old brush position
and the drawing under the new position.

If you are working on a CAD-style vector-based program it may seem
alien to store the rendered pixels, but it's what is generally
needed.

Some CAD systems can also use a video overlay layer, if the video
card on the computer supports it, but then you're getting into
pretty arcane hardware stuff :(

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://www.fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]