[Cairo] gtk2 cairo engine

Carl Worth cworth at east.isi.edu
Mon Jul 28 16:18:19 PDT 2003


On Jul 28, jboulnois at neo-rousseaux.org wrote:
 > Hi,
 > I have done a sample gtk2 engine using cairo, 
 > For now it is in very early stage, but the result is promising. 
 > You can find it at 
 > http://www.neo-rousseaux.org/jboulnois/vector-engine_07282003.tar.gz
 > Please send feedback

Julien,

Great work! This looks quite interesting. Let me know if there are any
aspects of the Cairo API that make this task especially painful, (or
even especially pleasant).

One thing I noticed in the code:

	  cairo_t *xrs=cairo_create();
	  xrs=cairo_create();

That allocates two separate cairo_t structures (and leaks the first
one). You definitely don't want to do that.

Also, if you are interested, you might try rendering gradients with
Cairo. The OLS paper has an example that shows how you can achieve
linear gradients, (you'll have to change the XrNames to cairo_names of
course):

http://cairographics.org/xr_ols2003/html/xr_ols2003.html#fig:outline_source

The idea is to draw a small Nx1 image with one pixel per component of
the gradient, (eg. in the black->white->black gradients in the paper,
N=3). Then set a matrix to scale this image to the size of the object
to be filled and set it to use bilinear interpolation when
scaling. Apply the scaled image using cairo_set_pattern, then fill and
Voila! a lovely, smooth gradient.

Cheers,

-Carl




More information about the cairo mailing list