Pycairo is set of Python bindings for the cairo graphics library.
Cairo is a software library used to provide a vector graphics�based, device-independent API for software developers. It is designed to provide primitives for 2-dimensional drawing across a number of different backends. Cairo is designed to use hardware acceleration when available.
Although written in C, there are bindings for using the cairo graphics library from many other programming languages, including Haskell, Java, Perl, Scheme, Smalltalk and several others. Dual licensed under the GNU Lesser General Public License and the Mozilla Public License, cairo is free software.
This simple example draws a blue triangle into a png file.
WIDTH, HEIGHT = 400, 400
# Setup Cairo
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT)
ctx = cairo.Context(surface)
# Set thickness of brush
# Draw out the triangle using absolute coordinates
# Apply the ink
# Output a PNG file