11.3 Color gradients

The color module provides a class gradient for continous transitions between colors. A list of named gradients is available in appendix .

class gradient( min=0, max=1)
This class provides the methods for the gradient. Different initializations can be found in lineargradient and functiongradient.

min and max provide the valid range of the arguments for getcolor.

getcolor( parameter)
Returns the color that corresponds to parameter (must be between min and max).

select( index, n_indices)
When a total number of n_indices different colors is needed from the gradient, this method returns the index-th color.

class lineargradient( startcolor, endcolor, min=0, max=1)
This class provides a linear transition between two given colors. The linear interpolation is performed on the color components of the specific color model.

startcolor and endcolor must be colors of the same color model.

class functiongradient( functions, type, min=0, max=1)
This class provides an arbitray transition between colors of the same color model.

type is a string indicating the color model (one of "cmyk", "rgb", "hsb", "grey")

functions is a dictionary that maps the color components onto given functions. E.g. for type="rgb" this dictionary must have the keys "r", "g", and "b".