## Cairo Interaction

Cairo Interaction — Functions to support using Cairo

## Synopsis

    #include <gdk/gdk.h>

    cairo_t*    gdk_cairo_create                (GdkDrawable *drawable);
    void        gdk_cairo_set_source_color      (cairo_t *cr,
                                                 GdkColor *color);
    void        gdk_cairo_set_source_pixbuf     (cairo_t *cr,
                                                 GdkPixbuf *pixbuf,
                                                 double pixbuf_x,
                                                 double pixbuf_y);
    void        gdk_cairo_set_source_pixmap     (cairo_t *cr,
                                                 GdkPixmap *pixmap,
                                                 double pixmap_x,
                                                 double pixmap_y);
    void        gdk_cairo_rectangle             (cairo_t *cr,
                                                 GdkRectangle *rectangle);
    void        gdk_cairo_region                (cairo_t *cr,
                                                 GdkRegion *region);

## Description

Cairo is a graphics library that supports vector graphics and image compositing that can be used with GDK. Since 2.8, GTK+ does most of its drawing using Cairo.

GDK does not wrap the Cairo API, instead it allows to create Cairo contexts which can be used to draw on GDK drawables. Additional functions allow to convert GDK's rectangles and regions into Cairo paths and to use pixbufs as sources for drawing operations.

## Details

### gdk_cairo_create ()

    cairo_t*    gdk_cairo_create                (GdkDrawable *drawable);

Creates a Cairo context for drawing to `drawable`.

`drawable` : | a GdkDrawable
Returns : | A newly created Cairo context. Free with `cairo_destroy()` when you are done drawing.

Since 2.8

### gdk_cairo_set_source_color ()

    void        gdk_cairo_set_source_color      (cairo_t *cr,
                                                 GdkColor *color);

Sets the specified GdkColor as the source color of `cr`.

`cr` : | a cairo_t
`color` : | a GdkColor

Since 2.8

### gdk_cairo_set_source_pixbuf ()

    void        gdk_cairo_set_source_pixbuf     (cairo_t *cr,
                                                 GdkPixbuf *pixbuf,
                                                 double pixbuf_x,
                                                 double pixbuf_y);

Sets the given pixbuf as the source pattern for the Cairo context. The pattern has an extend mode of `CAIRO_EXTEND_NONE` and is aligned so that the origin of `pixbuf` is `pixbuf_x`, `pixbuf_y`

`cr` : | a Cairo context
`pixbuf` : | a GdkPixbuf
`pixbuf_x` : | X coordinate of location to place upper left corner of `pixbuf`
`pixbuf_y` : | Y coordinate of location to place upper left corner of `pixbuf`

Since 2.8

### gdk_cairo_set_source_pixmap ()

    void        gdk_cairo_set_source_pixmap     (cairo_t *cr,
                                                 GdkPixmap *pixmap,
                                                 double pixmap_x,
                                                 double pixmap_y);

Sets the given pixmap as the source pattern for the Cairo context. The pattern has an extend mode of `CAIRO_EXTEND_NONE` and is aligned so that the origin of `pixbuf` is `pixbuf_x`, `pixbuf_y`

`cr` : | a Cairo context
`pixmap` : | a GdkPixmap
`pixmap_x` : | X coordinate of location to place upper left corner of `pixmap`
`pixmap_y` : | Y coordinate of location to place upper left corner of `pixmap`

Since 2.10

### gdk_cairo_rectangle ()

    void        gdk_cairo_rectangle             (cairo_t *cr,
                                                 GdkRectangle *rectangle);

Adds the given rectangle to the current path of `cr`.

`cr` : | a cairo_t
`rectangle` : | a GdkRectangle

Since 2.8

### gdk_cairo_region ()

    void        gdk_cairo_region                (cairo_t *cr,
                                                 GdkRegion *region);

Adds the given region to the current path of `cr`.

`cr` : | a cairo_t
`region` : | a GdkRegion

Since 2.8