[cairo] Calculating bounds

Eduardo Cavazos wayo.cavazos at gmail.com
Fri Jun 4 12:21:48 PDT 2010


Hello,

I recently mentioned that Ypsilon Scheme has bindings for Cairo. One of 
my projects using these is a ContextFreeArt inspired language embedded 
in Scheme. An example rendering:

     http://gist.github.com/425682

The implementation is actually a port of an older version of mine which 
rendered using OpenGL.

Anywho, in the Scheme example, you can see that I set the bounds of the 
coordinate system like so:

     (bounds -3 3 -2 4)

meaning the x bounds are [-3,3] and the y bounds are [-2,4]. In the 
actuall CFA implementation, you don't have to specify this; it's 
calculated automatically. So I'm wondering about how best to accomplish 
this with Cairo. It seems like I'd have to run through paths twice; once 
calculating the bounds using functions like cairo_fill_extents and 
cairo_user_to_device, and again to do the actual rendering after setting 
the correct user space coordinates. Does this sound like a good strategy?

The core part of the implementation is at:

     http://github.com/dharmatech/psilab/blob/master/cfdg/core.sls

Ed


More information about the cairo mailing list