The SetLinearGradient
method is used to apply a linear gradient to a bitmap. This method allows you to specify a starting and ending point for the gradient, as well as the gradient itself, which defines the color transitions.
The SetLinearGradient
method is used to apply a linear gradient to a bitmap. This method allows you to specify a starting and ending point for the gradient, as well as the gradient itself, which defines the color transitions.
To use the SetLinearGradient
method, you need to provide the starting and ending points of the gradient as Vector2
objects, and a Gradient
object that defines the color stops and transitions. This method modifies the bitmap by applying the specified gradient between the two points.
// Create a new Bitmap instance Bitmap bitmap = new Bitmap(); // Define the start and end points for the gradient Vector2 startPoint = new Vector2(0, 0); Vector2 endPoint = new Vector2(100, 100); // Create a Gradient object Gradient gradient = new Gradient(); gradient.AddColorStop(0.0f, Color.Red); gradient.AddColorStop(1.0f, Color.Blue); // Apply the linear gradient to the bitmap bitmap.SetLinearGradient(startPoint, endPoint, gradient);