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

View: New views
2 Messages — Rating Filter:   Alert me  

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

by alanb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everyone,
I am fairly new to using cairo, I understand the basic stuff but have a
question. What is the most efficient way of moving a line drawn from the
centre of a drawingarea to the current mouse position over a detailed
drawn background?  I am sure this is a basic question that many have
asked in the past and I have looked at the tutorial material but couldnt
see anything to help(probably looking in the wrong place).

I have written the code to draw the line but it involves continually
clearing the screen and re-drawing everything which is quite slow. In
the past I have used Xor drawing but understand this is not how its done
now.

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?

Thanks

Alan
_______________________________________________
cairo mailing list
cairo@...
http://lists.cairographics.org/mailman/listinfo/cairo

Re: Basic question about drawing a moving line over a detailed background in mono c# program

by M Joonas Pihlaja :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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,

Joonas
_______________________________________________
cairo mailing list
cairo@...
http://lists.cairographics.org/mailman/listinfo/cairo