Strokeclass

A stroke on a shape's path. Defaults to centered, with half its width on either side. Dimensions and dash phase are in drawing pixels. Defaults to no stroke.

objectStroke
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed struct Sandbox.Stroke

Constructors2

Showing 2 constructors

Methods5

Showing 5 methods

public static Sandbox.Stroke Dashed(Sandbox.Fill fill, float width = 1, float dashLength = 8, float gap = 4, float offset = 0)PUBLICSTATIC

Creates a dashed stroke with butt caps and round joins. Dimensions are in drawing pixels.

ParameterTypeDescription
fillFillColor, gradient or image used to paint the dashes.
width = 1floatCentered stroke width.
dashLength = 8floatLength of each dash along the path's centerline.
gap = 4floatGap between dash runs before extending their caps.
offset = 0floatPhase along the path, in drawing pixels.
Returns:Stroke

public static Sandbox.Stroke Dotted(Sandbox.Fill fill, float width = 1, float gap = 4, float offset = 0)PUBLICSTATIC

Creates round dots with diameter equal to the stroke width. Dimensions are in drawing pixels.

ParameterTypeDescription
fillFillColor, gradient or image used to paint the dots.
width = 1floatDiameter of each dot.
gap = 4floatGap between dot edges. Closed paths fit whole dot periods around their perimeter.
offset = 0floatPhase along the path, in drawing pixels.
Returns:Stroke

public static Sandbox.Stroke Solid(Sandbox.Fill fill, float width = 1)PUBLICSTATIC

Creates a solid stroke with butt caps and round joins. Width is in drawing pixels.

ParameterTypeDescription
fillFill
width = 1float
Returns:Stroke

public Sandbox.Stroke WithCap(Sandbox.Stroke.LineCap cap)PUBLIC

Returns a copy with the specified caps at both ends of open paths and dash runs. Dots stay round.

ParameterTypeDescription
capLineCap
Returns:Stroke

Properties11

Showing 11 properties

public Sandbox.Stroke.StrokeAlignment Sandbox.Stroke.Alignment { get; set; }PUBLICGETSET

Placement on closed shapes. Defaults to Center; ignored by open paths. Inside and outside strokes clip a double-width centered stroke to the selected side, including its dash caps and dots. Pattern distances follow the original boundary.

Returns:StrokeAlignment

public Sandbox.Stroke.LineCap Sandbox.Stroke.Cap { get; set; }PUBLICGETSET

Outward-facing caps at both ends of open paths and dash runs, without shortening heads on short runs. Closed paths have no endpoint caps; dots stay round.

Returns:LineCap

public float Sandbox.Stroke.DashLength { get; set; }PUBLICGETSET

Dash centerline length in drawing pixels. Nonpositive or non-finite values produce a solid stroke.

Returns:float

public Sandbox.Fill Sandbox.Stroke.Fill { get; set; }PUBLICGETSET

Fill mapped across the whole undashed stroke's bounds, shared by all dashes and caps.

Returns:Fill

public float Sandbox.Stroke.Gap { get; set; }PUBLICGETSET

Gap between dash runs or dot edges. Negative gaps become zero; non-finite gaps produce a solid stroke.

Returns:float

public float Sandbox.Stroke.MiterLimit { get; set; }PUBLICGETSET

Maximum miter length divided by half the width, before falling back to bevel. Clamped to at least 1; non-finite values use 4.

Returns:float

public static Sandbox.Stroke Sandbox.Stroke.None { get; set; }PUBLICSTATICGETSET

A disabled stroke. Equivalent to the default value.

Returns:Stroke

public float Sandbox.Stroke.Offset { get; set; }PUBLICGETSET

Phase along the path in drawing pixels. Wraps around the period; non-finite values become zero.

Returns:float

public Sandbox.BorderStyle Sandbox.Stroke.Style { get; set; }PUBLICGETSET

Style and spacing along the path. Generic paths support solid, dashed and dotted strokes; decorative styles render on inside rectangles with solid-color paint and fall back to solid elsewhere. Pattern geometry is cached; its memory cost grows with the number of dashes or dots. Patterns that exceed GPU buffer capacity throw ArgumentOutOfRangeException.

Returns:BorderStyle

public float Sandbox.Stroke.Width { get; set; }PUBLICGETSET

Width in drawing pixels, placed according to Alignment. Nonpositive or non-finite widths disable the stroke.

Returns:float

On this page