Skip to content

HueRotation

HueRotation filter class

Example

const filter = new HueRotation({
rotation: -0.5
});
object.filters.push(filter);
object.applyFilters();

Extends

Constructors

new HueRotation()

new HueRotation(options?): HueRotation

Constructor

Parameters

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

Options object

Returns

HueRotation

Inherited from

ColorMatrix.constructor

Defined in

src/filters/BaseFilter.ts:56

Properties

colorsOnly

colorsOnly: boolean

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

Default

true

Inherited from

ColorMatrix.colorsOnly

Defined in

src/filters/ColorMatrix.ts:56


matrix

matrix: TMatColorMatrix

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

Param

array of 20 numbers.

Default

Inherited from

ColorMatrix.matrix

Defined in

src/filters/ColorMatrix.ts:48


rotation

rotation: number

HueRotation value, from -1 to 1.

Defined in

src/filters/HueRotation.ts:31


defaults

static defaults: HueRotationOwnProps = hueRotationDefaultValues

Overrides

ColorMatrix.defaults

Defined in

src/filters/HueRotation.ts:35


type

static type: string = 'HueRotation'

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

ColorMatrix.type

Defined in

src/filters/HueRotation.ts:33


uniformLocations

static uniformLocations: string[]

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

ColorMatrix.uniformLocations

Defined in

src/filters/ColorMatrix.ts:62

Accessors

type

get type(): Name

Filter type

Default

Returns

Name

Inherited from

ColorMatrix.type

Defined in

src/filters/BaseFilter.ts:30

Methods

_setupFrameBuffer()

_setupFrameBuffer(options): void

Parameters

options: TWebGLPipelineState

Returns

void

Inherited from

ColorMatrix._setupFrameBuffer

Defined in

src/filters/BaseFilter.ts:204


_swapTextures()

_swapTextures(options): void

Parameters

options: TWebGLPipelineState

Returns

void

Inherited from

ColorMatrix._swapTextures

Defined in

src/filters/BaseFilter.ts:231


applyTo()

applyTo(options): void

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

ColorMatrix.applyTo

Defined in

src/filters/HueRotation.ts:60


applyTo2d()

applyTo2d(options): void

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

Parameters

options: T2DPipelineState

Returns

void

Inherited from

ColorMatrix.applyTo2d

Defined in

src/filters/ColorMatrix.ts:74


applyToWebGL()

applyToWebGL(options): void

Apply this filter using webgl.

Parameters

options: TWebGLPipelineState

Returns

void

Inherited from

ColorMatrix.applyToWebGL

Defined in

src/filters/BaseFilter.ts:314


bindAdditionalTexture()

bindAdditionalTexture(gl, texture, textureUnit): void

Parameters

gl: WebGLRenderingContext

texture: WebGLTexture

textureUnit: number

Returns

void

Inherited from

ColorMatrix.bindAdditionalTexture

Defined in

src/filters/BaseFilter.ts:333


calculateMatrix()

calculateMatrix(): void

Returns

void

Defined in

src/filters/HueRotation.ts:37


createHelpLayer()

createHelpLayer(options): void

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

ColorMatrix.createHelpLayer

Defined in

src/filters/BaseFilter.ts:369


createProgram()

createProgram(gl, fragmentSource, vertexSource): object

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

ColorMatrix.createProgram

Defined in

src/filters/BaseFilter.ts:82


getAttributeLocations()

getAttributeLocations(gl, program): TWebGLAttributeLocationMap

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

ColorMatrix.getAttributeLocations

Defined in

src/filters/BaseFilter.ts:152


getCacheKey()

getCacheKey(): string

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

ColorMatrix.getCacheKey

Defined in

src/filters/BaseFilter.ts:283


getFragmentSource()

getFragmentSource(): string

Returns

string

Inherited from

ColorMatrix.getFragmentSource

Defined in

src/filters/ColorMatrix.ts:64


getUniformLocations()

getUniformLocations(gl, program): TWebGLUniformLocationMap

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

ColorMatrix.getUniformLocations

Defined in

src/filters/BaseFilter.ts:168


getVertexSource()

getVertexSource(): string

Returns

string

Inherited from

ColorMatrix.getVertexSource

Defined in

src/filters/BaseFilter.ts:71


isNeutralState()

isNeutralState(): boolean

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

ColorMatrix.isNeutralState

Defined in

src/filters/HueRotation.ts:56


retrieveShader()

retrieveShader(options): TWebGLProgramCacheItem

Retrieves the cached shader.

Parameters

options: TWebGLPipelineState

Returns

TWebGLProgramCacheItem

the compiled program shader

Inherited from

ColorMatrix.retrieveShader

Defined in

src/filters/BaseFilter.ts:294


sendAttributeData()

sendAttributeData(gl, attributeLocations, aPositionData): void

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

ColorMatrix.sendAttributeData

Defined in

src/filters/BaseFilter.ts:191


sendUniformData()

sendUniformData(gl, uniformLocations): void

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

Inherited from

ColorMatrix.sendUniformData

Defined in

src/filters/ColorMatrix.ts:106


toJSON()

toJSON(): object & HueRotationOwnProps

Returns a JSON representation of an instance

Returns

object & HueRotationOwnProps

JSON

Inherited from

ColorMatrix.toJSON

Defined in

src/filters/BaseFilter.ts:406


toObject()

toObject(): object

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

Returns

object

Object representation of an instance

rotation

rotation: number

type

type: "HueRotation"

Overrides

ColorMatrix.toObject

Defined in

src/filters/HueRotation.ts:66


unbindAdditionalTexture()

unbindAdditionalTexture(gl, textureUnit): void

Parameters

gl: WebGLRenderingContext

textureUnit: number

Returns

void

Inherited from

ColorMatrix.unbindAdditionalTexture

Defined in

src/filters/BaseFilter.ts:344


fromObject()

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

Parameters

__namedParameters: Record<string, any>

_options: Abortable

Returns

Promise<BaseFilter<string, object>>

Inherited from

ColorMatrix.fromObject

Defined in

src/filters/BaseFilter.ts:411