Skip to content

Composed

Defined in: src/filters/Composed.ts:17

A container class that knows how to apply a sequence of filters to an input image.

Extends

  • BaseFilter<"Composed", ComposedOwnProps, ComposedSerializedProps>

Constructors

new Composed()

new Composed(options): Composed

Defined in: src/filters/Composed.ts:29

Parameters

options

object & Record<string, any> = {}

Returns

Composed

Overrides

BaseFilter.constructor

Properties

subFilters

subFilters: BaseFilter<string>[]

Defined in: src/filters/Composed.ts:25

A non sparse array of filters to apply


defaults

static defaults: Record<string, unknown>

Defined in: src/filters/BaseFilter.ts:51

Inherited from

BaseFilter.defaults


type

static type: string = 'Composed'

Defined in: src/filters/Composed.ts:27

The class type. Used to identify which class this is. This is used for serialization purposes and internally it can be used to identify classes. As a developer you could use instance of Class but to avoid importing all the code and blocking tree shaking we try to avoid doing that.

Overrides

BaseFilter.type


uniformLocations

static uniformLocations: string[] = []

Defined in: src/filters/BaseFilter.ts:49

Contains the uniform locations for the fragment shader. uStepW and uStepH are handled by the BaseFilter, each filter class needs to specify all the one that are needed

Inherited from

BaseFilter.uniformLocations

Accessors

type

Get Signature

get type(): Name

Defined in: src/filters/BaseFilter.ts:31

Filter type

Default
Returns

Name

Inherited from

BaseFilter.type

Methods

_setupFrameBuffer()

_setupFrameBuffer(options): void

Defined in: src/filters/BaseFilter.ts:205

Parameters

options

TWebGLPipelineState

Returns

void

Inherited from

BaseFilter._setupFrameBuffer


_swapTextures()

_swapTextures(options): void

Defined in: src/filters/BaseFilter.ts:232

Parameters

options

TWebGLPipelineState

Returns

void

Inherited from

BaseFilter._swapTextures


applyTo()

applyTo(options): void

Defined in: src/filters/Composed.ts:45

Apply this container’s filters to the input image provided.

Parameters

options

TWebGLPipelineState | T2DPipelineState

Returns

void

Overrides

BaseFilter.applyTo


applyTo2d()

applyTo2d(_options): void

Defined in: src/filters/BaseFilter.ts:275

Parameters

_options

T2DPipelineState

Returns

void

Inherited from

BaseFilter.applyTo2d


applyToWebGL()

applyToWebGL(options): void

Defined in: src/filters/BaseFilter.ts:315

Apply this filter using webgl.

Parameters

options

TWebGLPipelineState

Returns

void

Inherited from

BaseFilter.applyToWebGL


bindAdditionalTexture()

bindAdditionalTexture(gl, texture, textureUnit): void

Defined in: src/filters/BaseFilter.ts:334

Parameters

gl

WebGLRenderingContext

texture

WebGLTexture

textureUnit

number

Returns

void

Inherited from

BaseFilter.bindAdditionalTexture


createHelpLayer()

createHelpLayer(options): void

Defined in: src/filters/BaseFilter.ts:370

If needed by a 2d filter, this functions can create an helper canvas to be used remember that options.targetCanvas is available for use till end of chain.

Parameters

options

T2DPipelineState

Returns

void

Inherited from

BaseFilter.createHelpLayer


createProgram()

createProgram(gl, fragmentSource, vertexSource): object

Defined in: src/filters/BaseFilter.ts:83

Compile this filter’s shader program.

Parameters

gl

WebGLRenderingContext

The GL canvas context to use for shader compilation.

fragmentSource

string = ...

fragmentShader source for compilation

vertexSource

string = ...

vertexShader source for compilation

Returns

object

attributeLocations

attributeLocations: TWebGLAttributeLocationMap

program

program: WebGLProgram

uniformLocations

uniformLocations: TWebGLUniformLocationMap

Inherited from

BaseFilter.createProgram


getAttributeLocations()

getAttributeLocations(gl, program): TWebGLAttributeLocationMap

