[cairo] Path Gradients

Bill Spitzak spitzak at thefoundry.co.uk
Fri Jan 4 11:12:11 PST 2008

Behdad Esfahbod wrote:

>> It was unclear what happens with multiple-step gradients, which some
>> of 
>> the examples show. Does it only change the last step, or is there an
>> api 
>> to change all the steps?
> The actual radial stops where done in the code using a Blend object,
> that's like just having stops for alpha value.  That is, instead of the
> linear interpolation between the two ends, user can provide a detailed
> blend function.  No separate color stops.

I'm sorry, I thought you were talking about the example where the color 
along the edge changes, as shown by the top-left triangle in this picture:


It is apparent from the examples that they support multi-stop gradients, 
but there is no example of what happens if you specify *both* this and 
if you change the colors along the path. Does it only change the last 
stop? Or is there an api to change all the stops? Or does it just not work?

>> I am still very interested in any explanation why the path needs to
>> be 
>> specified twice and what happens if the two paths are different.
> What do you mean by twice?  Where?

All the examples in this paper send the path twice, once to construct 
the "path gradient brush" and again to fill the shape:


My best guess is that this really is similar to how Cairo does the 
radial brush. The "path gradient" specifies a pattern that can then be 
masked by a different path. Unfortunately it appears that they define 
the pattern as transparent outside the path, which makes it pretty 
useless for any path that is outside the source path. I think defining 
the outside as being equal to the last stop would be much more useful.

More information about the cairo mailing list