Class FillGradient
A gradient across a shape's fill. Gradient holds one; each draw call captures its values as it is made.
public sealed class FillGradient
- Inheritance
-
FillGradient
Examples
shapes.FillColor = new Color(90, 190, 255, 120);
shapes.Gradient.Color = new Color(90, 190, 255, 0); // fades to nothing
shapes.Gradient.Direction = Vector2.UnitX; // left to right
shapes.DrawRectangle(center, Vector3.UnitX, Vector3.UnitY, size, outline);
shapes.Gradient.Clear();
Remarks
With a Color set, the fill starts as the batch's fill colour at one extreme of the shape and reaches this colour at the opposite extreme, along Direction. It spans the shape's own extent, so a bar and a disc each run edge to edge whatever their size; a sector spans its wedge, not the disc it was cut from. Alpha counts: a fill that runs to its own colour at alpha 0 fades out.
The gradient is the fill's alone; the border and glow keep their colours. Alpha scales both ends.
Properties
Color
The colour the fill runs to, or null (the default) for a flat fill.
public Color? Color { get; set; }
Property Value
Direction
The direction the gradient runs in, in the shape's local axes - for a 2D shape, world X and Y; for a rectangle on a plane, that plane's axes. Defaults to +Y, bottom to top. The length does not matter.
public Vector2 Direction { get; set; }
Property Value
Methods
Clear()
Back to a flat fill. The direction is kept.
public void Clear()
Set(Color, Vector2?)
Sets the gradient at once.
public void Set(Color color, Vector2? direction = null)