Examples

The following list shows some of the libraries and programs that are using cairo. Additions to this list are quite welcome.

Snippets with screenshots

Øyvind Kolås has put together a great little page of samples showing how to draw useful things with small snippets of code.

Cairocks is a small library of useful, common Cairo routines. Examples for using it with cairo-gl and SDL2 are also available. A cairocffi-based Python3 companion module named cairockscffi is also available.

Bezier gradients

Bezier gradients, also known as type 6/7 gradients in PS/PDF parlance, are incredibly power tools. Using a patchwise 2D cubic Bezier surface allows them to construct any of the lesser gradients such as linear, conical and radial, and the flexibility to do so much more. One example, Adrian Johnson gives is the ability to create realistic shading of a complex object:

Small demos

A simple pygtk clock and a pygtk shogiban using svg to pixbuf rendering providing a GUI for gnushogi. Xiangqiboard uses cairo via the Gtk2Hs Library for the Haskell programming language.

Mirco (MacSlow) Müller wrote a Cairo Clock that is a good example of how to use Cairo and librsvg in a real application.

Mike Hearn wrote a very simple demo of how to make partly transparent windows with GTK+ and Cairo, and MacSlow has written a more complete example that uses the new XShape extensions to make the transparent areas click-through.

MacSlow also provided a little demonstration of using cairo-drawn graphics as dynamic textures for OpenGL. You can check out that particular example with:

git clone git://people.freedesktop.org/~macslow/gl-cairo-cube

Juan Manuel Mouriz provided another simplest example of using cairo-drawn graphics as dynamic textures for OpenGL. You can check out with:

svn checkout http://gtk-gl-slider.googlecode.com/svn/ gtk-gl-slider-read-only

Further examples regarding cairo, glitz and OpenGL are described on the cairo and OpenGL page.

A pycairo example showing how to use librsvg on windows: cairo rsvg and python in windows

A small physics / blob simulator using Cairo and SDL for rendering: blobsallad

The Xlib page outlines using Cairo with just Xlib to make a simple GUI demo.

Animation

A multi-threaded animation tutorial with cairo and GTK+: threaded animation with cairo

A nice vector animated clock video

An explanation of animating graphics with easings

The getting started with graphics http://www.getlazarus.org/forums/viewtopic.php?f=18&t=35

anim_framework is a framework for generating geometrical animations using Python, including some examples

Cairo in motion is a small Cairo C__ in FLTK1 example of animation along spline paths.

Toolkits based on cairo

Charting

SVG

Other projects and programs

GTK Cairo canvas: plans, experiments, interest