Color and Scripting
Using color in SL scripting is fairly easy. If works by combining values of red, green, and blue light. They are stored like this:
< Red Value, Green Value, Blue Value >
Each red, green, or blue value can be between 0.0 (no color saturation) to 1.0 (total color saturation). These values are determined by combining the colors as if they were light, not paint. Therefore, the combination of all three in total saturation is white:
The combination of all three with no saturation is black:
If there is not saturation on two values, and the third is saturated, you get a pure color:
Color | Hexadecimal for CSS/HTML | Vector for Second Life |
---|---|---|
Red | #ff0000 | <1.0, 0.0, 0.0> |
Green | #00ff00 | <0.0, 1.0, 0.0> |
Blue | #0000ff | <0.0, 0.0, 1.0> |
Orange | #ff7f00 | <1.0, 0.5, 0.0> |
Cyan | #00ffff | <0.0, 1.0, 1.0> |
Pink | #ff007f | <1.0, 0.0, 0.5> |
Yellow | #ffff00 | <1.0, 1.0, 0.0> |
Purple | #990099 | <0.6, 0.0, 0.6> |
White | #ffffff | <1.0, 1.0, 1.0> |
Black | #000000 | <0.0, 0.0, 0.0> |
Converting Hexadecimal to Vectors
To convert from a hexadecimal values used in CSS or HTML to ones usable in Second Life scripting, first convert the number for the red, green and blue saturation from hexadecimal to decimal, then divide that number by 255. Do bear in mind that 3-digit codes are a shorthand form, so each digit should be doubled (F becomes FF, 4 becomes 44, 0 becomes 00 etc)
Hexadecimal | Decimal | Saturation Float |
---|---|---|
FF | 255 | 1.0 |
CC | 204 | 0.8 |
00 | 0 | 0.0 |
FF = total saturation
00 = no saturation
00 on the web = 0 in Second Life
FF on the web = 1 in Second Life
Therefore:
FF00FF = <1.0,0.0,1.0>