[cairo] Path Gradients

Milan Marusinec milan at marusinec.sk
Tue Jan 22 18:19:53 PST 2008


Hello Bobby,

> However, there is one situation (that is my main interest in the path gradient) that I cannot figure out how to map to these "Type 6" gradient meshes. This situation is where you have a path, and you want to make a gradient from an abitrary "center point" out to the edges, with color stops along the way. Can you think of an easy way to use a "Type 6" gradient mesh to reproduce the gradients seen in these images:
> 
> http://www.bobpowell.net/pgb.ht4.jpg
> http://www.bobpowell.net/pgb.ht6.jpg
> 

I think, I have recently implemented the thing you want.
Have a look at:

http://www.aggpas.org/aggpas-demo.htm#ContourGradient

It is done for different library than cairo and it is
in Pascal, but the alghorithm (which could be ported
to cairo) is there and it's licence allows you to do so.

Basically, the whole thing is about firstly computing
the so called Distance Transform (DT) from any arbitrary
shape, which then further serves as a source of color
transition levels. It's also pretty fast. You can also
download a compiled executable demo and play with it a little.

Cheers
Milano



More information about the cairo mailing list