Table of Contents

Class DashPattern

Namespace
Stride.CommunityToolkit.Shapes
Assembly
Stride.CommunityToolkit.Shapes.dll

The dash pattern along an outline, in on-screen pixels - constant at any zoom, like the border. Dash holds one; each draw call captures its values as it is made.

public sealed class DashPattern
Inheritance
DashPattern

Examples

shapes.Dash.Length = 6f;          // gap defaults to the same
shapes.Dash.Phase += 30f * dt;    // and the ring turns
shapes.DrawArc(center, radius, 0f, MathF.Tau, color);
shapes.Dash.Clear();

Remarks

Dashes run around circles, rings, annuli, sectors and arcs - starting at the start angle, so a gauge's ticks begin where its sweep does - and along lines. A polygon with more than two corners is always drawn solid; its outline has no single direction to dash along.

Around a circle or arc the pattern is stretched or squeezed by up to half a period so that a whole number of dashes fills the turn, which is what makes a tick ring come out even at any radius instead of ending in a stub. The gaps are cuts through the whole shape, so the fill and glow stop at a dash end exactly as they stop at a sector's edge.

Properties

Gap

The gap between dashes, in pixels. The default 0 makes the gap the same length as the dash.

public float Gap { get; set; }

Property Value

float

Length

Length of each dash, in pixels. The default 0 draws solid.

public float Length { get; set; }

Property Value

float

Phase

Where along the outline the pattern starts, in pixels. Advance it every frame and a dashed ring rotates, a dashed line marches - the cheapest animation a HUD has.

public float Phase { get; set; }

Property Value

float

Methods

Clear()

Back to solid.

public void Clear()

Set(float, float, float)

Sets the whole pattern at once.

public void Set(float length, float gap = 0, float phase = 0)

Parameters

length float

Length of each dash in pixels; 0 for solid.

gap float

Gap in pixels; 0 for the same as the dash.

phase float

Where the pattern starts, in pixels.