Skip to content

HueRotation

Defined in: src/filters/HueRotation.ts:33

HueRotation filter class

const filter = new HueRotation({
rotation: -0.5
});
object.filters.push(filter);
object.applyFilters();
  • ColorMatrix<"HueRotation", HueRotationOwnProps, HueRotationSerializedProps>

new HueRotation(options?): HueRotation

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

Constructor

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

Options object

HueRotation

ColorMatrix.constructor

colorsOnly: boolean

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

Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario to save some calculation

true

ColorMatrix.colorsOnly


matrix: TMatColorMatrix

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

Colormatrix for pixels. array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning outside the -1, 1 range. 0.0039215686 is the part of 1 that get translated to 1 in 2d

array of 20 numbers.

ColorMatrix.matrix


rotation: number

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

HueRotation value, from -1 to 1.


static defaults: HueRotationOwnProps = hueRotationDefaultValues

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

ColorMatrix.defaults


static type: string = 'HueRotation'

Defined in: src/filters/HueRotation.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.

ColorMatrix.type


static uniformLocations: string[]

Defined in: src/filters/ColorMatrix.ts:63

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

ColorMatrix.uniformLocations

get type(): Name

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

Filter type

Name

ColorMatrix.type

_setupFrameBuffer(options): void

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

TWebGLPipelineState

void

ColorMatrix._setupFrameBuffer


_swapTextures(options): void

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

TWebGLPipelineState

void

ColorMatrix._swapTextures


applyTo(options): void

Defined in: src/filters/HueRotation.ts:82

Apply this filter to the input image data provided.

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

TWebGLPipelineState | T2DPipelineState

void

ColorMatrix.applyTo


applyTo2d(options): void

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

Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image.

T2DPipelineState

void

ColorMatrix.applyTo2d


applyToWebGL(options): void

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

Apply this filter using webgl.

TWebGLPipelineState

void

ColorMatrix.applyToWebGL


bindAdditionalTexture(gl, texture, textureUnit): void

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

WebGLRenderingContext

WebGLTexture

number

void

ColorMatrix.bindAdditionalTexture


calculateMatrix(): void

Defined in: src/filters/HueRotation.ts:47

void


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.

T2DPipelineState

void

ColorMatrix.createHelpLayer


createProgram(gl, fragmentSource, vertexSource): object

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

Compile this filter’s shader program.

WebGLRenderingContext

The GL canvas context to use for shader compilation.

string = ...

fragmentShader source for compilation

string = ...

vertexShader source for compilation

object

attributeLocations: TWebGLAttributeLocationMap

program: WebGLProgram

uniformLocations: TWebGLUniformLocationMap

ColorMatrix.createProgram


getAttributeLocations(gl, program): TWebGLAttributeLocationMap

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

Return a map of attribute names to WebGLAttributeLocation objects.

WebGLRenderingContext

The canvas context used to compile the shader program.

WebGLProgram

The shader program from which to take attribute locations.

TWebGLAttributeLocationMap

A map of attribute names to attribute locations.

ColorMatrix.getAttributeLocations


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

string

ColorMatrix.getCacheKey


getFragmentSource(): string

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

string

ColorMatrix.getFragmentSource


getUniformLocations(gl, program): TWebGLUniformLocationMap

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

Return a map of uniform names to WebGLUniformLocation objects.

WebGLRenderingContext

The canvas context used to compile the shader program.

WebGLProgram

The shader program from which to take uniform locations.

TWebGLUniformLocationMap

A map of uniform names to uniform locations.

ColorMatrix.getUniformLocations


getVertexSource(): string

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

string

ColorMatrix.getVertexSource


isNeutralState(): boolean

Defined in: src/filters/HueRotation.ts:78

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 )

boolean

ColorMatrix.isNeutralState


retrieveShader(options): TWebGLProgramCacheItem

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

Retrieves the cached shader.

TWebGLPipelineState

TWebGLProgramCacheItem

the compiled program shader

ColorMatrix.retrieveShader


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.

WebGLRenderingContext

The canvas context used to compile the shader program.

Record<string, number>

A map of shader attribute names to their locations.

Float32Array

void

ColorMatrix.sendAttributeData


sendUniformData(gl, uniformLocations): void

Defined in: src/filters/ColorMatrix.ts:106

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

WebGLRenderingContext

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

TWebGLUniformLocationMap

A map of string uniform names to WebGLUniformLocation objects

void

ColorMatrix.sendUniformData


toJSON(): object & HueRotationSerializedProps

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

Returns a JSON representation of an instance

object & HueRotationSerializedProps

JSON

ColorMatrix.toJSON


toObject(): object

Defined in: src/filters/HueRotation.ts:87

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

object

Object representation of an instance

rotation: number

type: "HueRotation"

ColorMatrix.toObject


unbindAdditionalTexture(gl, textureUnit): void

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

WebGLRenderingContext

number

void

ColorMatrix.unbindAdditionalTexture


static fromObject(__namedParameters, _options): Promise<BaseFilter<string, object, object>>

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

Record<string, any>

Abortable

Promise<BaseFilter<string, object, object>>

ColorMatrix.fromObject