Table of Contents

Method DrawDashedLine

Namespace
Alternet.Skia
Assembly
Alternet.UI.Common.dll

DrawDashedLine(SKCanvas, SKPoint, SKPoint, SKColor, float, SkiaDashStyle, float[]?, float, bool)

Draws a line on the canvas using a dash style similar to System.Drawing.Pen.DashStyle. This helper creates and configures an SKPaint internally (caller does not own/dispose it).

public static void DrawDashedLine(SKCanvas canvas, SKPoint p1, SKPoint p2, SKColor color, float strokeWidth = 1, SkiaDashStyle dashStyle = SkiaDashStyle.Solid, float[]? customPattern = null, float dashOffset = 0, bool antialiasing = true)

Parameters

canvas SKCanvas

Canvas to draw on (not null).

p1 SKPoint

Start point in canvas coordinates.

p2 SKPoint

End point in canvas coordinates.

color SKColor

Stroke color.

strokeWidth float

Stroke width in canvas units (use 0 for hairline).

dashStyle SkiaDashStyle

Dash style from System.Drawing.Drawing2D.DashStyle.

customPattern float[]

If dashStyle == DashStyle.Custom, this supplies the pattern as device pixels: {on, off, on, off, ...}. If null when Custom is requested, falls back to a dotted pattern.

dashOffset float

Phase/offset in device pixels. This is converted to canvas units using the canvas transform so animation/phase matches device-space expectations.

antialiasing bool

Whether to enable antialiasing on the paint.