Difference between revisions of "GradientValue"

From Second Life Wiki
Jump to navigation Jump to search
m (got rid of back-and-forth-conversion and added intra-wiki links)
m (shorten desc)
Line 4: Line 4:
|p1_type=vector|p1_name=startColor|p1_desc=Gradient start color
|p1_type=vector|p1_name=startColor|p1_desc=Gradient start color
|p2_type=vector|p2_name=endColor|p2_desc=Gradient end color
|p2_type=vector|p2_name=endColor|p2_desc=Gradient end color
|p3_type=float|p3_name=percentage|p3_desc=Percentage from startColor to endColor in the range (0.0 <{{=}} percentage <{{=}} 100.0)
|p3_type=float|p3_name=percentage|p3_desc=Percentage in the range (0.0 to 100.0) from startColor to endColor
|return_type=vector|return_text=that is the color vector between {{LSLP|startColor}} and {{LSLP|endColor}} depending upon {{LSLP|percentage}}.
|return_type=vector|return_text=that is the color vector between {{LSLP|startColor}} and {{LSLP|endColor}} depending upon {{LSLP|percentage}}.
|func_footnote
|func_footnote

Revision as of 15:55, 8 January 2014

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