Programmatic rainbows

G

godfatherofsoul

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?
 
V

Victor Bazarov

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?

Post to 'comp.graphics.algorithms', please. Your question has nothing
to do with C++ language.

V
 
P

Phlip

godfatherofsoul said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top