[cairo] Path Gradients

Adrian Johnson ajohnson at redneon.com
Tue Jan 22 14:14:04 PST 2008


Bobby Salazar wrote:

> 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

That type of gradient could be approximated by flattening the path then
creating triangle gradients from the center point to each line on the path.

With the Type 6 coon mesh you could make one side of the coon patch zero
length and two other sides a straight line so you get a sort of triangle
with one side a Bézier curve. Then you do not need to flatten the path.

There is an Adobe tech note [1] where they show how to create a conical
gradient using four coons patches. The conical gradient is just a
special case of the path gradient where the path is a circle . Circles
are approximated with four Bézier curves.


[1]
http://partners.adobe.com/public/developer/en/ps/sdk/TN5600.SmoothShading.pdf



More information about the cairo mailing list