Description
The Colors
property of the Gradient
struct in the Sandbox namespace provides access to an immutable list of color stops, represented by ColorFrame
objects. These color stops define the colors at specific points in time along the gradient. The list should be ordered by time to ensure the gradient is rendered correctly.
Usage
Use the Colors
property to retrieve the list of color stops in a gradient. This property is read-only and returns an ImmutableList<ColorFrame>
, ensuring that the list cannot be modified directly. To modify the gradient, use methods such as AddColor
or WithFrames
to create a new gradient with the desired color frames.
Example
// Example of accessing the Colors property
Gradient gradient = new Gradient();
ImmutableList<Gradient.ColorFrame> colorFrames = gradient.Colors;
// Iterate through the color frames
foreach (var colorFrame in colorFrames)
{
Console.WriteLine($"Time: {colorFrame.Time}, Color: {colorFrame.Color}");
}