The cairo graphics library is an interesting toolkit, used by many well-known products, including GTK+, Mono, Poppler, Mozilla Firefox, WebKit, R, Gnuplot and others.
It supports graphics output to many targets, including the X Window System (Unix and other platforms), Win32, Mac OS X Quartz, PDF, PostScript, PNG and SVG.
Though written in C, it has bindings for many programming languages, including C++ , Factor, Haskell , Lua , Perl , Python , Ruby, Scheme , Smalltalk and others.
Pycairo is the Python binding to cairographics.
According to Wikipedia (see above), one of the founders of the cairo library was Keith Packard, who was also one of the key developers of X-Windows:
It was interesting to read that, because I had attended a training program on X, XLib, Xt and Motif, at the company where I worked, years ago; this was before X became widely available on Linux desktop computers; we used HP workstations during the course. I remember having a lot of fun during that course, along with the other participants. We kidded each other and the instructor a lot. Who can forget "DC the DC; Window theWindow", etc. :)
(DC being Device Context). Those were C / XLib declarations, from an X book used for the course, which might have been by Packard (or Gettys, IIRC).
I also remember a colleague of mine, creating a rudimentary version of a graphical paint program, like MS Paint, in Motif, during the Motif part of the course, in under an hour or so. That was probably my first introduction to the power of frameworks, and to the concept of callbacks (in C). I don't think I really grokked them at the time, though I did, later.
I had come across cairo some time ago, and made a note of it, because of its support for PDF output, an area I'm interested in, and also because of its Python support.
I saw it again today via the page below on preshing.com (which is the same site where I saw the info for my recent post on Mandelbrot graphics and Python):
The above page gives a nice example of the use of Python's with statement, in the context of using PyCairo to draw some rectangles, each rotated by some angle from the previous one, without the transformations being additive (in a sense - see the post for details).
- Vasudev Ram