[cairo] Getting Colour from linear gradient

Carl Worth cworth at cworth.org
Thu Sep 4 14:58:10 PDT 2008


On Wed, 2008-09-03 at 13:50 +0200, Michael Gurnett wrote:
> Is there anyway of determining the colour at a given position from a linear gradiant.

There's no direct way to in the current API.

One could workaround that by using the gradient as the source, (with a
desired transformation to isolate the portion desired), and painting to
a 1x1 image surface, and then reading the value out.

That's either ugly or clever, take your pick.

Also, there's obviously internal functionality that does basically what
you want, so one could imagine writing a proposal (or patch!) to export
that.

I hope that helps, and I hope you have fun with cairo!

-Carl





More information about the cairo mailing list