BaseFilter
Extended by
BlendColor
BlendImage
Blur
Brightness
ColorMatrix
Composed
Contrast
Convolute
Gamma
Grayscale
Invert
Noise
Pixelate
RemoveColor
Resize
Saturation
Vibrance
Type Parameters
• Name extends string
• OwnProps extends Record
<string
, any
> = object
Constructors
new BaseFilter()
new BaseFilter<
Name
,OwnProps
>(options
?):BaseFilter
<Name
,OwnProps
>
Constructor
Parameters
• options?: object
& Partial
<OwnProps
> & Record
<string
, any
> = {}
Options object
Returns
BaseFilter
<Name
, OwnProps
>
Defined in
Properties
defaults
static
defaults:Record
<string
,unknown
>
Defined in
type
static
type:string
='BaseFilter'
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.
Defined in
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
Defined in
Accessors
type
get
type():Name
Filter type
Default
Returns
Name
Defined in
Methods
_setupFrameBuffer()
_setupFrameBuffer(
options
):void
Parameters
• options: TWebGLPipelineState
Returns
void
Defined in
_swapTextures()
_swapTextures(
options
):void
Parameters
• options: TWebGLPipelineState
Returns
void
Defined in
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
Defined in
applyTo2d()
applyTo2d(
_options
):void
Parameters
• _options: T2DPipelineState
Returns
void
Defined in
applyToWebGL()
applyToWebGL(
options
):void
Apply this filter using webgl.
Parameters
• options: TWebGLPipelineState
Returns
void
Defined in
bindAdditionalTexture()
bindAdditionalTexture(
gl
,texture
,textureUnit
):void
Parameters
• gl: WebGLRenderingContext
• texture: WebGLTexture
• textureUnit: number
Returns
void
Defined in
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
Defined in
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
Defined in
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
A map of attribute names to attribute locations.
Defined in
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
Defined in
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
A map of uniform names to uniform locations.
Defined in
getVertexSource()
getVertexSource():
string
Returns
string
Defined in
isNeutralState()
isNeutralState(
options
?):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 )
Parameters
• options?: any
Returns
boolean
Defined in
retrieveShader()
retrieveShader(
options
):TWebGLProgramCacheItem
Retrieves the cached shader.
Parameters
• options: TWebGLPipelineState
Returns
the compiled program shader
Defined in
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
Defined in
sendUniformData()
sendUniformData(
_gl
,_uniformLocations
):void
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
Defined in
toJSON()
toJSON():
object
&OwnProps
Returns a JSON representation of an instance
Returns
object
& OwnProps
JSON
Defined in
toObject()
toObject():
object
&OwnProps
Returns object representation of an instance It will automatically export the default values of a filter, stored in the static defaults property.
Returns
object
& OwnProps
Object representation of an instance
Defined in
unbindAdditionalTexture()
unbindAdditionalTexture(
gl
,textureUnit
):void
Parameters
• gl: WebGLRenderingContext
• textureUnit: number
Returns
void
Defined in
fromObject()
static
fromObject(__namedParameters
,_options
):Promise
<BaseFilter
<string
,object
>>
Parameters
• __namedParameters: Record
<string
, any
>
• _options: Abortable
Returns
Promise
<BaseFilter
<string
, object
>>