, , .
; , float RGB? (. "" http://jk.ozlabs.org/projects/lca2008-hackfest/).
, HSV RSB Saturation Value Hue. RGB:

. http://jk.ozlabs.org/blog/post/65/hackfest08-solution-2/ , .
C, python. , , 0 <= <= 1, , , , -1 <= <= 1:
static float interpolate(float x, float x_min, float x_max,
float y_min, float y_max)
{
x = (x - x_min) / (x_max - x_min);
return x * (y_max - y_min) + y_min;
}
void colour_map(struct pixel *pix, float i, float i_max)
{
const float saturation = 0.8;
const float value = 0.8;
float v_min, hue;
hue = i / (i_max + 1);
v_min = value * (1 - saturation);
if (hue < 0.25) {
pix->r = value * 255;
pix->g = interpolate(hue, 0.0, 0.25, v_min, value) * 255;
pix->b = v_min * 255;
} else if (hue < 0.5) {
pix->r = interpolate(hue, 0.25, 0.5, value, v_min) * 255;
pix->g = value * 255;
pix->b = v_min * 255;
} else if (hue < 0.75) {
pix->r = v_min * 255;
pix->g = value * 255;
pix->b = interpolate(hue, 0.5, 0.75, v_min, value) * 255;
} else {
pix->r = v_min * 255;
pix->g = interpolate(hue, 0.75, 1.0, value, v_min) * 255;
pix->b = value * 255;
}
pix->a = 255;
}