canvaskit-wasm 0.39
build 2026-04-29
PointMode
How Canvas.drawPoints interprets its input array. Same five points, three different mode values:
const mode = controls.select('mode', ['Points', 'Lines', 'Polygon'], 'Polygon');
// Five (x, y) pairs as a flat number[]. Float32Array works too.
const pts = [60, 60, 160, 200, 240, 60, 320, 200, 380, 130];
const stroke = new CK.Paint();
stroke.setStyle(CK.PaintStyle.Stroke);
stroke.setStrokeWidth(10);
stroke.setStrokeCap(CK.StrokeCap.Round);
stroke.setColor(CK.Color(40, 90, 180, 1));
stroke.setAntiAlias(true);
loop(() => {
canvas.clear(CK.WHITE);
canvas.drawPoints(CK.PointMode[mode()], pts, stroke);
surface.flush();
});
Points draws a stroke-cap-shaped dot at each (x, y) (Round cap → big circles). Lines connects each pair — pts[0..1] to pts[2..3], then pts[4..5] to pts[6..7], etc. Half the points become start, half become end. Polygon connects them all in sequence as a polyline.
All values
| Value | Interpretation |
|---|---|
Points | Each (x, y) draws a single point (a stroke-cap-shaped dot at that position). |
Lines | Pairs of points draw line segments. Array length must be even. |
Polygon | Connect points with line segments in order — like a stroked polyline. |
See also
Canvas.drawPoints.StrokeCap— the cap shape determines how points render.