Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!sun-barr!newstop!texsun!convex!forsythe@convex.com From: forsythe@convex.com (Charles Forsythe) Newsgroups: comp.graphics Subject: Re: Colors of the Rainbow Message-ID: <4347@convex.UUCP> Date: 4 Jan 90 06:29:50 GMT References: <2284@isaak.isa.de> Sender: usenet@convex.UUCP Lines: 32 schwarze@isaak.uucp (Jochen Schwarze) writes: >I'm looking for a function that maps a wavelength to the appropriate RGB >triple. Has anybody done this? Any pointers appreciated. This is actually very easy to do. R = M * sin(T) + N G = M * sin(T + phi) + N B = M * sin(T + theta) + N T goes from 0 to 360 degress. phi is 120 degrees theta is 240 degrees M and N are just adjustment constants, typically M=128 and N=128 to swing over an entire unsigned 8-bit value. I haven't done this for a while, but I know that the sine waves should be evenly phase-shifted across an interval. I'm pretty sure it's 360 degrees, but it might be 180 -- try and see. This should go dark_red-->purple with all of the colors inbetween in their proper order. One problem with this color set is that it's luminosity is constant. While the colors are vibrant, there is no contrast and hence an image using just these colors can be a little boring. If it's important, you may want to experiment with some functions that add or subtract luminoisity and saturation to add a little more diversity to the hues. -Charles ======================== Send comments/flames to: forsythe@convex.com Convex does not filter outgoing posts and is not responsible for the contents therein.