new Convolute()
- Source:
- See:
-
- fabric.Image.filters.Convolute#initialize for constructor definition
- ImageFilters demo
Adapted from html5rocks article
Examples
Sharpen filter
var filter = new fabric.Image.filters.Convolute({
matrix: [ 0, -1, 0,
-1, 5, -1,
0, -1, 0 ]
});
object.filters.push(filter);
object.applyFilters();
canvas.renderAll();
Blur filter
var filter = new fabric.Image.filters.Convolute({
matrix: [ 1/9, 1/9, 1/9,
1/9, 1/9, 1/9,
1/9, 1/9, 1/9 ]
});
object.filters.push(filter);
object.applyFilters();
canvas.renderAll();
Emboss filter
var filter = new fabric.Image.filters.Convolute({
matrix: [ 1, 1, 1,
1, 0.7, -1,
-1, -1, -1 ]
});
object.filters.push(filter);
object.applyFilters();
canvas.renderAll();
Emboss filter with opaqueness
var filter = new fabric.Image.filters.Convolute({
opaque: true,
matrix: [ 1, 1, 1,
1, 0.7, -1,
-1, -1, -1 ]
});
object.filters.push(filter);
object.applyFilters();
canvas.renderAll();
Extends
Members
fragmentSource
- Source:
Fragment source for the brightness program
type
- Source:
- Overrides:
- Default Value:
- Convolute
Filter type
Methods
applyTo(options)
- Source:
- Inherited From:
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
|
applyTo2d(options)
- Source:
Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
applyToWebGL(options)
- Source:
- Inherited From:
Apply this filter using webgl.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
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 |
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. |
initialize(optionsopt)
- Source:
- Inherited From:
Constructor
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Options object |
isNeutralState(options)
- Source:
- Inherited From:
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 |
retrieveShader(options)
- Source:
- Overrides:
Retrieves the cached shader.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
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 |
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