Skip to content

Cairo package

Birch language wrapper for the Cairo 2d graphics library. Currently provides a limited subset of the functionality of the library.


Birch is open source software.

It is licensed under the Apache License, Version 2.0 (the "License"); you may not use it except in compliance with the License. You may obtain a copy of the License at



To build and install, use:

birch build
birch install


To use from another Birch package, first add Cairo to the require.package item in its META.json. This will add checks for package files during the build.

Basic usage then looks something like this:

surface:Surface <- createPNG(file, width, height);
cr:Context <- create(surface);

/* paint a black background */
cr.setSourceRGB(0.0, 0.0, 0.0);

/* draw a white rectangle */
cr.setSourceRGB(1.0, 1.0, 1.0);
cr.rectangle(0.25*width, 0.25*height, 0.5*width, 0.5*height);

/* clean up */

Usage idioms are mostly preserved from Cairo itself. See the Cairo documentation for more details, and the package documentation (or code) for the subset of functionality provided.