Table of Contents

Class GradientBrush

Namespace
Icy.Rendering.Brushes
Assembly
IcyUI.dll

Paints a multi-stop linear or radial color gradient.

public class GradientBrush : IBrush
Inheritance
GradientBrush
Implements
Inherited Members
Extension Methods

Remarks

Renders via a CPU-built pixel buffer uploaded through CreateTexture<TColor>(int, int, TColor[])

  • the same texture-upload mechanism used elsewhere in this library (see e.g. font atlas rendering) - rebuilt only when the draw rect's size, Kind, Angle/Center, or GradientStops actually change. Also opportunistically probes GetBuiltInEffect(EffectCode) for GradientEffect once per instance (never more than once, even though every current engine's RenderContext unconditionally throws NotImplementedException for it today) - if a future engine implementation ever returns a working effect instead, this brush picks it up automatically with no API change on either side. Actually implementing that effect is out of scope here.

Properties

Angle

Gets or sets the direction, in degrees, a Linear gradient runs across the draw rect. Ignored for Radial.

public float Angle { get; set; }

Property Value

float

Center

Gets or sets the center, normalized to [0,1] within the draw rect, a Radial gradient radiates from. Ignored for Linear.

public Vector2 Center { get; set; }

Property Value

Vector2

GradientStops

Gets the color stops this gradient interpolates between, in any order - sorted internally by Offset when the buffer is built.

public IList<GradientStop> GradientStops { get; }

Property Value

IList<GradientStop>

Kind

Gets or sets which gradient shape this brush paints.

public GradientKind Kind { get; set; }

Property Value

GradientKind

Methods

Draw(IRenderContext, in TextureRenderingOptions)

Draws a brush on the specified render surface.

public void Draw(IRenderContext context, in TextureRenderingOptions options)

Parameters

context IRenderContext

An instance of the render context to draw brush with..

options TextureRenderingOptions

Options to draw the brush with.