Category:LSL Color
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Color in LSL
Color in LSLLSL has its own special format for color. LSL uses a vector to store color. Unlike traditional RGB where each channel is 0 -> 255, LSL's color channels are 0 -> 1.
Format: <R, G, B>
• float | x | – | Red value | [0, 1] |
• float | y | – | Green value | [0, 1] |
• float | z | – | Blue value | [0, 1] |
Examples
<lsl>vector white = <1.0, 1.0, 1.0>; vector grey = <0.5, 0.5, 0.5>; vector black = <0.0, 0.0, 0.0>; vector red = <1.0, 0.0, 0.0>; vector green = <0.0, 1.0, 0.0>; vector blue = <0.0, 0.0, 1.0>; vector yellow = <1.0, 1.0, 0.0>; vector cyan = <0.0, 1.0, 1.0>; vector magenta = <1.0, 0.0, 1.0>;</lsl>
Equivalent color vectors with classic menu colors
<lsl>vector black = <0,0,0>;//Color 1 vector white_A = <1,1,1>;//Color 2 vector gray = <0.50196,0.50196,0.50196>;//Color 2 vector light_gray = <0.74902,0.74902,0.74902>;//Color 3 vector dark_red = <0.50196,0,0>;//Color 3 vector red = <1,0,0>;//Color 4 vector dark_yellow = <0.50196,0,0>;//Color 5 vector yellow = <1,0,0>;//Color 6 vector dark_green = <0,0.50196,0>;//Color 7 vector green = <0,1,0>;//Color 8 vector dark_cyan = <0,0.50196,0.50196>;//Color 9 vector cyan = <0,1,1>;//Color 10 vector dark_blue = <0,0,0.50196>;//Color 11 vector blue = <0,0,1>;//Color 12 vector dark_magenta = <0.50196,0,0.50196>;//Color 13 vector magenta = <1,0,1>;//Color 14 vector dirty_yellow = <0.50196,0.50196,0>;//Color 15 vector light_yellow = <1,1,0.50196>;//Color 16 vector dark_green_to_blue = <0,0.25098,0.25098>;//Color 17 vector green_to_blue = <0,1,0.50196>;//Color 18 vector light_green_to_blue = <0,0.50196,1>;//Color 19 vector light_blue_to_green = <0.50196,1,1>;//Color 20 vector dark_blue_to_cyan = <0,0.25098,0.50196>;//Color 21 vector cyan_to_pink = <0.50196,0.50196,1>;//Color 22 vector indigo = <0.50196,0,1>;//Color 23 vector violet = <1,1,0.50196>;//Color 24 vector dark_brown = <0.50196,0.25098,0>;//Color 25 vector brown = <1,0.50196,0>;//Color 26 vector light_brown = <0.74902,0.49824,0.25098>;//Color 27 vector white_B = <1,1,1>;//Color 28 vector dirty_white = <1,1,0.78824>;//Color 29 vector white_C = <1,1,1>;//Color 30 //In prectice, rounded values can be used, like 0.5 for 0.50196>;</lsl>
Useful Snippets
Useful functions for storing/retrieving color and alpha values to/from integers <lsl>integer ColorAlphatoRGBA(vector color, float alpha) {
return (((integer)(alpha * 255.0) & 0xFF) << 24)
Pages in category "LSL Color"
The following 29 pages are in this category, out of 29 total.