Is there a way to interpolate between RGB values? I have a set of values that I want to map (linearly or otherwise) to colors from a color_min RGB triple to a color_max RGB triple. Since RGB is not "incrementable", how would I do this?



just interpolate each component?

but how do you make the color transitions smooth - ie. how to ensure the colors run through the reds first before switching to the mix of red green before switching to the green... etc. ?

ie the colors dont go in order like some sort of binary thing. 0 0 0 is not necessarily followed by 0 0 1, etc.

Am I wrong about this?



If all you want is a color cube then yes, all you need to do is increment it like a binary number.

If you are not storing it as a packed integer value, then you only need three loops:

for red := min to max
    for green := min to max
      for blue := min to max
        output (red, green, blue)

(BTW, in both cases this is the "interpolate each component".)

Hope this helps.