Difference between revisions of "GradientValue"
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) (some general readability improvements and some for non-widescreens when viewing the page specifically) |
Kireji Haiku (talk | contribs) m (got rid of back-and-forth-conversion and added intra-wiki links) |
||
Line 2: | Line 2: | ||
|func=GradientValue | |func=GradientValue | ||
|mode=user | |mode=user | ||
|p1_type=vector|p1_name= | |p1_type=vector|p1_name=startColor|p1_desc=Gradient start color | ||
|p2_type=vector|p2_name=endColor|p2_desc= | |p2_type=vector|p2_name=endColor|p2_desc=Gradient end color | ||
|p3_type=float|p3_name=percentage|p3_desc= | |p3_type=float|p3_name=percentage|p3_desc=Percentage from startColor to endColor in the range (0.0 <{{=}} percentage <{{=}} 100.0) | ||
| | |return_type=vector|return_text=that is the color vector between {{LSLP|startColor}} and {{LSLP|endColor}} depending upon {{LSLP|percentage}}. | ||
|func_footnote | |func_footnote | ||
|caveats | |||
|spec= | |spec= | ||
<lsl> | <lsl> | ||
//Created by Ugleh Ulrik | // Created by Ugleh Ulrik | ||
vector GradientValue(vector | vector GradientValue(vector startColor, vector endColor, float percentage) | ||
{ | { | ||
/ | percentage /= 100.0;// percentage to decimal for further use | ||
float red = | float red = startColor.x + percentage*(endColor.x - startColor.x); | ||
float green = | float green = startColor.y + percentage*(endColor.y - startColor.y); | ||
float blue = | float blue = startColor.z + percentage*(endColor.z - startColor.z); | ||
return <red,green,blue> | return <red, green, blue>; | ||
} | } | ||
</lsl> | </lsl> | ||
|examples= | |examples= | ||
<lsl> | <lsl> | ||
//Created by Ugleh Ulrik | //Created by Ugleh Ulrik | ||
vector GradientValue (vector | vector GradientValue(vector startColor, vector endColor, float percentage) | ||
{ | { | ||
/ | percentage /= 100.0;// percentage to decimal for further use | ||
float red = | float red = startColor.x + percentage*(endColor.x - startColor.x); | ||
float green = | float green = startColor.y + percentage*(endColor.y - startColor.y); | ||
float blue = | float blue = startColor.z + percentage*(endColor.z - startColor.z); | ||
return <red, green, blue> | return <red, green, blue>; | ||
} | } | ||
default | default | ||
Line 46: | Line 42: | ||
state_entry() | state_entry() | ||
{ | { | ||
vector maroon = <0.522, 0.078, 0.294>; | |||
vector teal = <0.224, 0.800, 0.800>; | |||
vector | |||
vector ColorBetween = GradientValue(maroon, teal, 50.0); | |||
// ColorBetween = <0.373, 0.439, 0.547> | |||
llSetColor(ColorBetween, ALL_SIDES); | llSetColor(ColorBetween, ALL_SIDES); | ||
Line 63: | Line 55: | ||
|notes | |notes | ||
|also | |also | ||
|also_functions | |also_constants= | ||
|also_articles | {{LSL DefineRow||[[PRIM_COLOR]]}} | ||
{{LSL DefineRow||[[CHANGED_COLOR]]}} | |||
|also_functions= | |||
{{LSL DefineRow||[[llGetColor]]}} | |||
{{LSL DefineRow||[[llGetLinkPrimitiveParams]]}} | |||
{{LSL DefineRow||[[llSetColor]]}} | |||
{{LSL DefineRow||[[llSetLinkColor]]}} | |||
|also_articles= | |||
{{LSL DefineRow||[[Color and Scripting]]}} | |||
{{LSL DefineRow||{{LSLGC|Color}}}} | |||
|cat1=Examples | |cat1=Examples | ||
|cat2=User-Defined_Functions | |cat2=User-Defined_Functions |
Revision as of 15:42, 8 January 2014
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
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 from startColor to endColor in the range (0.0 <= percentage <= 100.0) |
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 |