[cairo] Cairo in 3 Dimensions

Øyvind Kolås oeyvindk at hig.no
Sat Apr 8 18:59:39 PDT 2006

* Bill Spitzak <spitzak at d2.com> [060408 20:41]:
> Esben Stien wrote:
> > Any plans to add a 3'rd dimension to cairo?
> I feel the only "vital" missing element is the ability to provide a 
> perspective transformation to the source surface. This would change the 
> current 3x2 matrix into a 3x3 one. Notice that it is not a 4x4 matrix, 
> it does not input or output z information. With this addition a Cairo 
> program would be physically capable of producing a texture-mapped 3d scene.

PostScript is extendable to 3d by through postscript [1]. In the same
manner taht LaTeX gives a lot of power to TeX, there will arise reusable
drawing functions for cairo. Abstractions on top of cairo can be written
in any of the supporting scripting languages (or extending the existing
cairo core from C).

The main lacking feature when adding 3d as an abstraction on top of
cairo would probably be perspective transforms of fills with patterns
that have raster sources. This can probably be approximated through
subidvision but I guess clipping issues would make this complex,
unelegant and most probably slow.

The vector/path portion of the cairo API is built on bezier splines
which are invariant to affine transformation. Perspective
transformations are not affine and thus need (piece-wize linear?)
approximation through the perspective transform. A stroke could be
approximated through a transform done on the path of the stroke
(possible to implement on top of the introspection of the current path.)
Another way of approximating a stroke is probably thorugh variable
line-width (not existing in current cairo-API, but probably also
possible as an abstraction on top of the existing API.)

/Øyvind Kolås

1: http://www.sunsite.ubc.ca/DigitalMathArchive/Graphics/text/www/
«The future is already here. It's just not very evenly distributed»
                                                 -- William Gibson
http://pippin.gimp.org/                            http://ffii.org/

More information about the cairo mailing list