Class: Resize

fabric.Image.filters.Resize

new Resize()

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

Extends

Members

lanczosLobes

LanczosLobes parameter for lanczos filter
Default Value:
  • 3
Source:

resizeType

Resize type
Default Value:
  • hermite
Source:

scaleX

Scale factor for resizing, x axis
Source:

scaleY

Scale factor for resizing, y axis
Source:

type

Filter type
Overrides:
Default Value:
  • Resize
Source:

Methods

applyTo(options)

Apply this filter to the input image data provided. 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.
Inherited From:
Source:

applyTo2d(canvasEl, scaleX, scaleY)

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

applyToWebGL(options)

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

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

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
Source:
Returns:
Type
ImageData

createHelpLayer()

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

createProgram(gl, fragmentSource, vertexSource)

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

getAttributeLocations(gl, program) → {Object}

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.
Inherited From:
Source:
Returns:
A map of attribute names to attribute locations.
Type
Object

getUniformLocations(gl, program) → {Object}

Return a map of uniform names to WebGLUniformLocation objects. Intended to be overridden by subclasses.
Parameters:
Name Type Description
gl WebGLRenderingContext The canvas context used to compile the shader program.
program WebGLShaderProgram The shader program from which to take uniform locations.
Inherited From:
Source:
Returns:
A map of uniform names to uniform locations.
Type
Object

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

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
Source:
Returns:
Type
ImageData

initialize(optionsopt)

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

isNeutralState(options)

Intentionally left blank, to be overridden in custom filters
Parameters:
Name Type Description
options Object
Inherited From:
Source:

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

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
Source:
Returns:
Type
ImageData

retrieveShader(options)

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

sendAttributeData(gl, attributeLocations)

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

sendUniformData(gl, uniformLocations)

Send uniform data from this filter to its shader program on the GPU. Intended to be overridden by subclasses.
Parameters:
Name Type Description
gl WebGLRenderingContext The canvas context used to compile the shader program.
uniformLocations Object A map of shader uniform names to their locations.
Inherited From:
Source:

setOptions(optionsopt)

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

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

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
Source:
Returns:
Type
ImageData

toJSON() → {Object}

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

toObject() → {Object}

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