Pixelate
Pixelate filter class
Example
Extends
Constructors
new Pixelate(options)
new Pixelate(
options
?):Pixelate
Constructor
Parameters
• options?: Record
<string
, any
>= {}
Options object
Returns
Inherited from
Source
src/filters/BaseFilter.ts:58
Properties
blocksize
blocksize:
number
Source
src/filters/Pixelate.ts:22
defaults
static
defaults:Partial
<TClassProperties
<Pixelate
>> =pixelateDefaultValues
Overrides
Source
src/filters/Pixelate.ts:26
type
static
type:string
='Pixelate'
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
Source
src/filters/Pixelate.ts:24
Accessors
type
get
type():string
Filter type
Default
Returns
string
Source
src/filters/BaseFilter.ts:25
Methods
_setupFrameBuffer()
_setupFrameBuffer(
options
):void
Parameters
• options: TWebGLPipelineState
Returns
void
Inherited from
Source
src/filters/BaseFilter.ts:190
_swapTextures()
_swapTextures(
options
):void
Parameters
• options: TWebGLPipelineState
Returns
void
Inherited from
Source
src/filters/BaseFilter.ts:217
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
Inherited from
Source
src/filters/BaseFilter.ts:265
applyTo2d()
applyTo2d(
options
):void
Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image.
Parameters
• options: T2DPipelineState
Returns
void
Overrides
Source
src/filters/Pixelate.ts:34
applyToWebGL()
applyToWebGL(
options
):void
Apply this filter using webgl.
Parameters
• options: TWebGLPipelineState
Returns
void
Inherited from
Source
src/filters/BaseFilter.ts:315
bindAdditionalTexture()
bindAdditionalTexture(
gl
,texture
,textureUnit
):void
Parameters
• gl: WebGLRenderingContext
• texture: WebGLTexture
• textureUnit: number
Returns
void
Inherited from
BaseFilter
.bindAdditionalTexture
Source
src/filters/BaseFilter.ts:334
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
Source
src/filters/BaseFilter.ts:380
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
= undefined
fragmentShader source for compilation
• vertexSource: string
= undefined
vertexShader source for compilation
Returns
Object
attributeLocations
attributeLocations:
TWebGLAttributeLocationMap
program
program:
WebGLProgram
uniformLocations
uniformLocations:
TWebGLUniformLocationMap
Inherited from
Source
src/filters/BaseFilter.ts:77
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.
Inherited from
BaseFilter
.getAttributeLocations
Source
src/filters/BaseFilter.ts:146
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
Source
src/filters/BaseFilter.ts:284
getMainParameter()
getMainParameter():
undefined
|string
|number
| (gl
,program
) =>TWebGLAttributeLocationMap
| (options
) =>TWebGLProgramCacheItem
| () =>Object
| () =>Object
| (gl
,program
) =>TWebGLUniformLocationMap
| (gl
,uniformLocations
) =>void
| () =>string
| (options
) =>void
| () =>boolean
| (options
) =>void
| (gl
,fragmentSource
,vertexSource
) =>Object
| (gl
,attributeLocations
,aPositionData
) =>void
| (options
) =>void
| (options
) =>void
| (options
) =>void
| (gl
,texture
,textureUnit
) =>void
| (gl
,textureUnit
) =>void
| () => string | number | ((gl: WebGLRenderingContext, program: WebGLProgram) => TWebGLAttributeLocationMap) | ((options: TWebGLPipelineState) => TWebGLProgramCacheItem) | … 18 more … | undefined | (value
) =>void
| (options
) =>void
Returns
undefined
| string
| number
| (gl
, program
) => TWebGLAttributeLocationMap
| (options
) => TWebGLProgramCacheItem
| () => Object
| () => Object
| (gl
, program
) => TWebGLUniformLocationMap
| (gl
, uniformLocations
) => void
| () => string
| (options
) => void
| () => boolean
| (options
) => void
| (gl
, fragmentSource
, vertexSource
) => Object
| (gl
, attributeLocations
, aPositionData
) => void
| (options
) => void
| (options
) => void
| (options
) => void
| (gl
, texture
, textureUnit
) => void
| (gl
, textureUnit
) => void
| () => string | number | ((gl: WebGLRenderingContext, program: WebGLProgram) => TWebGLAttributeLocationMap) | ((options: TWebGLPipelineState) => TWebGLProgramCacheItem) | … 18 more … | undefined | (value
) => void
| (options
) => void
Inherited from
Source
src/filters/BaseFilter.ts:351
getUniformLocations()
getUniformLocations(
gl
,program
):TWebGLUniformLocationMap
Return WebGL uniform locations for this filter’s shader.
Parameters
• gl: WebGLRenderingContext
The GL canvas context used to compile this filter’s shader.
• program: WebGLProgram
This filter’s compiled shader program.
Returns
Overrides
BaseFilter
.getUniformLocations
Source
src/filters/Pixelate.ts:73
isNeutralState()
isNeutralState():
boolean
Indicate when the filter is not gonna apply changes to the image
Returns
boolean
Overrides
Source
src/filters/Pixelate.ts:59
retrieveShader()
retrieveShader(
options
):TWebGLProgramCacheItem
Retrieves the cached shader.
Parameters
• options: TWebGLPipelineState
Returns
the compiled program shader
Inherited from
Source
src/filters/BaseFilter.ts:295
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
Source
src/filters/BaseFilter.ts:177
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
Overrides
Source
src/filters/Pixelate.ts:90
setMainParameter()
setMainParameter(
value
):void
Parameters
• value: any
Returns
void
Inherited from
Source
src/filters/BaseFilter.ts:355
toJSON()
toJSON():
Object
Returns a JSON representation of an instance
Returns
Object
JSON
type
type:
string
Inherited from
Source
src/filters/BaseFilter.ts:405
toObject()
toObject():
Object
Returns object representation of an instance
Returns
Object
Object representation of an instance
type
type:
string
Inherited from
Source
src/filters/BaseFilter.ts:393
unbindAdditionalTexture()
unbindAdditionalTexture(
gl
,textureUnit
):void
Parameters
• gl: WebGLRenderingContext
• textureUnit: number
Returns
void
Inherited from
BaseFilter
.unbindAdditionalTexture
Source
src/filters/BaseFilter.ts:345
fromObject()
static
fromObject(__namedParameters
,options
):Promise
<BaseFilter
>
Parameters
• __namedParameters: Record
<string
, any
>
• options: Abortable
Returns
Promise
<BaseFilter
>
Inherited from
Source
src/filters/BaseFilter.ts:410