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
| Factory | Args | Returns | Notes |
|---|---|---|---|
CK.ImageFilter.MakeBlend | mode: BlendMode, bg: ImageFilter | null, fg: ImageFilter | null, cropRect?: Rect | ImageFilter | Combine two filtered sources via a blend mode. |
CK.ImageFilter.MakeBlur | sigmaX, sigmaY: number, tileMode: TileMode, input: ImageFilter | null | ImageFilter | Gaussian blur. |
CK.ImageFilter.MakeColorFilter | cf: ColorFilter, input: ImageFilter | null | ImageFilter | Lift a ColorFilter into the image-filter pipeline. |
CK.ImageFilter.MakeCompose | outer: ImageFilter, inner: ImageFilter | ImageFilter | Run inner first, then outer. |
CK.ImageFilter.MakeDilate | rx, ry: number, input: ImageFilter | null | ImageFilter | Morphological dilation. Thickens shapes. |
CK.ImageFilter.MakeDisplacementMap | xChan, yChan: ColorChannel, scale: number, displacement: ImageFilter, input: ImageFilter | null | ImageFilter | Distort input by reading offsets from displacement's color channels. |
CK.ImageFilter.MakeDropShadow | dx, dy, sigmaX, sigmaY: number, color: Color, input: ImageFilter | null | ImageFilter | Standard drop shadow under the source. |
CK.ImageFilter.MakeDropShadowOnly | dx, dy, sigmaX, sigmaY: number, color: Color, input: ImageFilter | null | ImageFilter | Shadow only — source is hidden. |
CK.ImageFilter.MakeErode | rx, ry: number, input: ImageFilter | null | ImageFilter | Morphological erosion. Thins shapes. |
CK.ImageFilter.MakeImage | img: Image, sampling, src: Rect, dst: Rect | ImageFilter | Use an image as the chain's source. |
CK.ImageFilter.MakeMatrixTransform | matrix: Matrix, sampling, input: ImageFilter | null | ImageFilter | Affine transform on the input pixels. |
CK.ImageFilter.MakeOffset | dx, dy: number, input: ImageFilter | null | ImageFilter | Translate input pixels. |
CK.ImageFilter.MakeShader | shader: Shader | ImageFilter | Promote a shader to an image filter. |
See also
ImageFilter— type, lifecycle, paint integration.Paint.setImageFilter,Canvas.saveLayer.ColorFilter,Shader.