[cairo] Erasing A Line
ibaldo at adinet.com.uy
Thu Jun 28 19:37:51 PDT 2007
El 28/06/07 10:18, Allen escribió:
> Hi Ivan,
> Thanks for the hints. & yes, I use Gtkmm. I was thinking of "layers"
> or "surfaces" but being so new I don't really know how to use the
> effectively. I'm checkout the "examples" right now.
> But it sounds like, from what you have said, that I use 1 surface for
> the Background (bg) image, and the "apply" another surface for drawing
> on, which would need to be "clear" or really transparent. Then I draw
> on the transparency.
> Is this correct?
But if you have a background image, then almost certainly you will
end having a Cairo Surface for it, so what you do after the user moves
the mouse is this:
- generate an expose event for the area occupied by the old line
and the new line, 2 calls to gtk_widget_queue_draw_area (it will join
both rectangles and generate only 1 expose event).
- on the expose event of the DrawingArea or Image you draw with
Cairo, first clip with gdk_cairo_region(cr, event->region);
cairo_clip(cr), then draw first the background image, then the line at
the place where the mouse is pointing.
You really don't need transparency or real layers, just draw things
in the correct order.
Though beware: I consider myself a Cairo newbie still, maybe someone
can enlighten us with a more clever approach?
Hey, maybe you want to take a look at some canvas library, for
example GooCanvas, you may find that using them things become more
simpler or clear.
Ivan Baldo - ibaldo at adinet.com.uy - http://ibaldo.codigolibre.net/
ICQ 10215364 - Phone/FAX (598) (2) 613 3223.
Caldas 1781, Malvin, Montevideo, Uruguay, South America.
We believe that we are free, but in reality we are not! Are we?
Alternatives: ibaldo at codigolibre.net - http://go.to/ibaldo
More information about the cairo