Difference between revisions of "LlSetColor"

From Second Life Wiki
Jump to navigation Jump to search
(That is harder to read and costs more in LSO.)
m (Replaced old <LSL> block with <source lang="lsl2">)
Line 10: Line 10:
|caveats
|caveats
|constants
|constants
|examples=<lsl>
|examples=<source lang="lsl2">
integer face = -1;
integer face = -1;
vector color = <1.0, 1.0, 1.0>;
vector color = <1.0, 1.0, 1.0>;
Line 25: Line 25:
     }
     }
}
}
</lsl>
</source>
|helpers=
|helpers=
{{{!}} class="sortable" {{Prettytable}}
{{{!}} class="sortable" {{Prettytable}}

Revision as of 14:46, 22 January 2015

Summary

Function: llSetColor( vector color, integer face );

Sets the color on face of the prim.

• vector color color in RGB <R, G, B> (<0.0, 0.0, 0.0> = black, <1.0, 1.0, 1.0> = white)
• integer face face number or ALL_SIDES

If face is ALL_SIDES then the function works on all sides.

Newbie Notes

llSetColor changes the color of a prim, either on a specific side (face) or the entire prim.

Example:
llSetColor(<r, g, b>, ALL_SIDES);

r, g, b: values for red, green, blue ranging from <0.0, 0.0, 0.0> (black) to <1.0, 1.0, 1.0> (white)

To continue reading see: Newbie Notes

Caveats

  • The function silently fails if its face value indicates a face that does not exist.
All Issues ~ Search JIRA for related Bugs

Examples

integer face = -1;
vector color = <1.0, 1.0, 1.0>;

default
{
    touch_start(integer num)
    {
        if(~face)       //quick & dirty but efficient way of testing if face is not equal to -1
            llSetColor(color, face); //restore the color
        face = (face + 1) % llGetNumberOfSides(); //increment and keep the face number in range
        color = llGetColor(face); //save the face's color
        llSetColor(<0.5, 0.0, 0.0>, face );  //change the face's color
    }
}

Useful Snippets

Color Hexadecimal code LSL color representations
NAVY #001f3f <0.000, 0.122, 0.247>
BLUE #0074d9 <0.000, 0.455, 0.851>
AQUA #7fdbff <0.498, 0.859, 1.000>
TEAL #39cccc <0.224, 0.800, 0.800>
OLIVE #3d9970 <0.239, 0.600, 0.439>
GREEN #2ecc40 <0.180, 0.800, 0.251>
LIME #01ff70 <0.004, 1.000, 0.439>
YELLOW #ffdc00 <1.000, 0.863, 0.000>
ORANGE #ff851b <1.000, 0.522, 0.106>
RED #ff4136 <1.000, 0.255, 0.212>
MAROON #85144b <0.522, 0.078, 0.294>
FUCHSIA #f012be <0.941, 0.071, 0.745>
PURPLE #b10dc9 <0.694, 0.051, 0.788>
WHITE #ffffff <1.000, 1.000, 1.000>
SILVER #dddddd <0.867, 0.867, 0.867>
GRAY #aaaaaa <0.667, 0.667, 0.667>
BLACK #111111 <0.067, 0.067, 0.067>

See Also

Events

•  changed CHANGED_COLOR

Functions

•  llGetAlpha Gets the prim's alpha
•  llSetAlpha Sets the prim's alpha
•  llGetColor Gets the prim's color
•  llSetLinkColor Sets link's color
•  llSetLinkAlpha Sets link's alpha

Articles

•  Color in LSL
•  Color and Scripting

Deep Notes

Search JIRA for related Issues

Signature

function void llSetColor( vector color, integer face );