[cairo] Erasing A Line

Ivan Baldo ibaldo at adinet.com.uy
Wed Jun 27 17:09:15 PDT 2007


  Hello!

El 27/06/07 17:44, Allen escribió:
> Could someone possibly tell me how to erase a line once I've drawn it?  
>   
Do you use GTK?
What you can do in GTK is to create an expose event that refreshes the 
part where the line was before and the part where the line is now, so 
when you draw, the part where there is no line you draw a background and 
the part where there is a line you draw the background and the line.
In GTK every expose event (a redraw of some part or all the picture) is 
a new Cairo context, so for persistence you can have Cairo surfaces 
(created with cairo_surface_create_similar()) to draw background or 
persistent things and the dynamic things (that line that follows mouse) 
you draw them on the fly.

> I've tried to determine the "background" color of my Drawing area widget 
> - it's not white but WILL be a picture eventually - and the Cairo 
> context info does not show me how to get the background color before 
> drawing on it.
>   
So you may start to support that background, instead of asking Cairo to 
read its contents -> you manage its contents, so you have a background 
surface and draw things over it, to clear something, just redraw the 
part you want to clear.
You may think of it as different "layers".

> Thanks so much.  I really appreciate this.
>
>   
You are welcome!!!
Hope this helps, don't hesitate to ask again or bring more information!
Goodbye.

-- 
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 mailing list