[cairo] Transforming colours

Bill Spitzak spitzak at d2.com
Fri May 20 09:09:54 PDT 2005


 From the description at

http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary146.html

it looks like this is a linear transformation of the color values. This 
means that each color x is changed into Ax+B.

If the gradient produces a weighted sum of some subset of the color 
stops, and the weights always sum to 1, the result of applying the 
linear transform to this result is identical to applying the sum to the 
transformed stops. I think this is true of Cairo's gradients. Notice 
that linear interpolation of the stops is not necessary, any function 
can be used as long as the weights sum to 1.

So I think replacing the color stops with the transformed values is correct.

Jonathan Roewen wrote:
> Hi,
> 
> I was wondering if anyone had some quick tips on implementing an
> equivalent of Flash's Color.setTransform function?
> 
>>From what I can tell it takes each pixel colour component, scales it
> (-100% to +100%), and adds an offset (-255 to +255).
> 
> What I'm confused about is how I can apply such a transformation to a
> shape in cairo. I'm not sure if I can just replace my colour stops in
> gradients with the calculated colours (which I think is prolly wrong),
> or whether I need something more complicated.



More information about the cairo mailing list