GradientValue
Return value notes
Returns a vector that is the color vector between
start and end depending upon percentage if the vector between can be calculated, else returns <-1, -1, -1>.Specification
// Created by Ugleh Ulrik
vector GradientValue(vector start, vector end, float percentage)
{
list colorParams = [start.x, start.y, start.z, end.x, end.y, end.z];
if (percentage < 0.0
|| 100.0 < percentage
|| llListStatistics(LIST_STAT_MIN, colorParams) < 0.0
|| 1.0 < llListStatistics(LIST_STAT_MAX, colorParams))
{
return <-1, -1, -1>;
}
percentage /= 100.0;// convert to decimal for further use
return start + percentage*(end - start);
}Examples
vector GradientValue(vector start, vector end, float percentage)
{
list colorParams = [start.x, start.y, start.z, end.x, end.y, end.z];
if (percentage < 0.0
|| 100.0 < percentage
|| llListStatistics(LIST_STAT_MIN, colorParams) < 0.0
|| 1.0 < llListStatistics(LIST_STAT_MAX, colorParams))
{
return <-1, -1, -1>;
}
percentage /= 100.0;
return start + percentage*(end - start);
}
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>
if (ColorBetween != <-1, -1, -1>)
llSetColor(ColorBetween, ALL_SIDES);
}
}See also: functions
See also: articles
Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.