new ColorMatrix()
Color Matrix filter class
彩色矩阵滤镜类
- Source:
- See:
Example
var filter = new fabric.Image.filters.ColorMatrix({
matrix: [
1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,
-0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,
-0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,
0, 0, 0, 1, 0
]
});
object.filters.push(filter);
object.applyFilters();
Extends
Members
colorsOnly
Lock the colormatrix on the color part, skipping alpha, manly for non webgl scenario
to save some calculation
锁定颜色部分的颜色矩阵,跳过alpha,主要用于非webgl场景
为了节省一些计算
- Source:
matrix
Colormatrix for pixels.
array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning
outside the -1, 1 range.
0.0039215686 is the part of 1 that get translated to 1 in 2d
像素的颜色矩阵。
包含20个浮点数的数组。4、9、14、19位的数字含义不明确
在- 1,1范围之外。
0.0039215686是1在2d中转换成1的部分
- Default Value:
[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]
- Source:
type
Filter type
过滤器类型
- Overrides:
- Default Value:
- ColorMatrix
- 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.
将此过滤器应用于所提供的输入图像数据。
根据选项确定是使用WebGL还是Canvas2D。webgl国旗。
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Inherited From:
- Source:
applyTo2d(options)
Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image.
将ColorMatrix操作应用于表示图像像素的Uint8Array。
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
applyToWebGL(options)
Apply this filter using webgl.
使用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.
如果2d过滤器需要,这个函数可以创建一个要使用的辅助画布
记住这些选项。targetCanvas可以使用,直到链结束。
- 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.用于着色器编译的GL画布上下文。 |
fragmentSource |
String | fragmentShader source for compilationfragmentShader编译源 |
vertexSource |
String | vertexShader source for compilationvertexShader编译源 |
- Inherited From:
- Source:
getAttributeLocations(gl, program) → {Object}
Return a map of attribute names to WebGLAttributeLocation objects.
返回属性名映射到WebGLAttributeLocation对象。
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.
返回这个过滤器的着色器的WebGL统一位置。
Parameters:
Name | Type | Description |
---|---|---|
gl |
WebGLRenderingContext | The GL canvas context used to compile this filter's shader.GL画布上下文用于编译这个过滤器的着色器。 |
program |
WebGLShaderProgram | This filter's compiled shader program.这个过滤器的编译着色程序。 |
- Overrides:
- Source:
initialize(optionsopt)
Constructor
构造函数
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Options object选择对象 |
- Overrides:
- 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 )
基于一个参数的过滤器的通用isNeutral实现。
仅在image applyFilters中使用,用于丢弃不起作用的过滤器
在图像上
其他滤镜可能需要自己的版本(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.
将属性数据从这个过滤器发送到它在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.GL画布上下文用于编译这个过滤器的着色器。 |
uniformLocations |
Object | A map of string uniform names to WebGLUniformLocation objects字符串统一名称到WebGLUniformLocation对象的映射 |
- 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
返回实例的JSON表示形式
- Inherited From:
- Source:
Returns:
JSON
- Type
- Object
toObject() → {Object}
Returns object representation of an instance
返回实例的对象表示形式
- Inherited From:
- Source:
Returns:
Object representation of an instance
- Type
- Object