Skip to content

Documentation / spryte / filter

Function: filter() ​

filter(draw, filters, fn): void

Defined in: filters.ts:19

Run fn and draw the result through filters, in order. Same units, transform and clips as outside; nests with masks and targets. Each filter pass is an offscreen pass the size of the destination, so filter groups, not single sprites.

ts
import { blur, filter, grayscale } from "spryte";
filter(draw, [grayscale()], () => drawWorld(draw)); // paused
draw.blend("add");
filter(draw, [blur(4)], () => drawLights(draw)); // glow: a blurred copy added under the sharp one
draw.blend("normal");
drawLights(draw);

Parameters ​

draw ​

Draw

filters ​

readonly Filter[]

fn ​

() => void

Returns ​

void