Next: , Previous: Pango Interaction, Up: Top


27 Cairo Interaction

Functions to support using Cairo

27.1 Overview

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.

27.2 Usage

— Function: gdk-cairo-create (drawable <gdk-drawable>) ⇒  (ret cairo-t)

Creates a Cairo context for drawing to drawable.

drawable
a <gdk-drawable>
ret
A newly created Cairo context. Free with cairo-destroy when you are done drawing.

Since 2.8

— Function: gdk-cairo-set-source-color (cr cairo-t) (color <gdk-color>)

Sets the specified <gdk-color> as the source color of cr.

cr
a <cairo-t>
color
a <gdk-color>

Since 2.8

— Function: gdk-cairo-set-source-pixbuf (cr cairo-t) (pixbuf <gdk-pixbuf>) (pixbuf_x double) (pixbuf_y double)

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 <gdk-pixbuf>
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

— Function: gdk-cairo-set-source-pixmap (cr cairo-t) (pixmap <gdk-pixmap>) (pixmap_x double) (pixmap_y double)

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 <gdk-pixmap>
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

— Function: gdk-cairo-rectangle (cr cairo-t) (rectangle <gdk-rectangle>)

Adds the given rectangle to the current path of cr.

cr
a <cairo-t>
rectangle
a <gdk-rectangle>

Since 2.8

— Function: gdk-cairo-region (cr cairo-t) (region <gdk-region>)

Adds the given region to the current path of cr.

cr
a <cairo-t>
region
a <gdk-region>

Since 2.8