ID:151770
 
I'm not really up on color theory and mechanics. I can use RGB or Hex color codes with no problem, but things like HSL/HSV aren't so clear for me.

My situation is that I want to be able to effect color changes, starting from blue, going into white, to yellow, and finally ending in red.

There would be about 70 distinct color changes, which I could hard code if it really came down to it. In the meantime, I'd like to see what others thought might be a good way to approach the problem.

I've considered starting at RGB 0,0,255 and add 25.5 R and G to the mix until it hits white. From there remove 25.5 B until yellow is achieved, and then remove 25.5 G until red is achieved.

It strikes me that this may be better suited for HSL than RGB though. I found one library that might help [MobiusEvalon.colourfunctions] but I get the following error when trying to download it:
Downloading Colour Functions (9989 bytes).
Failed to download data (HTTP server returned unexpected status: 404 Not Found).


Thoughts and/or suggestions?
I've got color manipulation functions in LummoxJR.IconProcs including HSV, and procs that will handle the blending for you.

As far as the transitions you suggested, It won't make any difference whether you use HSV or RGB since blue⇒whiterArr;yellowrArr;red can all be done with RGB blending just as easily. Because you're modifying only one or two channels and in a uniform manner, HSV would give you the same results. Where HSV is best used is when you're blending between disparate colors like red and green and want to keep the same brightness, where strict RGB blending would give you a darker gold color when you reached the halfway point between red and green.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
I've got color manipulation functions in LummoxJR.IconProcs including HSV, and procs that will handle the blending for you.

As far as the transitions you suggested, It won't make any difference whether you use HSV or RGB since blue⇒whiterArr;yellowrArr;red can all be done with RGB blending just as easily. Because you're modifying only one or two channels and in a uniform manner, HSV would give you the same results. Where HSV is best used is when you're blending between disparate colors like red and green and want to keep the same brightness, where strict RGB blending would give you a darker gold color when you reached the halfway point between red and green.

Lummox JR

Thanks Lummox. I'm basically trying to automate generating star color based on spectral classification (OBAFGKM), given intervals of 0 to 9 (F5 being half way to G0). F is a yellow star while G is an orange star. Naturally an F5 will be redder than an F0, but not as red as a G0.

I think I've figured out what I'll be doing, and your library will help, thank you. I'll be defining the base color for a given class. I'll get the difference between that and the next class in R, G, and B format, divide by 10, and multiply by the subclass.

So, for an F5, the base color is 255,255,0 and the next color is 255,128,0. The difference is 0,-127,0. 1/10th of that is 0,-12.7,0, and multiplied by the subclass (five) is -63.5, giving me a color of 255,191.5,0.

[EDIT] Or I can just use your blend function with the subclass as a decimal (0.0 to 0.9).
In response to CriticalBotch
To handle star spectra, you might also want to consider not using RGB values directly, but using raw numerics. These you can push past full saturation, so drawing a halo around a bright star would just be a matter of pulling the values down a bit. Of course if you're drawing each star as a point source, that's moot.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
To handle star spectra, you might also want to consider not using RGB values directly, but using raw numerics. These you can push past full saturation, so drawing a halo around a bright star would just be a matter of pulling the values down a bit. Of course if you're drawing each star as a point source, that's moot.

Lummox JR

Hmm, please elaborate?

At the moment I'm trying to get caught up on icon manipulation so I can draw the star object at run time (still considering how I want to handle mapping solar radii to the 32x32 - or multiples of such - icon grid). Any advice you might be able to provide would be very helpful.

Relative ranges for radii are tied to the spectral classes (O through M), and range roughly from 0 to 6.6 and up (I went with an 8.0 cap to better work with the 32 base, which roughly maps 2 pixels per radii).

As I understand it, all the attributes of a star can be derived from it's spectral classification. Mass and radii have a floor and ceiling value based on the current spectral class, and we can derive where (with some variance) between the current class and the next in the same manner as I was getting the color change from one to the next.
In response to CriticalBotch
CriticalBotch wrote:
Thanks Lummox. I'm basically trying to automate generating star color based on spectral classification (OBAFGKM), given intervals of 0 to 9 (F5 being half way to G0). F is a yellow star while G is an orange star. Naturally an F5 will be redder than an F0, but not as red as a G0.

Interesting. You might find this page useful. Even if you just use a linear approximation between stellar classes, it could give you some useful RGB values to interpolate between.
In response to Hobnob
Hobnob wrote:
CriticalBotch wrote:
Thanks Lummox. I'm basically trying to automate generating star color based on spectral classification (OBAFGKM), given intervals of 0 to 9 (F5 being half way to G0). F is a yellow star while G is an orange star. Naturally an F5 will be redder than an F0, but not as red as a G0.

Interesting. You might find this page useful. Even if you just use a linear approximation between stellar classes, it could give you some useful RGB values to interpolate between.

Hmm, thanks for the site. I've been using the Wikipedia entry which seems redshifted from the colors on the site you provided. I'm not sure if that's due to atmospheric interference on the part of the Wikipedia entry or something else, but I believe I'll stick with the Wikipedia values (I like my "red dwarfs" to be red, lol).

I ran a test, using the following values for each class' base:
O - #000080
B - #8080FF
A = #FFFFFF
F = #FFFF80
G = #FFFF00
K = #FF8000
M = #FF0000
X = #400000

X, obviously, isn't a true spectral class. I include it to provide shifting from M0 to M9 and generate a brownish color for brown dwarfs.

