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, valid for resizeType lanczos
lanczos过滤器的lanczoslobe参数,对lanczos的重新sizetype有效
- Default Value:
- 3
- Source:
resizeType
Resize type
for webgl resizeType is just lanczos, for canvas2d can be:
bilinear, hermite, sliceHack, lanczos.
调整类型
对于webgl的resizeType是lanczos,对于canvas2d可以是:
双线性,hermite, sliceHack, lanczos。
- Default Value:
- hermite
- Source:
scaleX
Scale factor for resizing, x axis
调整大小的比例因子,x轴
- Default Value:
- 1
- Source:
scaleY
Scale factor for resizing, y axis
调整大小的比例因子,y轴
- Default Value:
- 1
- Source:
type
Filter type
过滤器类型
- Overrides:
- Default Value:
- Resize
- Source:
Methods
applyTo(options)
Apply the resize filter to the image
Determines whether to use WebGL or Canvas2D based on the options.webgl flag.
应用调整大小过滤器的图像
根据选项决定是使用WebGL还是Canvas2D。webgl国旗。
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Overrides:
- 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.
使用webgl应用此过滤器。
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Inherited From:
- Source:
bilinearFiltering(canvasEl, oW, oH, dW, dH) → {ImageData}
bilinearFiltering
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.
如果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:
generateShader(filterWindow)
Generate vertex and shader sources from the necessary steps numbers
生成顶点和着色源从必要的步骤数字
Parameters:
Name | Type | Description |
---|---|---|
filterWindow |
Number | 组织类 |
- 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:
hermiteFastResize(canvasEl, oW, oH, dW, dH) → {ImageData}
hermiteFastResize
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)
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实现。
仅在图像应用过滤器中使用,以丢弃不会产生效果的过滤器
在图像
其他滤镜可能需要自己的版本(ColorMatrix, HueRotation, gamma, composdfilter)
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | 组织类 |
- Overrides:
- Source:
lanczosResize(canvasEl, oW, oH, dW, dH) → {ImageData}
Filter lanczosResize
过滤器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
|
- Overrides:
- 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:
sliceByTwo(canvasEl, oW, oH, dW, dH) → {ImageData}
Filter sliceByTwo
过滤器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
返回实例的JSON表示
- 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