By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,898 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,898 IT Pros & Developers. It's quick & easy.

Programmatic rainbows

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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?
Post to 'comp.graphics.algorithms', please. Your question has nothing
to do with C++ language.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 11 '06 #2

P: n/a
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

This discussion thread is closed

Replies have been disabled for this discussion.