Description
The WithFrames
method allows you to create a new Gradient
instance with a specified list of color frames. This method is useful when you want to define a gradient with specific color stops, each represented by a ColorFrame
object, which includes a color and a position in the gradient.
Usage
To use the WithFrames
method, you need to provide an ImmutableList
of ColorFrame
objects. Each ColorFrame
should specify a color and its corresponding position in the gradient. The method returns a new Gradient
instance configured with these frames.
Example
// Example of using the WithFrames method
var colorFrames = ImmutableList.Create(
new Gradient.ColorFrame { Color = Color.Red, Position = 0.0f },
new Gradient.ColorFrame { Color = Color.Green, Position = 0.5f },
new Gradient.ColorFrame { Color = Color.Blue, Position = 1.0f }
);
Gradient gradient = new Gradient().WithFrames(colorFrames);
// Now you can use the gradient object as needed