Skip to main content

Class: FilterChain

Defined in: attributes/shape/filters/chain.ts:15

Immutable, chainable list of media filters.

Each builder method returns a new FilterChain with the filter appended, so chains are safe to share and branch.

Example

const mx = MX.blur(4).grayscale(0.5);
node.filters = mx; // assign directly
node.filters = [...mx, { type: 'alpha', value: 0.5 }]; // spread into array

Constructors

Constructor

new FilterChain(list?): FilterChain

Defined in: attributes/shape/filters/chain.ts:16

Parameters

list?

MediaFilter[] = []

Returns

FilterChain

Properties

list

list: MediaFilter[] = []

Defined in: attributes/shape/filters/chain.ts:16

Methods

[iterator]()

[iterator](): Generator<MediaFilter, void, unknown>

Defined in: attributes/shape/filters/chain.ts:54

Allows spreading the chain into an array: [...MX.blur(5)].

Returns

Generator<MediaFilter, void, unknown>


alpha()

alpha(value): FilterChain

Defined in: attributes/shape/filters/chain.ts:29

Append an alpha (opacity) filter; value 0 = transparent, 1 = unchanged.

Parameters

value

number

Returns

FilterChain


blur()

blur(radius): FilterChain

Defined in: attributes/shape/filters/chain.ts:19

Append a blur with the given pixel radius.

Parameters

radius

number

Returns

FilterChain


colorAdjustment()

colorAdjustment(settings): FilterChain

Defined in: attributes/shape/filters/chain.ts:39

Append a color-adjustment filter from the given partial settings.

Parameters

settings

Omit<Extract<MediaFilter, { type: "colorAdjustment"; }>, "type">

Returns

FilterChain


colorMatrix()

colorMatrix(matrix): FilterChain

Defined in: attributes/shape/filters/chain.ts:44

Append a raw 4×5 row-major color matrix (Skia format).

Parameters

matrix

number[]

Returns

FilterChain


curves()

curves(points, channel?): FilterChain

Defined in: attributes/shape/filters/chain.ts:49

Append a curves filter from control points ([input, output] pairs) on an optional channel.

Parameters

points

[number, number][]

channel?

CurvesChannel

Returns

FilterChain


exposure()

exposure(value): FilterChain

Defined in: attributes/shape/filters/chain.ts:34

Append an exposure filter; value 1 = unchanged, >1 brighter, <1 darker.

Parameters

value

number

Returns

FilterChain


grayscale()

grayscale(amount): FilterChain

Defined in: attributes/shape/filters/chain.ts:24

Append a grayscale filter with amount in the 0–1 range.

Parameters

amount

number

Returns

FilterChain


toJSON()

toJSON(): MediaFilter[]

Defined in: attributes/shape/filters/chain.ts:59

Serializes to the raw filter array so frameworks that call toJSON get a plain value.

Returns

MediaFilter[]