Skip to content

Blur

Defined in: src/filters/Blur.ts:30

Blur filter class

Example

const filter = new Blur({
blur: 0.5
});
object.filters.push(filter);
object.applyFilters();
canvas.renderAll();

Extends

Constructors

new Blur()

new Blur(options?): Blur

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

Constructor

Parameters

options?

object & Partial<BlurOwnProps> & Record<string, any> = {}

Options object

Returns

Blur

Inherited from

BaseFilter.constructor

Properties

aspectRatio

aspectRatio: number

Defined in: src/filters/Blur.ts:41


blur

blur: number

Defined in: src/filters/Blur.ts:38

blur value, in percentage of image dimensions. specific to keep the image blur constant at different resolutions range between 0 and 1.

Default


horizontal

horizontal: boolean

Defined in: src/filters/Blur.ts:40


defaults

static defaults: BlurOwnProps = blurDefaultValues

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

Overrides

BaseFilter.defaults


type

static type: string = 'Blur'

Defined in: src/filters/Blur.ts:43

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/Blur.ts:47

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

Overrides

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/Blur.ts:53

Apply this filter to the input image data provided.

Determines whether to use WebGL or Canvas2D based on the options.webgl flag.

Parameters

options

TWebGLPipelineState | T2DPipelineState

Returns

void

Overrides

BaseFilter.applyTo


applyTo2d()

applyTo2d(options): void

Defined in: src/filters/Blur.ts:71

Parameters

options

T2DPipelineState

Returns

void

Overrides

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


chooseRightDelta()

chooseRightDelta(): number[]

Defined in: src/filters/Blur.ts:150

choose right value of image percentage to blur with

Returns

number[]

a numeric array with delta values


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


getFragmentSource()

getFragmentSource(): string

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

Returns

string

Overrides

BaseFilter.getFragmentSource


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/Blur.ts:142

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/Blur.ts:134

Send data from this filter to its shader program’s uniforms.

Parameters

gl

WebGLRenderingContext

The GL canvas context used to compile this filter’s shader.

uniformLocations

TWebGLUniformLocationMap

A map of string uniform names to WebGLUniformLocation objects

Returns

void

Overrides

BaseFilter.sendUniformData


simpleBlur()

simpleBlur(__namedParameters): ImageData

Defined in: src/filters/Blur.ts:75

Parameters

__namedParameters

T2DPipelineState

Returns

ImageData


toJSON()

toJSON(): object & BlurOwnProps

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

Returns a JSON representation of an instance

Returns

object & BlurOwnProps

JSON

Inherited from

BaseFilter.toJSON


toObject()

toObject(): object & BlurOwnProps

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

Returns object representation of an instance It will automatically export the default values of a filter, stored in the static defaults property.

Returns

object & BlurOwnProps

Object representation of an instance

Inherited from

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(__namedParameters, _options): Promise<BaseFilter<string>>

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

Parameters

__namedParameters

Record<string, any>

_options

Abortable

Returns

Promise<BaseFilter<string>>

Inherited from

BaseFilter.fromObject