canvaskit-wasm 0.39 build 2026-04-29

MaskFilter — factories

CK.MaskFilter builds mask-filter objects. A mask filter operates on the alpha mask of a shape — the rasterized silhouette before pixel color is applied. Use it to blur the outline of a shape (soft glow / shadow look) without blurring the fill colors themselves.

Install on a paint with paint.setMaskFilter(filter). Caller deletes via filter.delete().

MakeBlur

MakeBlur(blurStyle, sigma, respectCTM) — Gaussian blur on the alpha mask. BlurStyle controls how the blur sits relative to the shape: Normal (soft halo on both sides), Solid (sharp shape + outer halo), Outer (outer halo only — drops the shape), Inner (inner halo only — fades the inside).

const style = controls.select('style', ['Normal', 'Solid', 'Outer', 'Inner'], 'Normal'); const paint = new CK.Paint(); paint.setColor(CK.Color(220, 60, 60, 1)); paint.setAntiAlias(true); const r = CK.RRectXY(CK.LTRBRect(140, 70, 280, 180), 12, 12); loop(() => { paint.setMaskFilter(CK.MaskFilter.MakeBlur(CK.BlurStyle[style()], 8, true)); canvas.clear(CK.WHITE); canvas.drawRRect(r, paint); surface.flush(); });

The dropdown re-creates the mask filter each frame; in production you'd cache the four styles and switch references.

All factories

FactoryArgsReturnsNotes
CK.MaskFilter.MakeBlurstyle: BlurStyle, sigma: number, respectCTM: booleanMaskFilterGaussian blur on the alpha mask. respectCTM: scale sigma with the current transform.

See also