Color gradient

A gradient is a gradient. Along a line, the color of an object changes from a (starting) color to a (target) color. The gradient can also extend radially, there may be several color transitions occur and the gradients can also be non-linear.

Gradients and color spaces

Linear RGB course

The RGB color space is a space in which each color is composed of a red, a green and a blue component. This forms a three-dimensional cube, which yields a straight line, can construct from the start to the finish color.

Linear Gradient in other color spaces

There are a number of other color spaces with which one can represent colors. About the CMYK space or the various Lab color spaces ( XYZ, Hunter Lab or CIE Lab ). Converts to the two output colors in such a model, there is calculated a linear course and converts the result back to RGB, so you get a different, not necessarily in RGB linear. Algorithms for conversion into these spaces and then back from them can be found at:

If one tries to apply this method to the CMY space, it is found that the result is the same, which are also achieved in the RGB space.

Gradients in the HSV space

The HSV space is a color space in which one defines a color by hue, saturation and brightness. This representation is the human perception of color come closer than other color spaces. The HSV space can be conceived either as a cylinder or a cone.

In HSV can be produced by changing the angle and percentage values ​​only in spatial coordinates and then back again a linear course. Here you have to decide for the representation of the space as a cylinder or a cone.

Are there differences between two colors only by their hue angle, so one can assume the circled portion as the course on which are these two colors.

Differ both in color brightness, and saturation, you get a spiral cut in the HSV cone.

This type of transition has the advantage that during the course of similar saturated colors appear no gray colors. However, if the saturation but 0, so dive in history, both unpredictably colors.

One, a similar spiral tread, as described above in the other direction. If the two colors relatively close together, so only one of the two courses, the shorter, more useful are the two colors, however far apart, so it's a matter of taste which one prefers. The upper runs rather by the cooler, the lower rather by the warmer colors.