new RemoveColor()
Remove white filter class
- Source:
- See:
-
- fabric.Image.filters.RemoveColor#initialize for constructor definition
- ImageFilters demo
Example
var filter = new fabric.Image.filters.RemoveColor({
threshold: 0.2,
});
object.filters.push(filter);
object.applyFilters();
canvas.renderAll();
Extends
Members
color
Color to remove, in any format understood by fabric.Color.
- Default Value:
- #FFFFFF
- Source:
distance
distance to actual color, as value up or down from each r,g,b
between 0 and 1
- Source:
fragmentSource
Fragment source for the brightness program
- Source:
type
Filter type
- Overrides:
- Default Value:
- RemoveColor
- Source:
useAlpha
For color to remove inside distance, use alpha channel for a smoother deletion
NOT IMPLEMENTED YET
- 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
|
- Inherited From:
- Source:
applyTo2d(canvasEl)
Applies filter to canvas element
Parameters:
Name | Type | Description |
---|---|---|
canvasEl |
Object | Canvas element to apply filter to |
- Source:
applyToWebGL(options)
Apply this filter using webgl.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Inherited From:
- Source:
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)
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. |
- Overrides:
- Source:
initialize(optionsopt)
Constructor
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Options object |
- Inherited From:
- Source:
isNeutralState(options)
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 |
- Inherited From:
- Source:
retrieveShader(options)
Retrieves the cached shader.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- 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 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 |
- Overrides:
- Source:
setOptions(optionsopt)
Sets filter's properties from options
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Options object |
- Inherited From:
- Source:
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