Description
The Evaluate
method of the Gradient
struct is used to determine the color at a specific point in time along the gradient. This method interpolates between the defined color stops to return a Color
that represents the gradient at the given time.
Usage
To use the Evaluate
method, you need to have a Gradient
object with defined color stops. You can then call Evaluate
with a time
parameter, which is a float
value representing the position along the gradient (typically between 0.0 and 1.0). The method will return the interpolated Color
at that position.
Example
// Create a gradient with color stops
var gradient = new Gradient();
gradient.AddColor(0.0f, new Color(1, 0, 0)); // Red at start
gradient.AddColor(1.0f, new Color(0, 0, 1)); // Blue at end
// Evaluate the color at the midpoint of the gradient
time = 0.5f;
Color colorAtMidpoint = gradient.Evaluate(time);
// colorAtMidpoint should be a blend of red and blue, typically purple