[CREATE] Gradients formulas

Jon Cruz jon at joncruz.org
Sun Dec 12 12:44:52 PST 2010


On Dec 6, 2010, at 2:02 AM, Olivier BERTEN wrote:

> Well... I guess my question wasn't clear ;-)
> 
> What I'm looking for are the actual algorithms used for gradients
> rendering in the different existing rendering engines. In other words:
> how do I compute the color value of a point in a gradient.
> 
> Some underlying questions are:
> How do you deal with middle point? isn't it just another color stop?

Depending on the mode for the segment (see GIMP blend modes http://wiki.inkscape.org/wiki/index.php/Swatch_Book#Gradient ).

You probably should think of it more as a control point for the interpolation function.


> For the software dealing with different color models, how do you deal
> with "mixed" gradients? from a RGB color to a CMYK color, for instance?
> The "Color gradient" article on Wikipedia says "In digital imaging
> systems, colors are typically interpolated in an RGB color space, often
> using gamma compressed RGB color values, as opposed to linear."

It really depends on the software. Adobe often will use the color mode/colorspace with the most fidelity. CMYK is a common fallback.

And even SVG that interpolates in RGB does allow for explicit control of interpolation in either sRGB or linear RGB.


> Who does
> gamma compression? How?



> I guess the best way to know that is to look at the code so here's for
> Gimp. If you can give me directions for other rendering engines, that
> would be great. I'd like to get an equivalent of the
> gimp_gradient_get_color_at for other softwares.
> 
> http://git.gnome.org/browse/gimp/tree/app/core/gimpgradient.c

For other software, things are trickier. However there are specs out there for postscript, PDF, etc. And people like those in #scribus in IRC are quite familiar with them.





More information about the CREATE mailing list