jremington:

I believe, even if you don’t, that your understanding could be improved by some reading and study of the basic concepts, and I took the time to point you toward an overview.

Everyone doing what you want to do uses the HSV or HSL color space. HSV is close to the way we naturally perceive and understand color, and much easier to use than RGB color mixing.

The routines I linked are actually quite simple, even for a novice. Three numbers in (Hue, Saturation and Value or Luminosity) and three numbers out (R, G, B).

This is a routine I have used (the structs can be replaced by 3D vectors or arrays):

```
typedef struct {
```

double r; // ∈ [0, 1]

double g; // ∈ [0, 1]

double b; // ∈ [0, 1]

} rgb;

typedef struct {

double h; // ∈ [0, 360]

double s; // ∈ [0, 1]

double v; // ∈ [0, 1]

} hsv;

rgb hsv2rgb(hsv HSV)

{

rgb RGB;

double H = HSV.h, S = HSV.s, V = HSV.v,

P, Q, T,

fract;

(H == 360.)?(H = 0.):(H /= 60.);

fract = H - floor(H);

P = V*(1. - S);

Q = V*(1. - S*fract);*

T = V(1. - S*(1. - fract));

if (0. <= H && H < 1.)

RGB = (rgb){.r = V, .g = T, .b = P};

else if (1. <= H && H < 2.)

RGB = (rgb){.r = Q, .g = V, .b = P};

else if (2. <= H && H < 3.)

RGB = (rgb){.r = P, .g = V, .b = T};

else if (3. <= H && H < 4.)

RGB = (rgb){.r = P, .g = Q, .b = V};

else if (4. <= H && H < 5.)

RGB = (rgb){.r = T, .g = P, .b = V};

else if (5. <= H && H < 6.)

RGB = (rgb){.r = V, .g = P, .b = Q};

else

RGB = (rgb){.r = 0., .g = 0., .b = 0.};

return RGB;

}

Thank you very much. I will try to apply this to my project, even though I dont think I have enough knowledge to do so. I dont really know what a 3D vector or array is, etc, etc… so it wont be easy for me to apply this. That is why I came to the forum, for some guidance.

If you want people to write code for you, post on the Gigs and Collaborations forum section. You may be asked to pay for the help.

I dont really understand from where you deduce that I am expecting somebody to write code for me. I never said so, neither I expect it to happen, but if it makes you happy to continue implying this, be happy.