Defined in: src/filters/BaseFilter.ts:153

Return a map of attribute names to WebGLAttributeLocation objects.

Parameters

gl

WebGLRenderingContext

The canvas context used to compile the shader program.

program

WebGLProgram

The shader program from which to take attribute locations.

Returns

TWebGLAttributeLocationMap

A map of attribute names to attribute locations.

Inherited from

BaseFilter.getAttributeLocations


getCacheKey()

getCacheKey(): string

Defined in: src/filters/BaseFilter.ts:284

Returns a string that represent the current selected shader code for the filter. Used to force recompilation when parameters change or to retrieve the shader from cache

Returns

string

Inherited from

BaseFilter.getCacheKey


getUniformLocations()

getUniformLocations(gl, program): TWebGLUniformLocationMap

Defined in: src/filters/BaseFilter.ts:169

Return a map of uniform names to WebGLUniformLocation objects.

Parameters

gl

WebGLRenderingContext

The canvas context used to compile the shader program.

program

WebGLProgram

The shader program from which to take uniform locations.

Returns

TWebGLUniformLocationMap

A map of uniform names to uniform locations.

Inherited from

BaseFilter.getUniformLocations


getVertexSource()

getVertexSource(): string

Defined in: src/filters/BaseFilter.ts:72

Returns

string

Inherited from

BaseFilter.getVertexSource


isNeutralState()

isNeutralState(): boolean

Defined in: src/filters/Composed.ts:65

Generic isNeutral implementation for one parameter based filters. Used only in image applyFilters to discard filters that will not have an effect on the image Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )

Returns

boolean

Overrides

BaseFilter.isNeutralState


retrieveShader()

retrieveShader(options): TWebGLProgramCacheItem

Defined in: src/filters/BaseFilter.ts:295

Retrieves the cached shader.

Parameters

options

TWebGLPipelineState

Returns

TWebGLProgramCacheItem

the compiled program shader

Inherited from

BaseFilter.retrieveShader


sendAttributeData()

sendAttributeData(gl, attributeLocations, aPositionData): void

Defined in: src/filters/BaseFilter.ts:192

Send attribute data from this filter to its shader program on the GPU.

Parameters

gl

WebGLRenderingContext

The canvas context used to compile the shader program.

attributeLocations

Record<string, number>

A map of shader attribute names to their locations.

aPositionData

Float32Array

Returns

void

Inherited from

BaseFilter.sendAttributeData


sendUniformData()

sendUniformData(_gl, _uniformLocations): void

Defined in: src/filters/BaseFilter.ts:359

Send uniform data from this filter to its shader program on the GPU.

Intended to be overridden by subclasses.

Parameters

_gl

WebGLRenderingContext

The canvas context used to compile the shader program.

_uniformLocations

TWebGLUniformLocationMap

A map of shader uniform names to their locations.

Returns

void

Inherited from

BaseFilter.sendUniformData


toJSON()

toJSON(): object & ComposedSerializedProps

Defined in: src/filters/BaseFilter.ts:407

Returns a JSON representation of an instance

Returns

object & ComposedSerializedProps

JSON

Inherited from

BaseFilter.toJSON


toObject()

toObject(): object

Defined in: src/filters/Composed.ts:58

Serialize this filter into JSON.

Returns

object

A JSON representation of this filter.

subFilters

subFilters: object & object[]

type

type: "Composed"

Overrides

BaseFilter.toObject


unbindAdditionalTexture()

unbindAdditionalTexture(gl, textureUnit): void

Defined in: src/filters/BaseFilter.ts:345

Parameters

gl

WebGLRenderingContext

textureUnit

number

Returns

void

Inherited from

BaseFilter.unbindAdditionalTexture


fromObject()

static fromObject(object, options?): Promise<Composed>

Defined in: src/filters/Composed.ts:77

Deserialize a JSON definition of a ComposedFilter into a concrete instance.

Parameters

object

Record<string, any>

Object to create an instance from

options?
signal

AbortSignal

handle aborting BlendImage filter loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal

Returns

Promise<Composed>

Static

Overrides

BaseFilter.fromObject