[cairo] Drawing selected data?
Ian Britten
britten at caris.com
Fri Jan 23 09:31:57 PST 2009
Hi all,
[ Sorry for the length, but I hope to prevent needless questions... ]
Background:
I'm using Cairo to export data to various file formats, and need to
match what was rendered on-screen (via our current non-Cairo stuff).
Topic:
When the user selects a polygon on-screen, it is drawn as transparent
in a selection colour (eg: Red), on top of all the other data. Note
that there may be other data on top of the polygon (text, lines),
and the selection is drawn on top of all that. I need my exported
drawing to show this selection too.
Current on-screen (non-Cairo) approach:
When the selected polygon is rendered, it is also drawn to a
separate 1-bit offscreen bitmap, in addition to the background
bitmap. (The polygon knows it's selected) When finally painting
the window, the selection bitmap is simply painted (with an alpha
and a colour) after first drawing the background bitmap.
I'm currently wondering how to best achieve this with Cairo.
For example, as a start, I could simply carry around a second
surface. However, this would mean that in all my code, everything
that I'm currently doing, I would need to do twice, wouldn't it?
Twice the configuration setups, twice the path definitions, etc.
That seems like a lot of extra code (Esp since I actually need 2-3
of these extra surfaces, but I'm just keeping my example simple...)
Question:
Is there any [easy] way to copy/duplicate a sequence of calls
done on one surface to another surface? Note that I'm not looking
to simply copy one region of a surface to another, but instead am
looking to redo (re-render) a polygon onto a second surface (All
the pen/brush attributes, path, fill/stroke, etc).
If not, I guess I can just make all the calls on my second (and
third, etc) surfaces. Or maybe there's another way?
Question:
If I have a second surface containing the polygon (Which I assume
would be full-colour), is there a way I can render that on the
first surface such that it behaves as if it was 1-bit data, using
a single (different) colour and an alpha?
I'm guessing yes, since Cairo has lots of clever/cool stuff - I'm
just not familiar with it all... :P
Many thanks for any info/guidance/suggestions!
Ian
More information about the cairo
mailing list