2

everyone. How would I generate the next color in the color spectrum? Like, a function that takes a red value, a green value, and a blue value for input and output. I could input solid red (RGB 255, 0, 0) and it would output an orangish-red.

EDIT: Some more background info: I'm assuming the H, S, and V values have numeric ranges from 0-255. The C program I'm writing increments the hue value if it is less than 256, resets it to 0 if it's not, converts the HSV to RGB, displays the color on the screen, and loops. I've tried a couple HSV-to-RGB functions, but they're not working.

Babkock
  • 47
  • 1
  • 5

2 Answers2

1

Instead of the RGB domain for colors, you should work with HSV values. This way, you can modify the H value to move around the spectrum.

sukru
  • 2,229
  • 14
  • 15
  • Again, without context it's very difficult to help. You're telling the HSV-RGB functions are not working. Which programming language are you working with? For example, in C# it has been addressed at: http://stackoverflow.com/questions/1335426/is-there-a-built-in-c-net-system-api-for-hsv-to-rgb – sukru Apr 11 '11 at 00:17
1

Do you have to work with RGB values? If you don't, then use HSL as @sukru suggested, otherwise, try to convert it into HSL by following the instructions here, then increment the H value by 1/12, and convert to RGB.

awesomeguy
  • 290
  • 3
  • 10