canvaskit-wasm 0.39 build 2026-04-29

ImageFilter — factories

CK.ImageFilter is a namespace of factories that build ImageFilter objects. For the concept (what an image filter is, how to install it, how chains work), see the type page. This page lists every factory with a small runnable example.

Each factory returns a fresh ImageFilter — caller deletes when done. Filters chain via an input?: ImageFilter | null argument: pass another filter to feed its output into this one, or null to use the source pixels directly.

MakeBlur

MakeBlur(sigmaX, sigmaY, tileMode, input) — Gaussian blur. Sigma is the standard deviation in pixels; visible radius is roughly 3×sigma. tileMode controls how the blur samples beyond the source bounds (Decal fades to transparent, Clamp repeats the edge, Repeat/Mirror tile).

Error: Line 1: Unexpected identifier

MakeDropShadow

MakeDropShadow(dx, dy, sigmaX, sigmaY, color, input) — shadow under the source. The source draws too. Use MakeDropShadowOnly when stacking shadow and main draw separately.

const shadow = CK.ImageFilter.MakeDropShadow(6, 8, 4, 4, CK.Color(0, 0, 0, 0.5), null); const paint = new CK.Paint(); paint.setColor(CK.Color(220, 60, 60, 1)); paint.setAntiAlias(true); paint.setImageFilter(shadow); const r = CK.RRectXY(CK.LTRBRect(120, 50, 300, 200), 18, 18); loop(() => { canvas.clear(CK.WHITE); canvas.drawRRect(r, paint); surface.flush(); });

MakeColorFilter

MakeColorFilter(cf, input) — lifts a ColorFilter into the image-filter pipeline. The color filter runs against input's output pixels (or the source if input is null).

Error: Line 1: Unexpected identifier

MakeCompose

MakeCompose(outer, inner) — explicit composition. Equivalent to passing inner as outer's input. Use when you want to construct a chain from independently-built filters.

Error: Line 1: Unexpected identifier

MakeBlend

MakeBlend(mode, bg, fg, cropRect?) — combines two filtered sources via a BlendMode. Useful for compositing layered effects.

Error: Line 1: Unexpected identifier

MakeOffset

MakeOffset(dx, dy, input) — translate the input pixels by (dx, dy). Pairs naturally with MakeBlend to build per-channel offset effects.

Error: Line 1: Unexpected identifier

MakeDilate / MakeErode

MakeDilate(rx, ry, input) — each pixel becomes the per-channel maximum of its neighbourhood; thickens shapes. MakeErode(rx, ry, input) — minimum; thins shapes. (rx, ry) are the kernel half-widths in pixels.

Error: Line 1: Unexpected identifier

MakeImage

MakeImage(img, sampling, src, dst) — read pixels from a CanvasKit Image as a filter source. Useful as the bottom of a chain when you want the chain to operate on a known image rather than the paint's own draw.

Error: Line 1: Unexpected identifier

MakeMatrixTransform

MakeMatrixTransform(matrix, sampling, input) — affine transform on the input pixels (rotate, scale, skew). Sampling controls pixel resampling quality.

Error: Line 1: Unexpected identifier

All factories

FactoryArgsReturnsNotes
CK.ImageFilter.MakeBlendmode: BlendMode, bg: ImageFilter | null, fg: ImageFilter | null, cropRect?: RectImageFilterCombine two filtered sources via a blend mode.
CK.ImageFilter.MakeBlursigmaX, sigmaY: number, tileMode: TileMode, input: ImageFilter | nullImageFilterGaussian blur.
CK.ImageFilter.MakeColorFiltercf: ColorFilter, input: ImageFilter | nullImageFilterLift a ColorFilter into the image-filter pipeline.
CK.ImageFilter.MakeComposeouter: ImageFilter, inner: ImageFilterImageFilterRun inner first, then outer.
CK.ImageFilter.MakeDilaterx, ry: number, input: ImageFilter | nullImageFilterMorphological dilation. Thickens shapes.
CK.ImageFilter.MakeDisplacementMapxChan, yChan: ColorChannel, scale: number, displacement: ImageFilter, input: ImageFilter | nullImageFilterDistort input by reading offsets from displacement's color channels.
CK.ImageFilter.MakeDropShadowdx, dy, sigmaX, sigmaY: number, color: Color, input: ImageFilter | nullImageFilterStandard drop shadow under the source.
CK.ImageFilter.MakeDropShadowOnlydx, dy, sigmaX, sigmaY: number, color: Color, input: ImageFilter | nullImageFilterShadow only — source is hidden.
CK.ImageFilter.MakeEroderx, ry: number, input: ImageFilter | nullImageFilterMorphological erosion. Thins shapes.
CK.ImageFilter.MakeImageimg: Image, sampling, src: Rect, dst: RectImageFilterUse an image as the chain's source.
CK.ImageFilter.MakeMatrixTransformmatrix: Matrix, sampling, input: ImageFilter | nullImageFilterAffine transform on the input pixels.
CK.ImageFilter.MakeOffsetdx, dy: number, input: ImageFilter | nullImageFilterTranslate input pixels.
CK.ImageFilter.MakeShadershader: ShaderImageFilterPromote a shader to an image filter.

See also