[cairo] How can I find out the current color when I call cairo_fill?

Behdad Esfahbod behdad at behdad.org
Fri Jan 4 00:39:09 PST 2008

On Fri, 2008-01-04 at 03:14 -0500, ying lcs wrote:
> Hi,
> Can you please tell me if there is any function in cairo which allow me to find
> out what is the color (rbg), when i call
> cairo_rectangle(...);
> cairo_fill(...);
> I see there is a method cairo_set_source_rgb(), but I don't see a corresponding
> getter?

First do cairo_get_source(), followed by cairo_pattern_get_rgba().  If
the latter returns an error, the source is not a solid color (a
gradient, surface, etc).

> Thank you for any pointers.


"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759

More information about the cairo mailing list