canvaskit-wasm 0.39 build 2026-04-29

Vertices

A pre-baked triangle mesh. Build via CK.MakeVertices(...), draw with canvas.drawVertices(vertices, blendMode, paint). Useful when you want full control over a mesh — your own per-vertex colors, custom UVs for image sampling, or massive geometry that's expensive to recompute.

Vertices is a WASM object — .delete() when done.

// Two triangles, one corner color per vertex. Skia interpolates across the mesh. const positions = new Float32Array([ 60, 60, 360, 60, 60, 200, 360, 200, ]); // Colors must be a *flat* Float32Array (4 floats per vertex) or a Uint32Array // of CK.ColorAsInt values. An array of CK.Color() arrays won't work — Skia // silently falls back to the paint color and you'll get a solid block. const colors = new Float32Array([ ...CK.Color(220, 60, 60, 1), // top-left red ...CK.Color( 60, 200, 130, 1), // top-right green ...CK.Color(220, 220, 60, 1), // bottom-left yellow ...CK.Color( 40, 90, 180, 1), // bottom-right blue ]); const indices = [0, 1, 2, 1, 2, 3]; const mesh = CK.MakeVertices( CK.VertexMode.Triangles, positions, null, colors, indices ); const paint = new CK.Paint(); paint.setColor(CK.WHITE); paint.setAntiAlias(true); loop(() => { canvas.clear(CK.WHITE); // Modulate × white paint = vertex colors come through unchanged. canvas.drawVertices(mesh, CK.BlendMode.Modulate, paint); surface.flush(); });

Members

MemberArgsReturnsNotes
boundsRectBounding rect of all positions.
deletevoidFree the WASM memory. Required.

Static factories

FactoryArgsReturnsNotes
CK.MakeVerticesmode: VertexMode, positions: Float32Array | number[], textureCoords?: Float32Array | number[] | null, colors?: Float32Array | Color[] | null, indices?: Uint16Array | number[] | null, isVolatile?: booleanVerticesBuild a mesh. positions is flat [x0, y0, x1, y1, …]. indices selects triangles; colors drive per-vertex shading; textureCoords drive image sampling when paint has a shader.

See also