Resize

fabric.Image.filters. Resize

new Resize()

Source:
See:
Resize image filter class
Example
var filter = new fabric.Image.filters.Resize();
object.filters.push(filter);
object.applyFilters(canvas.renderAll.bind(canvas));

Extends

Members

lanczosLobes

Source:
Default Value:
  • 3
LanczosLobes parameter for lanczos filter, valid for resizeType lanczos

resizeType

Source:
Default Value:
  • hermite
Resize type for webgl resizeType is just lanczos, for canvas2d can be: bilinear, hermite, sliceHack, lanczos.

scaleX

Source:
Default Value:
  • 1
Scale factor for resizing, x axis

scaleY

Source:
Default Value:
  • 1
Scale factor for resizing, y axis

type

Source:
Overrides:
Default Value:
  • Resize
Filter type

Methods

applyTo(options)

Source:
Overrides:
Apply the resize filter to the image Determines whether to use WebGL or Canvas2D based on the options.webgl flag.
Parameters:
Name Type Description
options Object
Properties
Name Type Description
passes Number The number of filters remaining to be executed
webgl Boolean Whether to use webgl to render the filter.
sourceTexture WebGLTexture The texture setup as the source to be filtered.
targetTexture WebGLTexture The texture where filtered output should be drawn.
context WebGLRenderingContext The GL context used for rendering.
programCache Object A map of compiled shader programs, keyed by filter type.

applyTo2d(canvasEl, scaleX, scaleY)

Source:
Applies filter to canvas element
Parameters:
Name Type Description
canvasEl Object Canvas element to apply filter to
scaleX Number
scaleY Number

applyToWebGL(options)

Source:
Inherited From:
Apply this filter using webgl.
Parameters:
Name Type Description
options Object
Properties
Name Type Description
passes Number The number of filters remaining to be executed
webgl Boolean Whether to use webgl to render the filter.
originalTexture WebGLTexture The texture of the original input image.
sourceTexture WebGLTexture The texture setup as the source to be filtered.
targetTexture WebGLTexture The texture where filtered output should be drawn.
context WebGLRenderingContext The GL context used for rendering.
programCache Object A map of compiled shader programs, keyed by filter type.

bilinearFiltering(canvasEl, oW, oH, dW, dH) → {ImageData}

Source:
bilinearFiltering
Parameters:
Name Type Description
canvasEl Object Canvas element to apply filter to
oW Number Original Width
oH Number Original Height
dW Number Destination Width
dH Number Destination Height
Returns:
Type
ImageData

createHelpLayer()

Source:
Inherited From:
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.

createProgram(gl, fragmentSource, vertexSource)

Source:
Inherited From:
Compile this filter's shader program.
Parameters:
Name Type Description
gl WebGLRenderingContext The GL canvas context to use for shader compilation.
fragmentSource String fragmentShader source for compilation
vertexSource String vertexShader source for compilation

generateShader(filterWindow)

Source:
Generate vertex and shader sources from the necessary steps numbers
Parameters:
Name Type Description
filterWindow Number

getAttributeLocations(gl, program) → {Object}

Source:
Inherited From:
Return a map of attribute names to WebGLAttributeLocation objects.
Parameters:
Name Type Description
gl WebGLRenderingContext The canvas context used to compile the shader program.
program WebGLShaderProgram The shader program from which to take attribute locations.
Returns:
A map of attribute names to attribute locations.
Type
Object

getUniformLocations(gl, program)

Source:
Overrides:
Return WebGL uniform locations for this filter's shader.
Parameters:
Name Type Description
gl WebGLRenderingContext The GL canvas context used to compile this filter's shader.
program WebGLShaderProgram This filter's compiled shader program.

hermiteFastResize(canvasEl, oW, oH, dW, dH) → {ImageData}

Source:
hermiteFastResize
Parameters:
Name Type Description
canvasEl Object Canvas element to apply filter to
oW Number Original Width
oH Number Original Height
dW Number Destination Width
dH Number Destination Height
Returns:
Type
ImageData

initialize(optionsopt)

Source:
Inherited From:
Constructor
Parameters:
Name Type Attributes Description
options Object <optional>
Options object

isNeutralState(options)

Source:
Overrides:
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:
Name Type Description
options Object

lanczosResize(canvasEl, oW, oH, dW, dH) → {ImageData}

Source:
Filter lanczosResize
Parameters:
Name Type Description
canvasEl Object Canvas element to apply filter to
oW Number Original Width
oH Number Original Height
dW Number Destination Width
dH Number Destination Height
Returns:
Type
ImageData

retrieveShader(options)

Source:
Overrides:
Retrieves the cached shader.
Parameters:
Name Type Description
options Object
Properties
Name Type Description
context WebGLRenderingContext The GL context used for rendering.
programCache Object A map of compiled shader programs, keyed by filter type.

sendAttributeData(gl, attributeLocations)

Source:
Inherited From:
Send attribute data from this filter to its shader program on the GPU.
Parameters:
Name Type Description
gl WebGLRenderingContext The canvas context used to compile the shader program.
attributeLocations Object A map of shader attribute names to their locations.

sendUniformData(gl, uniformLocations)

Source:
Overrides:
Send data from this filter to its shader program's uniforms.
Parameters:
Name Type Description
gl WebGLRenderingContext The GL canvas context used to compile this filter's shader.
uniformLocations Object A map of string uniform names to WebGLUniformLocation objects

setOptions(optionsopt)

Source:
Inherited From:
Sets filter's properties from options
Parameters:
Name Type Attributes Description
options Object <optional>
Options object

sliceByTwo(canvasEl, oW, oH, dW, dH) → {ImageData}

Source:
Filter sliceByTwo
Parameters:
Name Type Description
canvasEl Object Canvas element to apply filter to
oW Number Original Width
oH Number Original Height
dW Number Destination Width
dH Number Destination Height
Returns:
Type
ImageData

toJSON() → {Object}

Source:
Inherited From:
Returns a JSON representation of an instance
Returns:
JSON
Type
Object

toObject() → {Object}

Source:
Overrides:
Returns object representation of an instance
Returns:
Object representation of an instance
Type
Object