Examples

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

Collected Demos

A git repository of contributed examples is available on gitlab. These cover PS, X11, sdl, quartz, gtk, and more.

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.

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

Cairo support is integrated into the GTK+ widget toolkit as of version 2.8.

Cairo is one among many GNUstep display backends.

Cairo has been used as the basis for the System.Drawing and System.Windows.Forms (a.k.a. Managed.Windows.Forms) namespaces in Mono's class library since the early creation of Cairo.

The SWT widget toolkit wraps cairo for its advanced graphics API on Linux as of version 3.1.

Papyrus is a 2D canvas (scenegraph) library which renders using cairomm (and thus cairo). A companion library, papyrusgtk, provides a set of gtkmm widgets that use a papyrus/cairomm/cairo stack for drawing.

Ada industrial control widget library for designing high-quality instrument dashboards is based on cairo.

Charting

Matplotlib is a 2D graph plotting library for Python. It supports a cairo backend.

pyCairoChart (link dead?) is a 2D chart module for python which provides several options to create charts in an easy way, author is bettercom aka Martin Lesser.

Goffice is a library including a 2D graph component with a cairo based backend. This library is used by Gnumeric and Gnucash.

gnuplot is a 2D and 3D graph plotting utility. Since gnuplot 4.2, it has had an interactive terminal written with the wxWidgets library, and this terminal renders the plot with cairo. Mainstream CVS of gnuplot also outputs to pdf with cairo.

PLplot is a 2D and 3D plotting library with several cairo device drivers. Currently these include xwindows, ps, pdf and png.

slope, a C charting library

SVG

librsvg is a SVG rendering library supporting a large subset of SVG 1.1.

Mozilla is using cairo to render SVG content as of Firefox 1.5 and 2.0. As of Firefox 3.0 it uses cairo for rendering all content and UI.

Network Improv wrote an SVG Scene/Canvas Library which renders using cairo.

Other projects and programs

Michael Meeks has done some experiments with making OpenOffice.org render using cairo. Here is his original announcement (link broken?) including screenshots.

There's now a Cairo-based backend for the OpenOffice.org slideshow component (and a prototype for Windows).

Longer-term, the whole OOo stack will be ported to a UNO-based rendering engine (that will transparently support Cairo - screenshots here).

Roadster, cairo-based mapping program

CairoPad, written in Lua, to study Cairo

Smrender, A Rule-based Renderer for OSM Data

GTK Cairo canvas: plans, experiments, interest