Difference between revisions of "Color and Scripting"
(added category flag for Text from In-world Notecards) |
(wikified) |
||
Line 1: | Line 1: | ||
Using color in SL scripting is fairly easy. If works by combining values of red, green, and blue light. They are stored like this: | 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 > | < Red Value, Green Value, Blue Value > | ||
Each red, green, or blue value can be between 0 (no color saturation) to 1 (total color saturation). | 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: | |||
The combination of all three with no | |||
If there is not saturation on two values, and the third is saturated, you get a pure color: | If there is not saturation on two values, and the third is saturated, you get a pure color: | ||
<1,0,0> = | {|class="wikitable" style="color:#fff;text-align:center;border: 1px solid #999; background: #111; " border="1" | ||
|- | |||
! Color !! Hexadecimal for CSS/HTML !! Vector for Second Life | |||
|- style="background:#f00;color:#000" | |||
! Red | |||
| #ff0000 | |||
|<1.0, 0.0, 0.0> | |||
|- style="background:#0f0;color:#000" | |||
! Green | |||
| #00ff00 | |||
|<0.0, 1.0, 0.0> | |||
|- style="background:#00f;color:#fff" | |||
! Blue | |||
| #0000ff | |||
|<0.0, 0.0, 1.0> | |||
|- style="background:#ff7f00;color:#000" | |||
! Orange | |||
| #ff7f00 | |||
|<1.0, 0.5, 0.0> | |||
|- style="background:#0ff;color:#000" | |||
! Cyan | |||
| #00ffff | |||
|<0.0, 1.0, 1.0> | |||
|- style="background:#ff007f;color:#000" | |||
! Pink | |||
| #ff007f | |||
|<1.0, 0.0, 0.5> | |||
|- style="background:#ff0;color:#000" | |||
! Yellow | |||
| #ffff00 | |||
|<1.0, 1.0, 0.0> | |||
|- style="background:#909;color:#fff" | |||
! Purple | |||
| #990099 | |||
|<0.6, 0.0, 0.6> | |||
|- style="background:#fff;color:#000;" | |||
! White | |||
| #ffffff | |||
| <1.0, 1.0, 1.0> | |||
|- style="background:#000;color:#fff" | |||
! 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) | |||
{|class="wikitable" style="text-align:center;border: 1px solid #000" | |||
! Hexadecimal !! Decimal !! Saturation Float | |||
|- | |||
| FF | |||
| 255 | |||
| 1.0 | |||
|- | |||
| CC | |||
| 204 | |||
| 0.8 | |||
|- | |||
| 00 | |||
| 0 | |||
| 0.0 | |||
|} | |||
FF = total saturation | FF = total saturation | ||
Line 47: | Line 84: | ||
Therefore: | Therefore: | ||
FF00FF = <1,0,1> | FF00FF = <1.0,0.0,1.0> | ||
== Contributor == | |||
[[User:FlipperPA Peregrine|FlipperPA Peregrine]] | |||
FlipperPA Peregrine | |||
[[Category:Text from In-world Notecards]] | [[Category:Text from In-world Notecards|Color and Scripting]] | ||
[[Category:Tutorials|Color and Scripting]] | |||
[[Category:Articles in need of expansion|Color and Scripting]] |
Revision as of 16:55, 8 January 2007
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>