Difference between revisions of "Color and Scripting"

From Second Life Wiki
Jump to: navigation, search
m
m (Converting Hexadecimal to Vectors)
Line 60: Line 60:
 
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)
 
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"
+
{|class="wikitable" {{Prettytable}}
! Hexadecimal !! Decimal !! Saturation Float
+
|-  
 +
!
 +
!{{Hl2}}| Red
 +
!{{Hl2}}| Green
 +
!{{Hl2}}| Blue
 
|-
 
|-
 +
! {{Hl2}} | Hexadecimal
 
| FF
 
| FF
| 255
 
| 1.0
 
|-
 
 
| CC
 
| CC
| 204
 
| 0.8
 
|-
 
 
| 00
 
| 00
 +
|-
 +
! {{Hl2}} |Decimal
 +
| 255
 +
| 204
 
| 0
 
| 0
 +
|-
 +
! {{Hl2}} |Saturation Float
 +
| 1.0
 +
| 0.8
 
| 0.0
 
| 0.0
 
|}
 
|}

Revision as of 11:19, 5 November 2008

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)

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