Resize
Defined in: src/filters/Resize.ts:52
Resize image filter class
Example
Section titled “Example”const filter = new Resize();object.filters.push(filter);object.applyFilters(canvas.renderAll.bind(canvas));
Extends
Section titled “Extends”BaseFilter
<"Resize"
,ResizeOwnProps
>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Resize(
options?
):Resize
Defined in: src/filters/BaseFilter.ts:57
Constructor
Parameters
Section titled “Parameters”options?
Section titled “options?”object
& Partial
<ResizeOwnProps
> & Record
<string
, any
> = {}
Options object
Returns
Section titled “Returns”Resize
Inherited from
Section titled “Inherited from”Properties
Section titled “Properties”lanczosLobes
Section titled “lanczosLobes”lanczosLobes:
number
Defined in: src/filters/Resize.ts:80
LanczosLobes parameter for lanczos filter, valid for resizeType lanczos
Default
Section titled “Default”
resizeType
Section titled “resizeType”resizeType:
TResizeType
Defined in: src/filters/Resize.ts:59
Resize type for webgl resizeType is just lanczos, for canvas2d can be: bilinear, hermite, sliceHack, lanczos.
Default
Section titled “Default”
scaleX
Section titled “scaleX”scaleX:
number
Defined in: src/filters/Resize.ts:66
Scale factor for resizing, x axis
Default
Section titled “Default”
scaleY
Section titled “scaleY”scaleY:
number
Defined in: src/filters/Resize.ts:73
Scale factor for resizing, y axis
Default
Section titled “Default”
defaults
Section titled “defaults”
static
defaults:ResizeOwnProps
=resizeDefaultValues
Defined in: src/filters/Resize.ts:84
Overrides
Section titled “Overrides”
static
type:string
='Resize'
Defined in: src/filters/Resize.ts:82
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
Section titled “Overrides”uniformLocations
Section titled “uniformLocations”
static
uniformLocations:string
[]
Defined in: src/filters/Resize.ts:86
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
Section titled “Overrides”Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get type():
Name
Defined in: src/filters/BaseFilter.ts:31
Filter type
Default
Section titled “Default”
Returns
Section titled “Returns”Name
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”_setupFrameBuffer()
Section titled “_setupFrameBuffer()”_setupFrameBuffer(
options
):void
Defined in: src/filters/BaseFilter.ts:205
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”_swapTextures()
Section titled “_swapTextures()”_swapTextures(
options
):void
Defined in: src/filters/BaseFilter.ts:232
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”applyTo()
Section titled “applyTo()”applyTo(
options
):void
Defined in: src/filters/Resize.ts:197
Apply the resize filter to the image Determines whether to use WebGL or Canvas2D based on the options.webgl flag.
Parameters
Section titled “Parameters”options
Section titled “options”TWebGLPipelineState
| T2DPipelineState
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”applyTo2d()
Section titled “applyTo2d()”applyTo2d(
this
,options
):void
Defined in: src/filters/Resize.ts:223
Parameters
Section titled “Parameters”ResizeDuring2DResize
options
Section titled “options”Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”applyToForWebgl()
Section titled “applyToForWebgl()”applyToForWebgl(
this
,options
):void
Defined in: src/filters/Resize.ts:163
Parameters
Section titled “Parameters”ResizeDuringWEBGLResize
options
Section titled “options”Returns
Section titled “Returns”void
applyToWebGL()
Section titled “applyToWebGL()”applyToWebGL(
options
):void
Defined in: src/filters/BaseFilter.ts:315
Apply this filter using webgl.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”bilinearFiltering()
Section titled “bilinearFiltering()”bilinearFiltering(
this
,options
,oW
,oH
,dW
,dH
):ImageData
Defined in: src/filters/Resize.ts:417
bilinearFiltering
Parameters
Section titled “Parameters”ResizeDuring2DResize
options
Section titled “options”number
Original Width
number
Original Height
number
Destination Width
number
Destination Height
Returns
Section titled “Returns”ImageData
bindAdditionalTexture()
Section titled “bindAdditionalTexture()”bindAdditionalTexture(
gl
,texture
,textureUnit
):void
Defined in: src/filters/BaseFilter.ts:334
Parameters
Section titled “Parameters”WebGLRenderingContext
texture
Section titled “texture”WebGLTexture
textureUnit
Section titled “textureUnit”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”BaseFilter
.bindAdditionalTexture
createHelpLayer()
Section titled “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
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”createProgram()
Section titled “createProgram()”createProgram(
gl
,fragmentSource
,vertexSource
):object
Defined in: src/filters/BaseFilter.ts:83
Compile this filter’s shader program.
Parameters
Section titled “Parameters”WebGLRenderingContext
The GL canvas context to use for shader compilation.
fragmentSource
Section titled “fragmentSource”string
= ...
fragmentShader source for compilation
vertexSource
Section titled “vertexSource”string
= ...
vertexShader source for compilation
Returns
Section titled “Returns”object
attributeLocations
Section titled “attributeLocations”attributeLocations:
TWebGLAttributeLocationMap
program
Section titled “program”program:
WebGLProgram
uniformLocations
Section titled “uniformLocations”uniformLocations:
TWebGLUniformLocationMap
Inherited from
Section titled “Inherited from”generateShader()
Section titled “generateShader()”generateShader(
filterWindow
):string
Defined in: src/filters/Resize.ts:136
Generate vertex and shader sources from the necessary steps numbers
Parameters
Section titled “Parameters”filterWindow
Section titled “filterWindow”number
Returns
Section titled “Returns”string
getAttributeLocations()
Section titled “getAttributeLocations()”getAttributeLocations(
gl
,program
):TWebGLAttributeLocationMap
Defined in: src/filters/BaseFilter.ts:153
Return a map of attribute names to WebGLAttributeLocation objects.
Parameters
Section titled “Parameters”WebGLRenderingContext
The canvas context used to compile the shader program.
program
Section titled “program”WebGLProgram
The shader program from which to take attribute locations.
Returns
Section titled “Returns”A map of attribute names to attribute locations.
Inherited from
Section titled “Inherited from”BaseFilter
.getAttributeLocations
getCacheKey()
Section titled “getCacheKey()”getCacheKey(
this
):string
Defined in: src/filters/Resize.ts:111
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
Parameters
Section titled “Parameters”ResizeDuringWEBGLResize
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”getFilterWindow()
Section titled “getFilterWindow()”getFilterWindow(
this
):number
Defined in: src/filters/Resize.ts:106
Parameters
Section titled “Parameters”ResizeDuringWEBGLResize
Returns
Section titled “Returns”number
getFragmentSource()
Section titled “getFragmentSource()”getFragmentSource(
this
):string
Defined in: src/filters/Resize.ts:116
Parameters
Section titled “Parameters”ResizeDuringWEBGLResize
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”BaseFilter.getFragmentSource
getTaps()
Section titled “getTaps()”getTaps(
this
):any
[]
Defined in: src/filters/Resize.ts:121
Parameters
Section titled “Parameters”ResizeDuringWEBGLResize
Returns
Section titled “Returns”any
[]
getUniformLocations()
Section titled “getUniformLocations()”getUniformLocations(
gl
,program
):TWebGLUniformLocationMap
Defined in: src/filters/BaseFilter.ts:169
Return a map of uniform names to WebGLUniformLocation objects.
Parameters
Section titled “Parameters”WebGLRenderingContext
The canvas context used to compile the shader program.
program
Section titled “program”WebGLProgram
The shader program from which to take uniform locations.
Returns
Section titled “Returns”A map of uniform names to uniform locations.
Inherited from
Section titled “Inherited from”BaseFilter
.getUniformLocations
getVertexSource()
Section titled “getVertexSource()”getVertexSource():
string
Defined in: src/filters/BaseFilter.ts:72
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”hermiteFastResize()
Section titled “hermiteFastResize()”hermiteFastResize(
this
,options
,oW
,oH
,dW
,dH
):ImageData
Defined in: src/filters/Resize.ts:480
hermiteFastResize
Parameters
Section titled “Parameters”ResizeDuring2DResize
options
Section titled “options”number
Original Width
number
Original Height
number
Destination Width
number
Destination Height
Returns
Section titled “Returns”ImageData
isNeutralState()
Section titled “isNeutralState()”isNeutralState():
boolean
Defined in: src/filters/Resize.ts:205
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
Section titled “Returns”boolean
Overrides
Section titled “Overrides”lanczosCreate()
Section titled “lanczosCreate()”lanczosCreate(
lobes
): (x
) =>number
Defined in: src/filters/Resize.ts:209
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”(
x
):number
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”number
lanczosResize()
Section titled “lanczosResize()”lanczosResize(
this
,options
,oW
,oH
,dW
,dH
):ImageData
Defined in: src/filters/Resize.ts:326
Filter lanczosResize
Parameters
Section titled “Parameters”ResizeDuring2DResize
options
Section titled “options”number
Original Width
number
Original Height
number
Destination Width
number
Destination Height
Returns
Section titled “Returns”ImageData
retrieveShader()
Section titled “retrieveShader()”retrieveShader(
options
):TWebGLProgramCacheItem
Defined in: src/filters/BaseFilter.ts:295
Retrieves the cached shader.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”the compiled program shader
Inherited from
Section titled “Inherited from”sendAttributeData()
Section titled “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
Section titled “Parameters”WebGLRenderingContext
The canvas context used to compile the shader program.
attributeLocations
Section titled “attributeLocations”Record
<string
, number
>
A map of shader attribute names to their locations.
aPositionData
Section titled “aPositionData”Float32Array
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”sendUniformData()
Section titled “sendUniformData()”sendUniformData(
this
,gl
,uniformLocations
):void
Defined in: src/filters/Resize.ts:94
Send data from this filter to its shader program’s uniforms.
Parameters
Section titled “Parameters”ResizeDuringWEBGLResize
WebGLRenderingContext
The GL canvas context used to compile this filter’s shader.
uniformLocations
Section titled “uniformLocations”A map of string uniform names to WebGLUniformLocation objects
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”sliceByTwo()
Section titled “sliceByTwo()”sliceByTwo(
options
,oW
,oH
,dW
,dH
):ImageData
Defined in: src/filters/Resize.ts:261
Filter sliceByTwo
Parameters
Section titled “Parameters”options
Section titled “options”number
Original Width
number
Original Height
number
Destination Width
number
Destination Height
Returns
Section titled “Returns”ImageData
toJSON()
Section titled “toJSON()”toJSON():
object
&ResizeOwnProps
Defined in: src/filters/BaseFilter.ts:407
Returns a JSON representation of an instance
Returns
Section titled “Returns”object
& ResizeOwnProps
JSON
Inherited from
Section titled “Inherited from”toObject()
Section titled “toObject()”toObject():
object
&ResizeOwnProps
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
Section titled “Returns”object
& ResizeOwnProps
Object representation of an instance
Inherited from
Section titled “Inherited from”unbindAdditionalTexture()
Section titled “unbindAdditionalTexture()”unbindAdditionalTexture(
gl
,textureUnit
):void
Defined in: src/filters/BaseFilter.ts:345
Parameters
Section titled “Parameters”WebGLRenderingContext
textureUnit
Section titled “textureUnit”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”BaseFilter
.unbindAdditionalTexture
fromObject()
Section titled “fromObject()”
static
fromObject(__namedParameters
,_options
):Promise
<BaseFilter
<string
,object
,object
>>
Defined in: src/filters/BaseFilter.ts:412
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”Record
<string
, any
>
_options
Section titled “_options”Returns
Section titled “Returns”Promise
<BaseFilter
<string
, object
, object
>>