468,456 Members | 1,663 Online

Programmatic rainbows

This probably isn't the best newsgroup for this question, but it's
something I've always been curious about. A while back, I wanted to
programmatically create a rainbow-like status bar. One end would be
red and the far end would be blue. Depending on the status percentage,
only a certain amount of color would be draw (from left-edge red all
the way up to right-edge blue). I wanted to create it programmatically
so that the dimensions of the image could change. However, I could
never figure out the correct RGB/x-coord formula to generate a
nice-looking rainbow. So, assuming a width of 100 pixels at x=0 I'd
use RGB(255,0,0) and for x=99 RGB(0,0,255). Any clue how to solve this?

Jul 11 '06 #1
2 2106
go*************@yahoo.com wrote:
This probably isn't the best newsgroup for this question, but it's
something I've always been curious about. A while back, I wanted to
programmatically create a rainbow-like status bar. One end would be
red and the far end would be blue. Depending on the status
percentage, only a certain amount of color would be draw (from
left-edge red all the way up to right-edge blue). I wanted to create
it programmatically so that the dimensions of the image could change.
However, I could never figure out the correct RGB/x-coord formula to
generate a nice-looking rainbow. So, assuming a width of 100 pixels
at x=0 I'd use RGB(255,0,0) and for x=99 RGB(0,0,255). Any clue how
to solve this?
to do with C++ language.

V
--
Jul 11 '06 #2
godfatherofsoul wrote:
This probably isn't the best newsgroup for this question
Nope. Could you have googled-up a better one?
but it's
something I've always been curious about. A while back, I wanted to
programmatically create a rainbow-like status bar. One end would be red
and the far end would be blue. Depending on the status percentage, only a
certain amount of color would be draw (from left-edge red all the way up
to right-edge blue). I wanted to create it programmatically so that the
dimensions of the image could change. However, I could never figure out
the correct RGB/x-coord formula to generate a nice-looking rainbow. So,
assuming a width of 100 pixels at x=0 I'd use RGB(255,0,0) and for x=99
RGB(0,0,255). Any clue how to solve this?
You are asking how to declare a color ramp in HVS, which is Hue Value
Saturation. Look up a system to change your Hue while clamping the VS, and
a system to convert HVS to RGB.

--
Phlip

Jul 12 '06 #3