Liam Healy ([info]lhealy) wrote,
@ 2008-03-22 08:50:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
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:


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.




(Post a new comment)

cl-cairo
(Anonymous)
2008-03-23 05:07 am UTC (link)
i've been using cl-cairo which is very un-lispy and incomplete, so i had to fork my own private version of it. i am very happy to see that with cl-cairo2 an alternative has emerged and i will give it a try. thank you :)

(Reply to this)

fixes to cl-cairo2
(Anonymous)
2008-03-23 11:04 pm UTC (link)
Hi,

I uploaded a new version, and hope this fixes the errors. If not, please let me know.

I started cl-cairo2 because I could not get cl-cairo to work, and since I use it for graphing, I intend to maintain it. Comments, bug reports and suggestions are always appreciated.

Tamas Papp

(Reply to this)


(Anonymous)
2008-03-24 04:10 pm UTC (link)
McClim has some bindings for cairo in the gtkairo backend

(Reply to this) (Thread)

McClim
[info]lhealy
2008-03-29 02:59 pm UTC (link)
I've seen this. I've had a great deal of trouble getting mcclim running and keeping it running on the various computers I use, and I've had more trouble (i.e. never successful) with gtkairo. Ideally, I'd always work through CLIM but I don't think that mcclim is there yet, though there is progress.

(Reply to this) (Parent)

cffi-cairo
(Anonymous)
2008-03-24 11:04 pm UTC (link)
I did the cffi-cairo bindings. However, I did not have a need for them after that, so I did no further work on them. But if you find any problems, feel free to mail me at chriss at muon dot de.
Hopefully, I will find some time in the near future to put up the darcs repository on my new server.

(Reply to this) (Thread)

Re: cffi-cairo
[info]lhealy
2008-03-29 03:03 pm UTC (link)
OK, thanks. If you notice the other comments Tamas has updated his cl-cairo2, so I will take a look when I get back to Cairo. It probably makes sense to focus bug fixes on one version, but I don't know which one that is at the moment.

(Reply to this) (Parent)(Thread)

Re: cffi-cairo
(Anonymous)
2008-03-30 09:07 pm UTC (link)
BTW: cffi-cairo uses a totally different approach than cl-cairo2.

The documentation of cffi still has the translate-p argument in defctype. I do not have any problems here with sbcl 1.0.6. Maybe you can tell me the lisp and the cffi version you used?

(Reply to this) (Parent)(Thread)

Re: cffi-cairo
[info]lhealy
2008-03-30 09:20 pm UTC (link)
OK. I haven't looked at the different approaches and how they run; my intent was to figure out which would be the best for my purposes.

I am using SBCL and the latest (not current) version of CFFI. The darcs tree or the tarballs have the latest versions, and the documentation will be correct for those versions. The "current" version is now about a year old, and I've been using the latest version for a while.

(Reply to this) (Parent)


Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…