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?

Thanks,

David

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?

Thanks,

Dave

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.