Skip to main content

Function: applyDashPattern()

applyDashPattern(commands, dash): string

Defined in: attributes/shape/path/dash.ts:281

Converts path commands into a dashed SVG path string.

The dash pattern is scaled uniformly so a whole number of cycles spans the path length — this avoids a half-cut dash at the start or end. Each subpath is then flattened and walked, emitting only the "on" runs.

Parameters

commands

PathCommand[]

Path commands to dash.

dash

number[]

Alternating on/off lengths (e.g. [4, 2] = 4 on, 2 off).

Returns

string

An SVG path d string containing only the visible dash segments, or '' when there is nothing to draw.