Difference between revisions of "GradientValue"

From Second Life Wiki
Jump to navigation Jump to search
m (shorten desc)
m (added check against percentage range)
Line 2: Line 2:
|func=GradientValue
|func=GradientValue
|mode=user
|mode=user
|p1_type=vector|p1_name=startColor|p1_desc=Gradient start color
|p1_type=vector|p1_name=start|p1_desc=Gradient start color
|p2_type=vector|p2_name=endColor|p2_desc=Gradient end color
|p2_type=vector|p2_name=end|p2_desc=Gradient end color
|p3_type=float|p3_name=percentage|p3_desc=Percentage in the range (0.0 to 100.0) from startColor to endColor
|p3_type=float|p3_name=percentage|p3_desc=Percentage in the range (0.0 to 100.0) from start to end
|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|start}} and {{LSLP|end}} depending upon {{LSLP|percentage}}.
|func_footnote
|func_footnote
|caveats
|caveats
Line 12: Line 12:
//  Created by Ugleh Ulrik
//  Created by Ugleh Ulrik


vector GradientValue(vector startColor, vector endColor, float percentage)
vector GradientValue(vector start, vector end, float percentage)
{
{
     percentage /= 100.0;// percentage to decimal for further use
    if (percentage < 0.0 || 100.0 < percentage) return;
     percentage /= 100.0;// convert to decimal for further use


     float red  = startColor.x + percentage*(endColor.x - startColor.x);
     float red  = start.x + percentage*(end.x - start.x);
     float green = startColor.y + percentage*(endColor.y - startColor.y);
     float green = start.y + percentage*(end.y - start.y);
     float blue  = startColor.z + percentage*(endColor.z - startColor.z);
     float blue  = start.z + percentage*(end.z - start.z);


     return <red, green, blue>;
     return <red, green, blue>;
Line 25: Line 26:
|examples=
|examples=
<lsl>
<lsl>
//Created by Ugleh Ulrik
vector GradientValue(vector start, vector end, float percentage)
 
vector GradientValue(vector startColor, vector endColor, float percentage)
{
{
     percentage /= 100.0;// percentage to decimal for further use
    if (percentage < 0.0 || 100.0 < percentage) return;
     percentage /= 100.0;


     float red  = startColor.x + percentage*(endColor.x - startColor.x);
     float red  = start.x + percentage*(end.x - start.x);
     float green = startColor.y + percentage*(endColor.y - startColor.y);
     float green = start.y + percentage*(end.y - start.y);
     float blue  = startColor.z + percentage*(endColor.z - startColor.z);
     float blue  = start.z + percentage*(end.z - start.z);


     return <red, green, blue>;
     return <red, green, blue>;

Revision as of 17:01, 8 January 2014

Summary

Function: vector GradientValue( vector start, vector end, float percentage );

Returns a vector that is the color vector between start and end depending upon percentage.

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

Specification

<lsl> // Created by Ugleh Ulrik

vector GradientValue(vector start, vector end, float percentage) {

   if (percentage < 0.0

Examples

<lsl> vector GradientValue(vector start, vector end, float percentage) {

if (percentage < 0.0

See Also

Constants

•  PRIM_COLOR
•  CHANGED_COLOR

Functions

•  llGetColor
•  llGetLinkPrimitiveParams
•  llSetColor
•  llSetLinkColor

Articles

•  Color and Scripting
•  Color