Skip to content

Filters ​

Visual effects applied to a node's rendered output.

ts
import { Filter, DrawFilter, BlurFilter, ColorMatrixFilter, OutlineFilter, PixelPerfectOutlineFilter, PixelPerfectInlineFilter, PaletteFilter, CustomShaderFilter, CustomDrawShaderFilter } from "willow";

Filter ​

ts
class Filter

Base class for visual effects applied to a node's rendered output.

Filter: properties ​

MemberDescription
readonly padding: intExtra padding pixels this filter needs around the node's bounds. Defaults to 0.

DrawFilter ​

ts
class DrawFilter extends Filter

Extends Filter.

Base class for per-pixel filters that can be applied at draw time without an offscreen render target.

BlurFilter ​

ts
class BlurFilter extends Filter

Extends Filter.

Separable gaussian-approximating blur filter.

BlurFilter: constructors ​

ts
new BlurFilter(radius?: int)

Creates a new blur filter with the given radius (in pixels).

BlurFilter: properties ​

MemberDescription
radius: intBlur radius in pixels. Non-negative.

BlurFilter: static methods ​

MemberDescription
static create(radius?: int): BlurFilterCreates a new blur filter with the given radius (in pixels).

ColorMatrixFilter ​

ts
class ColorMatrixFilter extends DrawFilter

Extends DrawFilter.

4x5 color matrix transformation filter.

ColorMatrixFilter: constructors ​

ts
new ColorMatrixFilter()

Creates a new color matrix filter initialized to the identity transform.

ColorMatrixFilter: methods ​

MemberDescription
setIdentity(): ColorMatrixFilterResets the matrix to the identity transform.
setGrayscale(): ColorMatrixFilterSets full grayscale transformation (equivalent to setting saturation to 0).
setInvert(): ColorMatrixFilterInverts the RGB color channels.
setBrightness(b: float): ColorMatrixFilterAdjusts brightness by offset in [-1.0, 1.0].
setContrast(c: float): ColorMatrixFilterAdjusts contrast: 1.0 is normal, 0.0 is gray, >1.0 is higher contrast.
setSaturation(s: float): ColorMatrixFilterAdjusts saturation: 1.0 is normal, 0.0 is grayscale.
setHueRotation(radians: float): ColorMatrixFilterRotates hue by the given angle in radians.

OutlineFilter ​

ts
class OutlineFilter extends Filter

Extends Filter.

Multi-pixel outline filter via offset sampling.

OutlineFilter: constructors ​

ts
new OutlineFilter(thickness: int, color: Color)

Creates a new outline filter with the given thickness and tint colour.

OutlineFilter: properties ​

MemberDescription
thickness: intOutline thickness in pixels.
color: ColorOutline tint colour.

OutlineFilter: static methods ​

MemberDescription
static create(thickness: int, color: Color): OutlineFilterCreates a new outline filter with the given thickness and tint colour.

PixelPerfectOutlineFilter ​

ts
class PixelPerfectOutlineFilter extends DrawFilter

Extends DrawFilter.

1-pixel cardinal neighbor outline filter.

PixelPerfectOutlineFilter: constructors ​

ts
new PixelPerfectOutlineFilter(color: Color)

Creates a new pixel-perfect outline filter with the given tint colour.

PixelPerfectOutlineFilter: properties ​

MemberDescription
color: ColorOutline tint colour.

PixelPerfectOutlineFilter: static methods ​

MemberDescription
static create(color: Color): PixelPerfectOutlineFilterCreates a new pixel-perfect outline filter with the given tint colour.

PixelPerfectInlineFilter ​

ts
class PixelPerfectInlineFilter extends DrawFilter

Extends DrawFilter.

1-pixel edge recoloring filter for pixels bordering transparent areas.

PixelPerfectInlineFilter: constructors ​

ts
new PixelPerfectInlineFilter(color: Color)

Creates a new pixel-perfect inline filter with the given colour.

PixelPerfectInlineFilter: properties ​

MemberDescription
color: ColorInset border colour.

PixelPerfectInlineFilter: static methods ​

MemberDescription
static create(color: Color): PixelPerfectInlineFilterCreates a new pixel-perfect inline filter with the given colour.

PaletteFilter ​

ts
class PaletteFilter extends DrawFilter

Extends DrawFilter.

Luminance-based palette remapping filter.

PaletteFilter: constructors ​

ts
new PaletteFilter()

Creates a new palette filter initialized with a grayscale palette.

PaletteFilter: properties ​

MemberDescription
cycleOffset: floatCycle offset for animated palette shifting.

PaletteFilter: methods ​

MemberDescription
setPalette(colors: Color[]): voidSets the 256-entry palette colors.

CustomShaderFilter ​

ts
class CustomShaderFilter extends Filter

Extends Filter.

Spatial filter driven by a user-provided prebuilt shader. The shader is a bgfx fragment binary built ahead of time with shaderc; there is no runtime shader compiler. The source image is sampler 0; named uniforms land in u_params1, sorted by name, each on a vec4 boundary.

CustomShaderFilter: constructors ​

ts
new CustomShaderFilter(shaderPath: string, padding?: int)

Loads <shaderPath>.<backend>.bin (spirv, glsl, essl, metal or dxbc, matching the running renderer) from the project assets. Raises an AssetError when the file is missing, is not a bgfx fragment shader, or was built for another backend.

CustomShaderFilter: methods ​

MemberDescription
setUniform(name: string, value: float | float[]): CustomShaderFilterSets a named uniform to a float or an array of floats; returns this filter.

CustomShaderFilter: static methods ​

MemberDescription
static create(shaderPath: string, padding?: int): CustomShaderFilterSame as the constructor.

CustomDrawShaderFilter ​

ts
class CustomDrawShaderFilter extends DrawFilter

Extends DrawFilter.

Per-pixel filter driven by a user-provided prebuilt shader. Same shader format and uniform packing as CustomShaderFilter; the shader must not read neighbouring pixels.

CustomDrawShaderFilter: constructors ​

ts
new CustomDrawShaderFilter(shaderPath: string)

Loads <shaderPath>.<backend>.bin from the project assets. Raises an AssetError when the file is missing, is not a bgfx fragment shader, or was built for another backend.

CustomDrawShaderFilter: methods ​

MemberDescription
setUniform(name: string, value: float | float[]): CustomDrawShaderFilterSets a named uniform to a float or an array of floats; returns this filter.

CustomDrawShaderFilter: static methods ​

MemberDescription
static create(shaderPath: string): CustomDrawShaderFilterSame as the constructor.