| Liam Healy ( @ 2008-03-22 08:50:00 |
| Entry tags: | graphics, lisp |
Cairo for Lisp
I have been looking into using Cairo for various 2D drawing needs. A key advantage is the availability of a variety of output formats, including both screen and hardcopy. One potential application is traditional x-y scientific/engineering plots. Although there are many options for doing that, even using Lisp, I have a Lisp package I adapted many years ago for this purpose that now lacks a good back end for output. My thought is that Cairo would be good for that, as it is a standardized library, widely available, with many modern output formats. I also have other 2D output that I do from Lisp, which I now do with a thin postscript definition layer that I wrote. Switching to Cairo would give me some more flexibility.
I did some research and found that there were three sets of bindings for Cairo:
- cl-cairo
- cl-cairo2
- cffi-cairo
The first, cl-cairo, despite being linked from the cairographics web page, appeared to be dead. I found the author, Lars Nostdal, on #lisp who said the project was no longer active, so with his permission I modified the Cairo bindings page to mention cl-cairo2 and cffi-cairo and remove cl-cairo. cl-cario2, from Tamás K Papp, seems more active, but I had trouble getting it to run; I've posted my problems and am awaiting a response. Finally, I tried cffi-cairo from chriss. It did not compile, but it was easy to fix the problem: the CFFI interface has changed, defctype no longer has a :translate-p argument. With a slight modification, the example
(run-snippet-png '(:clip :clip-image)) ran and produces PNG files that looked correct.
It looks like I'll be using cffi-cairo.