How to make "rainbow" RGB values?

Andrew McNamara andrewm at object-craft.com.au
Sun Feb 24 20:09:27 EST 2008


>I want to map an int to a color on a rainbow spectrum, i.e. for an int
>n in the range 0..N, low values (near 0) should map to the red end,
>and high values (near N) to the blue/violet end.
[...]
>I've tried a simple scheme of overlapping sines, but this resulted in
>too much red and blue, and no indigo/violet.

Consider using an HSV->RGB conversion function. Saturation (S) and value
(V) should remain constant, while Hue (H) varies to get your rainbow
effect.

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/



More information about the Python-list mailing list