Table of Contents

Class BoxShadow

Namespace
BSGameLib.UI.Controls
Assembly
BSGameLib.UI.dll

A soft drop shadow behind a control's fill, with the same four parts as a CSS box-shadow: an offset, a blur radius, a spread, and a color.

public class BoxShadow
Inheritance
BoxShadow
Inherited Members

Remarks

Drawn as a stack of 1px rectangle outlines around an opaque core, each carrying the alpha a gaussian blur would leave at that distance from the edge. That needs no shader, no render target and no texture, which is what keeps it usable from a .view.xml the same way a flat color is - the same reasoning as GradientMesh.

The rings never overlap, so each one's alpha is the final alpha at that distance rather than something that accumulates, and the falloff curve can be read straight off Coverage(float). A typical menu shadow (blur 8) is nine shape submissions.

Properties

Blur

The blur diameter in pixels, read as CSS reads it: the shadow fades out over this distance, centered on its edge, so it reaches roughly half of it beyond the control. Zero gives a hard-edged shadow.

public int Blur { get; set; }

Property Value

int

Color

The shadow's color at full strength, alpha included.

public Color Color { get; set; }

Property Value

Color

IsVisible

Whether the shadow would be drawn: it has a colour with some opacity and a blur, spread or offset.

public bool IsVisible { get; }

Property Value

bool

Offset

How far the shadow is displaced from the control, in pixels.

public Point Offset { get; set; }

Property Value

Point

Spread

How much larger (or, when negative, smaller) the shadow is than the control.

public int Spread { get; set; }

Property Value

int

Methods

Draw(IRenderEncoderScope, Rectangle)

Draws the shadow for a control occupying bounds. Call it before the control's own fill so the fill lands on top.

public void Draw(IRenderEncoderScope encoder, Rectangle bounds)

Parameters

encoder IRenderEncoderScope
bounds Rectangle