Difference between revisions of "Color and Scripting"

From Second Life Wiki
Jump to navigation Jump to search
(two colors, gray and brown, added to table)
m (Ok, colors don't have to be IN MY FACE, but grey on grey? fixed....)
Line 46: Line 46:
| #990099
| #990099
|<0.6, 0.0, 0.6>
|<0.6, 0.0, 0.6>
|- style="background:#664;color:#c33;"
|- style="background:#664;color:#fff;"
! brown
! brown
| #664c33
| #664c33
Line 54: Line 54:
| #ffffff
| #ffffff
| <1.0, 1.0, 1.0>
| <1.0, 1.0, 1.0>
|- style="background:#787;color:#878;"
|- style="background:#787;color:#fff;"
! Gray
! Gray
| #787878
| #787878

Revision as of 13:48, 1 July 2013

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>
brown #664c33 <0.4, 0.2, 0.3>
White #ffffff <1.0, 1.0, 1.0>
Gray #787878 <0.5, 0.5, 0.5>
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)

Form\Channels Red Green Blue
Hexadecimal FF CC 00
Decimal 255 204 0
Saturation Float 1.0 0.8 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>

Contributor

FlipperPA Peregrine