Here's where I get to be like TDK and show you the code I wrote 90 years ago to do this very thing...
function rainbowcolour(n)
r = 255-n
g = 255-abs(127-n)*2
b = n
Endfunction rgb(r,g,b)
I don't seem to have posted this before so I'm not sure if it's right, just typing from memory.
The function takes a single integer; 0-255 gives a rainbow, going beyond 255 goes into yellow and magenta colours.
[edit]
The problem with mine is that as soon as one colour starts increasing another decreases meaning you never get a bright yellow for example.
I haven't worked out how to get an overlap like this;
red high, green low, blue low
red high, green high, blue low
red low, green high, blue low
red low, green high, blue high
red low, green low, blue high
(and wrapping)
red high, green low, blue high
When someone works out how to do that it will be perfect.
TGC Forum - converting error messages into sarcasm since 2002.