In any event, using Lummox's library's BlendRGB(Base, NextBase, SubClass/10) worked wonderfully.

<font color=#000080> Class O0 Star [#000080]</font>
<font color=#0d0d8d> Class O1 Star [#0d0d8d]</font>
<font color=#1a1a99> Class O2 Star [#1a1a99]</font>
<font color=#2626a6> Class O3 Star [#2626a6]</font>
<font color=#3333b3> Class O4 Star [#3333b3]</font>
<font color=#4040c0> Class O5 Star [#4040c0]</font>
<font color=#4d4dcc> Class O6 Star [#4d4dcc]</font>
<font color=#5a5ad9> Class O7 Star [#5a5ad9]</font>
<font color=#6666e6> Class O8 Star [#6666e6]</font>
<font color=#7373f2> Class O9 Star [#7373f2]</font>
<font color=#8080ff> Class B0 Star [#8080ff]</font>
<font color=#8d8dff> Class B1 Star [#8d8dff]</font>
<font color=#9999ff> Class B2 Star [#9999ff]</font>
<font color=#a6a6ff> Class B3 Star [#a6a6ff]</font>
<font color=#b3b3ff> Class B4 Star [#b3b3ff]</font>
<font color=#c0c0ff> Class B5 Star [#c0c0ff]</font>
<font color=#ccccff> Class B6 Star [#ccccff]</font>
<font color=#d9d9ff> Class B7 Star [#d9d9ff]</font>
<font color=#e6e6ff> Class B8 Star [#e6e6ff]</font>
<font color=#f2f2ff> Class B9 Star [#f2f2ff]</font>
<font color=#ffffff> Class A0 Star [#ffffff]</font>
<font color=#fffff2> Class A1 Star [#fffff2]</font>
<font color=#ffffe6> Class A2 Star [#ffffe6]</font>
<font color=#ffffd9> Class A3 Star [#ffffd9]</font>
<font color=#ffffcc> Class A4 Star [#ffffcc]</font>
<font color=#ffffc0> Class A5 Star [#ffffc0]</font>
<font color=#ffffb3> Class A6 Star [#ffffb3]</font>
<font color=#ffffa6> Class A7 Star [#ffffa6]</font>
<font color=#ffff99> Class A8 Star [#ffff99]</font>
<font color=#ffff8d> Class A9 Star [#ffff8d]</font>
<font color=#ffff80> Class F0 Star [#ffff80]</font>
<font color=#ffff73> Class F1 Star [#ffff73]</font>
<font color=#ffff66> Class F2 Star [#ffff66]</font>
<font color=#ffff5a> Class F3 Star [#ffff5a]</font>
<font color=#ffff4d> Class F4 Star [#ffff4d]</font>
<font color=#ffff40> Class F5 Star [#ffff40]</font>
<font color=#ffff33> Class F6 Star [#ffff33]</font>
<font color=#ffff26> Class F7 Star [#ffff26]</font>
<font color=#ffff1a> Class F8 Star [#ffff1a]</font>
<font color=#ffff0d> Class F9 Star [#ffff0d]</font>
<font color=#ffff00> Class G0 Star [#ffff00]</font>
<font color=#fff200> Class G1 Star [#fff200]</font>
<font color=#ffe600> Class G2 Star [#ffe600]</font>
<font color=#ffd900> Class G3 Star [#ffd900]</font>
<font color=#ffcc00> Class G4 Star [#ffcc00]</font>
<font color=#ffc000> Class G5 Star [#ffc000]</font>
<font color=#ffb300> Class G6 Star [#ffb300]</font>
<font color=#ffa600> Class G7 Star [#ffa600]</font>
<font color=#ff9900> Class G8 Star [#ff9900]</font>
<font color=#ff8d00> Class G9 Star [#ff8d00]</font>
<font color=#ff8000> Class K0 Star [#ff8000]</font>
<font color=#ff7300> Class K1 Star [#ff7300]</font>
<font color=#ff6600> Class K2 Star [#ff6600]</font>
<font color=#ff5a00> Class K3 Star [#ff5a00]</font>
<font color=#ff4d00> Class K4 Star [#ff4d00]</font>
<font color=#ff4000> Class K5 Star [#ff4000]</font>
<font color=#ff3300> Class K6 Star [#ff3300]</font>
<font color=#ff2600> Class K7 Star [#ff2600]</font>
<font color=#ff1a00> Class K8 Star [#ff1a00]</font>
<font color=#ff0d00> Class K9 Star [#ff0d00]</font>
<font color=#ff0000> Class M0 Star [#ff0000]</font>
<font color=#ec0000> Class M1 Star [#ec0000]</font>
<font color=#d90000> Class M2 Star [#d90000]</font>
<font color=#c60000> Class M3 Star [#c60000]</font>
<font color=#b30000> Class M4 Star [#b30000]</font>
<font color=#a00000> Class M5 Star [#a00000]</font>
<font color=#8c0000> Class M6 Star [#8c0000]</font>
<font color=#790000> Class M7 Star [#790000]</font>
<font color=#660000> Class M8 Star [#660000]</font>
<font color=#530000> Class M9 Star [#530000]</font>

Obviously there's some spectral classifications here that don't really occur with any frequency, but given that it's for video game I think some concession can be made in favor of ease of use.

[edited as I changed the base O and X values to provide a more useful spectrum, and included the hex values being used]