Topic: Calculate RGB values between two colours |
|
---|---|
Author | Thread |
Maniac (V) Mad Scientist From: :morF |
posted 10-13-2006 17:44
Okay, say I've got two colour points in the RGB scale, one representing an eye-searing red, the other a mid-level dark green, and I need to calculate 10 evenly-spaced points between them, does anyone know a way I could do this? See, it's part of a java assignment I'm doing, that colours JList item backgrounds dependent on a given value. 12 points in total, including the two extremes. I can do the program, I just don't know how to calculate those points to create the appropaite Color objects for them. |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 10-13-2006 18:36
How about just dividing the distance for the channels seperatly by 12, then |
Maniac (V) Mad Scientist From: :morF |
posted 10-14-2006 01:46
Well, the transition from a mid-dark green also involves dropping the blue channel, since that's what makes the green darker. And since the correct transition goes through green to yellow to orange to red... |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 10-14-2006 09:17
In that case, I'm pretty sure RGB won't do for you, you will need to convert into another color space. |
Maniac (V) Mad Scientist From: :morF |
posted 10-14-2006 09:46
Yes... apparently HSV should be able to do it, but I've still got to work the algorithm out |
Maniac (V) Mad Scientist From: |
posted 10-14-2006 10:35
How about vectors? |
Paranoid (IV) Inmate From: Norway |
posted 10-14-2006 16:12
Skaarj: HSV <-> RGB conversions are well documented. Check wikipedia: HSV_color_space or wikipedia: HSL_color_space. I doubt using either HSL or HSV would make any difference in the end result. |