[cairo] Basic question about drawing a moving line over a detailed background in mono c# program

M Joonas Pihlaja jpihlaja at cc.helsinki.fi
Mon Nov 9 11:20:00 PST 2009

Hi Alan,

On Fri, 6 Nov 2009, Alan Battersby wrote:

> I have written the code to draw the line but it involves continually
> clearing the screen and re-drawing everything which is quite slow. 

I believe this is usually the way it's done.  Of course you may be 
able to cache some of the drawing in your app into intermediate 
surfaces, so that'd be the first thing to do.

> So how can I save the background drawing whilst the mouse is moving?
> Should it be to an image or is there some in memory structure I can use?

You should have the detailed background in a surface similar to the 
actual target surface you're drawing onto.  These are surfaces which 
are as compatible as possible with the target for fast copying and can 
be created using cairo_surface_create_similar().  Then you'd copy the 
background from the similar surface to the real target surface before 
drawing your line on top of that.

Hope that helps,


More information about the cairo mailing list