gradientValue

From Second Life Wiki
Revision as of 15:55, 8 January 2014 by Kireji Haiku (talk | contribs) (shorten desc)
Jump to navigation Jump to search

Summary

Function: vector GradientValue( vector startColor, vector endColor, float percentage );

Returns a vector that is the color vector between startColor and endColor depending upon percentage.

• vector startColor Gradient start color
• vector endColor Gradient end color
• float percentage Percentage in the range (0.0 to 100.0) from startColor to endColor

Specification

<lsl> // Created by Ugleh Ulrik

vector GradientValue(vector startColor, vector endColor, float percentage) {

   percentage /= 100.0;// percentage to decimal for further use
   float red   = startColor.x + percentage*(endColor.x - startColor.x);
   float green = startColor.y + percentage*(endColor.y - startColor.y);
   float blue  = startColor.z + percentage*(endColor.z - startColor.z);
   return <red, green, blue>;

} </lsl>

Examples

<lsl> //Created by Ugleh Ulrik

vector GradientValue(vector startColor, vector endColor, float percentage) {

   percentage /= 100.0;// percentage to decimal for further use
   float red   = startColor.x + percentage*(endColor.x - startColor.x);
   float green = startColor.y + percentage*(endColor.y - startColor.y);
   float blue  = startColor.z + percentage*(endColor.z - startColor.z);
   return <red, green, blue>;

}

default {

   state_entry()
   {
       vector maroon = <0.522, 0.078, 0.294>;
       vector teal   = <0.224, 0.800, 0.800>;
       vector ColorBetween = GradientValue(maroon, teal, 50.0);

// ColorBetween = <0.373, 0.439, 0.547>

       llSetColor(ColorBetween, ALL_SIDES);
   }

}

</lsl>

See Also

Constants

•  PRIM_COLOR
•  CHANGED_COLOR

Functions

•  llGetColor
•  llGetLinkPrimitiveParams
•  llSetColor
•  llSetLinkColor

Articles

•  Color and Scripting
•  Color