@postermywall/fabricjs-2 6.0.0-rc2.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -1
- package/dist/index.js +229 -491
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +229 -491
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +229 -491
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +229 -491
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.json.min.mjs +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/canvas/Canvas.d.ts.map +1 -1
- package/dist/src/canvas/Canvas.min.mjs +1 -1
- package/dist/src/canvas/Canvas.min.mjs.map +1 -1
- package/dist/src/canvas/Canvas.mjs +8 -9
- package/dist/src/canvas/Canvas.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.d.ts +1 -1
- package/dist/src/canvas/SelectableCanvas.d.ts.map +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.mjs +1 -1
- package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvas.d.ts +4 -4
- package/dist/src/canvas/StaticCanvas.d.ts.map +1 -1
- package/dist/src/canvas/StaticCanvas.min.mjs +1 -1
- package/dist/src/canvas/StaticCanvas.min.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvas.mjs +0 -13
- package/dist/src/canvas/StaticCanvas.mjs.map +1 -1
- package/dist/src/color/Color.d.ts +1 -0
- package/dist/src/color/Color.d.ts.map +1 -1
- package/dist/src/color/Color.min.mjs +1 -1
- package/dist/src/color/Color.min.mjs.map +1 -1
- package/dist/src/color/Color.mjs +3 -1
- package/dist/src/color/Color.mjs.map +1 -1
- package/dist/src/filters/BaseFilter.d.ts +16 -23
- package/dist/src/filters/BaseFilter.d.ts.map +1 -1
- package/dist/src/filters/BaseFilter.min.mjs +1 -1
- package/dist/src/filters/BaseFilter.min.mjs.map +1 -1
- package/dist/src/filters/BaseFilter.mjs +24 -41
- package/dist/src/filters/BaseFilter.mjs.map +1 -1
- package/dist/src/filters/BlendColor.d.ts +13 -24
- package/dist/src/filters/BlendColor.d.ts.map +1 -1
- package/dist/src/filters/BlendColor.min.mjs +1 -1
- package/dist/src/filters/BlendColor.min.mjs.map +1 -1
- package/dist/src/filters/BlendColor.mjs +1 -25
- package/dist/src/filters/BlendColor.mjs.map +1 -1
- package/dist/src/filters/BlendImage.d.ts +18 -19
- package/dist/src/filters/BlendImage.d.ts.map +1 -1
- package/dist/src/filters/BlendImage.min.mjs +1 -1
- package/dist/src/filters/BlendImage.min.mjs.map +1 -1
- package/dist/src/filters/BlendImage.mjs +13 -24
- package/dist/src/filters/BlendImage.mjs.map +1 -1
- package/dist/src/filters/Blur.d.ts +10 -12
- package/dist/src/filters/Blur.d.ts.map +1 -1
- package/dist/src/filters/Blur.min.mjs +1 -1
- package/dist/src/filters/Blur.min.mjs.map +1 -1
- package/dist/src/filters/Blur.mjs +5 -14
- package/dist/src/filters/Blur.mjs.map +1 -1
- package/dist/src/filters/Boilerplate.d.ts +11 -13
- package/dist/src/filters/Boilerplate.d.ts.map +1 -1
- package/dist/src/filters/Brightness.d.ts +10 -12
- package/dist/src/filters/Brightness.d.ts.map +1 -1
- package/dist/src/filters/Brightness.min.mjs +1 -1
- package/dist/src/filters/Brightness.min.mjs.map +1 -1
- package/dist/src/filters/Brightness.mjs +4 -16
- package/dist/src/filters/Brightness.mjs.map +1 -1
- package/dist/src/filters/Canvas2dFilterBackend.d.ts +1 -1
- package/dist/src/filters/Canvas2dFilterBackend.d.ts.map +1 -1
- package/dist/src/filters/Canvas2dFilterBackend.min.mjs.map +1 -1
- package/dist/src/filters/Canvas2dFilterBackend.mjs.map +1 -1
- package/dist/src/filters/ColorMatrix.d.ts +17 -15
- package/dist/src/filters/ColorMatrix.d.ts.map +1 -1
- package/dist/src/filters/ColorMatrix.min.mjs +1 -1
- package/dist/src/filters/ColorMatrix.min.mjs.map +1 -1
- package/dist/src/filters/ColorMatrix.mjs +7 -27
- package/dist/src/filters/ColorMatrix.mjs.map +1 -1
- package/dist/src/filters/ColorMatrixFilters.d.ts +63 -497
- package/dist/src/filters/ColorMatrixFilters.d.ts.map +1 -1
- package/dist/src/filters/ColorMatrixFilters.min.mjs +1 -1
- package/dist/src/filters/ColorMatrixFilters.min.mjs.map +1 -1
- package/dist/src/filters/ColorMatrixFilters.mjs +13 -8
- package/dist/src/filters/ColorMatrixFilters.mjs.map +1 -1
- package/dist/src/filters/Composed.d.ts +11 -10
- package/dist/src/filters/Composed.d.ts.map +1 -1
- package/dist/src/filters/Composed.min.mjs +1 -1
- package/dist/src/filters/Composed.min.mjs.map +1 -1
- package/dist/src/filters/Composed.mjs +7 -12
- package/dist/src/filters/Composed.mjs.map +1 -1
- package/dist/src/filters/Contrast.d.ts +10 -12
- package/dist/src/filters/Contrast.d.ts.map +1 -1
- package/dist/src/filters/Contrast.min.mjs +1 -1
- package/dist/src/filters/Contrast.min.mjs.map +1 -1
- package/dist/src/filters/Contrast.mjs +6 -17
- package/dist/src/filters/Contrast.mjs.map +1 -1
- package/dist/src/filters/Convolute.d.ts +11 -14
- package/dist/src/filters/Convolute.d.ts.map +1 -1
- package/dist/src/filters/Convolute.min.mjs +1 -1
- package/dist/src/filters/Convolute.min.mjs.map +1 -1
- package/dist/src/filters/Convolute.mjs +1 -15
- package/dist/src/filters/Convolute.mjs.map +1 -1
- package/dist/src/filters/Gamma.d.ts +17 -14
- package/dist/src/filters/Gamma.d.ts.map +1 -1
- package/dist/src/filters/Gamma.min.mjs +1 -1
- package/dist/src/filters/Gamma.min.mjs.map +1 -1
- package/dist/src/filters/Gamma.mjs +20 -24
- package/dist/src/filters/Gamma.mjs.map +1 -1
- package/dist/src/filters/Grayscale.d.ts +8 -11
- package/dist/src/filters/Grayscale.d.ts.map +1 -1
- package/dist/src/filters/Grayscale.min.mjs +1 -1
- package/dist/src/filters/Grayscale.min.mjs.map +1 -1
- package/dist/src/filters/Grayscale.mjs +2 -14
- package/dist/src/filters/Grayscale.mjs.map +1 -1
- package/dist/src/filters/HueRotation.d.ts +11 -5
- package/dist/src/filters/HueRotation.d.ts.map +1 -1
- package/dist/src/filters/HueRotation.min.mjs +1 -1
- package/dist/src/filters/HueRotation.min.mjs.map +1 -1
- package/dist/src/filters/HueRotation.mjs +10 -5
- package/dist/src/filters/HueRotation.mjs.map +1 -1
- package/dist/src/filters/Invert.d.ts +10 -13
- package/dist/src/filters/Invert.d.ts.map +1 -1
- package/dist/src/filters/Invert.min.mjs +1 -1
- package/dist/src/filters/Invert.min.mjs.map +1 -1
- package/dist/src/filters/Invert.mjs +2 -15
- package/dist/src/filters/Invert.mjs.map +1 -1
- package/dist/src/filters/Noise.d.ts +9 -20
- package/dist/src/filters/Noise.d.ts.map +1 -1
- package/dist/src/filters/Noise.min.mjs +1 -1
- package/dist/src/filters/Noise.min.mjs.map +1 -1
- package/dist/src/filters/Noise.mjs +4 -27
- package/dist/src/filters/Noise.mjs.map +1 -1
- package/dist/src/filters/Pixelate.d.ts +8 -12
- package/dist/src/filters/Pixelate.d.ts.map +1 -1
- package/dist/src/filters/Pixelate.min.mjs +1 -1
- package/dist/src/filters/Pixelate.min.mjs.map +1 -1
- package/dist/src/filters/Pixelate.mjs +2 -16
- package/dist/src/filters/Pixelate.mjs.map +1 -1
- package/dist/src/filters/RemoveColor.d.ts +12 -23
- package/dist/src/filters/RemoveColor.d.ts.map +1 -1
- package/dist/src/filters/RemoveColor.min.mjs +1 -1
- package/dist/src/filters/RemoveColor.min.mjs.map +1 -1
- package/dist/src/filters/RemoveColor.mjs +2 -25
- package/dist/src/filters/RemoveColor.mjs.map +1 -1
- package/dist/src/filters/Resize.d.ts +14 -30
- package/dist/src/filters/Resize.d.ts.map +1 -1
- package/dist/src/filters/Resize.min.mjs +1 -1
- package/dist/src/filters/Resize.min.mjs.map +1 -1
- package/dist/src/filters/Resize.mjs +3 -30
- package/dist/src/filters/Resize.mjs.map +1 -1
- package/dist/src/filters/Saturation.d.ts +9 -12
- package/dist/src/filters/Saturation.d.ts.map +1 -1
- package/dist/src/filters/Saturation.min.mjs +1 -1
- package/dist/src/filters/Saturation.min.mjs.map +1 -1
- package/dist/src/filters/Saturation.mjs +8 -20
- package/dist/src/filters/Saturation.mjs.map +1 -1
- package/dist/src/filters/Vibrance.d.ts +10 -13
- package/dist/src/filters/Vibrance.d.ts.map +1 -1
- package/dist/src/filters/Vibrance.min.mjs +1 -1
- package/dist/src/filters/Vibrance.min.mjs.map +1 -1
- package/dist/src/filters/Vibrance.mjs +6 -18
- package/dist/src/filters/Vibrance.mjs.map +1 -1
- package/dist/src/filters/WebGLFilterBackend.d.ts +1 -1
- package/dist/src/filters/WebGLFilterBackend.d.ts.map +1 -1
- package/dist/src/filters/WebGLFilterBackend.min.mjs.map +1 -1
- package/dist/src/filters/WebGLFilterBackend.mjs.map +1 -1
- package/dist/src/filters/shaders/blendImage.d.ts +1 -0
- package/dist/src/filters/shaders/blendImage.d.ts.map +1 -1
- package/dist/src/filters/shaders/blendImage.min.mjs +1 -1
- package/dist/src/filters/shaders/blendImage.min.mjs.map +1 -1
- package/dist/src/filters/shaders/blendImage.mjs +2 -1
- package/dist/src/filters/shaders/blendImage.mjs.map +1 -1
- package/dist/src/filters/typedefs.d.ts +22 -0
- package/dist/src/filters/typedefs.d.ts.map +1 -1
- package/dist/src/parser/elements_parser.d.ts +1 -1
- package/dist/src/parser/elements_parser.d.ts.map +1 -1
- package/dist/src/parser/elements_parser.min.mjs.map +1 -1
- package/dist/src/parser/elements_parser.mjs.map +1 -1
- package/dist/src/shapes/ActiveSelection.d.ts +1 -1
- package/dist/src/shapes/ActiveSelection.d.ts.map +1 -1
- package/dist/src/shapes/ActiveSelection.min.mjs +1 -1
- package/dist/src/shapes/ActiveSelection.min.mjs.map +1 -1
- package/dist/src/shapes/ActiveSelection.mjs +13 -10
- package/dist/src/shapes/ActiveSelection.mjs.map +1 -1
- package/dist/src/shapes/Group.d.ts +9 -0
- package/dist/src/shapes/Group.d.ts.map +1 -1
- package/dist/src/shapes/Group.min.mjs +1 -1
- package/dist/src/shapes/Group.min.mjs.map +1 -1
- package/dist/src/shapes/Group.mjs +10 -1
- package/dist/src/shapes/Group.mjs.map +1 -1
- package/dist/src/shapes/Image.d.ts +4 -4
- package/dist/src/shapes/Image.d.ts.map +1 -1
- package/dist/src/shapes/Image.min.mjs.map +1 -1
- package/dist/src/shapes/Image.mjs.map +1 -1
- package/dist/src/shapes/Object/InteractiveObject.d.ts +3 -0
- package/dist/src/shapes/Object/InteractiveObject.d.ts.map +1 -1
- package/dist/src/shapes/Object/InteractiveObject.min.mjs +1 -1
- package/dist/src/shapes/Object/InteractiveObject.min.mjs.map +1 -1
- package/dist/src/shapes/Object/InteractiveObject.mjs +3 -1
- package/dist/src/shapes/Object/InteractiveObject.mjs.map +1 -1
- package/dist/src/shapes/Object/Object.d.ts +1 -16
- package/dist/src/shapes/Object/Object.d.ts.map +1 -1
- package/dist/src/shapes/Object/Object.min.mjs +1 -1
- package/dist/src/shapes/Object/Object.min.mjs.map +1 -1
- package/dist/src/shapes/Object/Object.mjs +9 -10
- package/dist/src/shapes/Object/Object.mjs.map +1 -1
- package/dist/src/shapes/Object/StackedObject.d.ts +8 -15
- package/dist/src/shapes/Object/StackedObject.d.ts.map +1 -1
- package/dist/src/shapes/Object/StackedObject.min.mjs +1 -1
- package/dist/src/shapes/Object/StackedObject.min.mjs.map +1 -1
- package/dist/src/shapes/Object/StackedObject.mjs +11 -21
- package/dist/src/shapes/Object/StackedObject.mjs.map +1 -1
- package/dist/src/shapes/Path.d.ts +2 -2
- package/dist/src/shapes/Path.d.ts.map +1 -1
- package/dist/src/shapes/Path.min.mjs.map +1 -1
- package/dist/src/shapes/Path.mjs +2 -2
- package/dist/src/shapes/Path.mjs.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.d.ts +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.mjs.map +1 -1
- package/dist/src/util/misc/objectEnlive.d.ts +2 -2
- package/dist/src/util/misc/objectEnlive.d.ts.map +1 -1
- package/dist/src/util/misc/objectEnlive.min.mjs.map +1 -1
- package/dist/src/util/misc/objectEnlive.mjs.map +1 -1
- package/package.json +2 -2
- package/src/canvas/Canvas.ts +6 -9
- package/src/canvas/SelectableCanvas.ts +2 -2
- package/src/canvas/StaticCanvas.ts +4 -18
- package/src/color/Color.ts +2 -1
- package/src/color/color.test.ts +6 -0
- package/src/filters/BaseFilter.ts +45 -51
- package/src/filters/BlendColor.ts +13 -35
- package/src/filters/BlendImage.ts +26 -40
- package/src/filters/Blur.ts +13 -20
- package/src/filters/Boilerplate.ts +13 -22
- package/src/filters/Brightness.ts +12 -21
- package/src/filters/Canvas2dFilterBackend.ts +1 -1
- package/src/filters/ColorMatrix.ts +29 -34
- package/src/filters/ColorMatrixFilters.ts +15 -9
- package/src/filters/Composed.ts +26 -16
- package/src/filters/Contrast.ts +15 -23
- package/src/filters/Convolute.ts +11 -23
- package/src/filters/Gamma.ts +32 -24
- package/src/filters/Grayscale.ts +8 -19
- package/src/filters/HueRotation.ts +21 -11
- package/src/filters/Invert.ts +11 -22
- package/src/filters/Noise.ts +11 -30
- package/src/filters/Pixelate.ts +9 -22
- package/src/filters/RemoveColor.ts +21 -35
- package/src/filters/Resize.ts +20 -44
- package/src/filters/Saturation.ts +16 -27
- package/src/filters/Vibrance.ts +14 -24
- package/src/filters/WebGLFilterBackend.ts +1 -1
- package/src/filters/shaders/blendImage.ts +12 -0
- package/src/filters/typedefs.ts +23 -0
- package/src/parser/elements_parser.ts +1 -1
- package/src/shapes/ActiveSelection.ts +8 -4
- package/src/shapes/Group.ts +16 -1
- package/src/shapes/Image.ts +8 -6
- package/src/shapes/Object/InteractiveObject.ts +3 -1
- package/src/shapes/Object/Object.ts +10 -35
- package/src/shapes/Object/StackedObject.ts +28 -44
- package/src/shapes/Path.ts +4 -4
- package/src/shapes/Text/TextSVGExportMixin.ts +1 -1
- package/src/util/misc/objectEnlive.ts +12 -2
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Color } from '../color/Color';
|
|
2
|
-
import type { TClassProperties } from '../typedefs';
|
|
3
2
|
import { BaseFilter } from './BaseFilter';
|
|
4
3
|
import type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';
|
|
5
4
|
import { classRegistry } from '../ClassRegistry';
|
|
@@ -17,7 +16,13 @@ export type TBlendMode =
|
|
|
17
16
|
| 'exclusion'
|
|
18
17
|
| 'tint';
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
type BlendColorOwnProps = {
|
|
20
|
+
color: string;
|
|
21
|
+
mode: TBlendMode;
|
|
22
|
+
alpha: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const blendColorDefaultValues: BlendColorOwnProps = {
|
|
21
26
|
color: '#F95C63',
|
|
22
27
|
mode: 'multiply',
|
|
23
28
|
alpha: 1,
|
|
@@ -39,14 +44,14 @@ export const blendColorDefaultValues: Partial<TClassProperties<BlendColor>> = {
|
|
|
39
44
|
* object.applyFilters();
|
|
40
45
|
* canvas.renderAll();
|
|
41
46
|
*/
|
|
42
|
-
export class BlendColor extends BaseFilter {
|
|
47
|
+
export class BlendColor extends BaseFilter<'BlendColor', BlendColorOwnProps> {
|
|
43
48
|
/**
|
|
44
49
|
* Color to make the blend operation with. default to a reddish color since black or white
|
|
45
50
|
* gives always strong result.
|
|
46
51
|
* @type String
|
|
47
52
|
* @default
|
|
48
53
|
**/
|
|
49
|
-
declare color:
|
|
54
|
+
declare color: BlendColorOwnProps['color'];
|
|
50
55
|
|
|
51
56
|
/**
|
|
52
57
|
* Blend mode for the filter: one of multiply, add, difference, screen, subtract,
|
|
@@ -54,19 +59,20 @@ export class BlendColor extends BaseFilter {
|
|
|
54
59
|
* @type String
|
|
55
60
|
* @default
|
|
56
61
|
**/
|
|
57
|
-
declare mode:
|
|
58
|
-
|
|
62
|
+
declare mode: BlendColorOwnProps['mode'];
|
|
59
63
|
/**
|
|
60
64
|
* alpha value. represent the strength of the blend color operation.
|
|
61
65
|
* @type Number
|
|
62
66
|
* @default
|
|
63
67
|
**/
|
|
64
|
-
declare alpha:
|
|
68
|
+
declare alpha: BlendColorOwnProps['alpha'];
|
|
65
69
|
|
|
66
70
|
static defaults = blendColorDefaultValues;
|
|
67
71
|
|
|
68
72
|
static type = 'BlendColor';
|
|
69
73
|
|
|
74
|
+
static uniformLocations = ['uColor'];
|
|
75
|
+
|
|
70
76
|
getCacheKey() {
|
|
71
77
|
return `${this.type}_${this.mode}`;
|
|
72
78
|
}
|
|
@@ -168,21 +174,6 @@ export class BlendColor extends BaseFilter {
|
|
|
168
174
|
}
|
|
169
175
|
}
|
|
170
176
|
|
|
171
|
-
/**
|
|
172
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
173
|
-
*
|
|
174
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
175
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
176
|
-
*/
|
|
177
|
-
getUniformLocations(
|
|
178
|
-
gl: WebGLRenderingContext,
|
|
179
|
-
program: WebGLProgram
|
|
180
|
-
): TWebGLUniformLocationMap {
|
|
181
|
-
return {
|
|
182
|
-
uColor: gl.getUniformLocation(program, 'uColor'),
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
177
|
/**
|
|
187
178
|
* Send data from this filter to its shader program's uniforms.
|
|
188
179
|
*
|
|
@@ -200,19 +191,6 @@ export class BlendColor extends BaseFilter {
|
|
|
200
191
|
source[3] = this.alpha;
|
|
201
192
|
gl.uniform4fv(uniformLocations.uColor, source);
|
|
202
193
|
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Returns object representation of an instance
|
|
206
|
-
* @return {Object} Object representation of an instance
|
|
207
|
-
*/
|
|
208
|
-
toObject() {
|
|
209
|
-
return {
|
|
210
|
-
type: this.type,
|
|
211
|
-
color: this.color,
|
|
212
|
-
mode: this.mode,
|
|
213
|
-
alpha: this.alpha,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
194
|
}
|
|
217
195
|
|
|
218
196
|
classRegistry.setClass(BlendColor);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FabricImage } from '../shapes/Image';
|
|
2
|
-
import type { TClassProperties } from '../typedefs';
|
|
3
2
|
import { createCanvasElement } from '../util/misc/dom';
|
|
4
3
|
import { BaseFilter } from './BaseFilter';
|
|
5
4
|
import type {
|
|
@@ -9,24 +8,18 @@ import type {
|
|
|
9
8
|
} from './typedefs';
|
|
10
9
|
import type { WebGLFilterBackend } from './WebGLFilterBackend';
|
|
11
10
|
import { classRegistry } from '../ClassRegistry';
|
|
12
|
-
import { fragmentSource } from './shaders/blendImage';
|
|
11
|
+
import { fragmentSource, vertexSource } from './shaders/blendImage';
|
|
13
12
|
|
|
14
13
|
export type TBlendImageMode = 'multiply' | 'mask';
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
type BlendImageOwnProps = {
|
|
16
|
+
mode: TBlendImageMode;
|
|
17
|
+
alpha: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const blendImageDefaultValues: BlendImageOwnProps = {
|
|
17
21
|
mode: 'multiply',
|
|
18
22
|
alpha: 1,
|
|
19
|
-
vertexSource: `
|
|
20
|
-
attribute vec2 aPosition;
|
|
21
|
-
varying vec2 vTexCoord;
|
|
22
|
-
varying vec2 vTexCoord2;
|
|
23
|
-
uniform mat3 uTransformMatrix;
|
|
24
|
-
void main() {
|
|
25
|
-
vTexCoord = aPosition;
|
|
26
|
-
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
|
|
27
|
-
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
28
|
-
}
|
|
29
|
-
`,
|
|
30
23
|
};
|
|
31
24
|
|
|
32
25
|
/**
|
|
@@ -45,7 +38,7 @@ export const blendImageDefaultValues: Partial<TClassProperties<BlendImage>> = {
|
|
|
45
38
|
* object.applyFilters();
|
|
46
39
|
* canvas.renderAll();
|
|
47
40
|
*/
|
|
48
|
-
export class BlendImage extends BaseFilter {
|
|
41
|
+
export class BlendImage extends BaseFilter<'BlendImage', BlendImageOwnProps> {
|
|
49
42
|
/**
|
|
50
43
|
* Image to make the blend operation with.
|
|
51
44
|
**/
|
|
@@ -60,18 +53,20 @@ export class BlendImage extends BaseFilter {
|
|
|
60
53
|
* @type String
|
|
61
54
|
* @default
|
|
62
55
|
**/
|
|
63
|
-
declare mode:
|
|
56
|
+
declare mode: BlendImageOwnProps['mode'];
|
|
64
57
|
|
|
65
58
|
/**
|
|
66
59
|
* alpha value. represent the strength of the blend image operation.
|
|
67
60
|
* not implemented.
|
|
68
61
|
**/
|
|
69
|
-
declare alpha:
|
|
62
|
+
declare alpha: BlendImageOwnProps['alpha'];
|
|
70
63
|
|
|
71
64
|
static type = 'BlendImage';
|
|
72
65
|
|
|
73
66
|
static defaults = blendImageDefaultValues;
|
|
74
67
|
|
|
68
|
+
static uniformLocations = ['uTransformMatrix', 'uImage'];
|
|
69
|
+
|
|
75
70
|
getCacheKey() {
|
|
76
71
|
return `${this.type}_${this.mode}`;
|
|
77
72
|
}
|
|
@@ -80,6 +75,10 @@ export class BlendImage extends BaseFilter {
|
|
|
80
75
|
return fragmentSource[this.mode];
|
|
81
76
|
}
|
|
82
77
|
|
|
78
|
+
getVertexSource(): string {
|
|
79
|
+
return vertexSource;
|
|
80
|
+
}
|
|
81
|
+
|
|
83
82
|
applyToWebGL(options: TWebGLPipelineState) {
|
|
84
83
|
const gl = options.context,
|
|
85
84
|
texture = this.createTexture(options.filterBackend, this.image);
|
|
@@ -171,22 +170,6 @@ export class BlendImage extends BaseFilter {
|
|
|
171
170
|
}
|
|
172
171
|
}
|
|
173
172
|
|
|
174
|
-
/**
|
|
175
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
176
|
-
*
|
|
177
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
178
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
179
|
-
*/
|
|
180
|
-
getUniformLocations(
|
|
181
|
-
gl: WebGLRenderingContext,
|
|
182
|
-
program: WebGLProgram
|
|
183
|
-
): TWebGLUniformLocationMap {
|
|
184
|
-
return {
|
|
185
|
-
uTransformMatrix: gl.getUniformLocation(program, 'uTransformMatrix'),
|
|
186
|
-
uImage: gl.getUniformLocation(program, 'uImage'),
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
173
|
/**
|
|
191
174
|
* Send data from this filter to its shader program's uniforms.
|
|
192
175
|
*
|
|
@@ -204,14 +187,17 @@ export class BlendImage extends BaseFilter {
|
|
|
204
187
|
|
|
205
188
|
/**
|
|
206
189
|
* Returns object representation of an instance
|
|
190
|
+
* TODO: Handle the possibility of missing image better.
|
|
191
|
+
* As of now a BlendImage filter without image can't be used with fromObject
|
|
207
192
|
* @return {Object} Object representation of an instance
|
|
208
193
|
*/
|
|
209
|
-
toObject() {
|
|
194
|
+
toObject(): {
|
|
195
|
+
type: 'BlendImage';
|
|
196
|
+
image: ReturnType<FabricImage['toObject']>;
|
|
197
|
+
} & BlendImageOwnProps {
|
|
210
198
|
return {
|
|
211
|
-
|
|
199
|
+
...super.toObject(),
|
|
212
200
|
image: this.image && this.image.toObject(),
|
|
213
|
-
mode: this.mode,
|
|
214
|
-
alpha: this.alpha,
|
|
215
201
|
};
|
|
216
202
|
}
|
|
217
203
|
|
|
@@ -223,13 +209,13 @@ export class BlendImage extends BaseFilter {
|
|
|
223
209
|
* @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
|
|
224
210
|
* @returns {Promise<BlendImage>}
|
|
225
211
|
*/
|
|
226
|
-
static fromObject(
|
|
212
|
+
static async fromObject(
|
|
227
213
|
{ type, image, ...filterOptions }: Record<string, any>,
|
|
228
214
|
options: { signal: AbortSignal }
|
|
229
|
-
) {
|
|
215
|
+
): Promise<BaseFilter<'BlendImage', BlendImageOwnProps>> {
|
|
230
216
|
return FabricImage.fromObject(image, options).then(
|
|
231
217
|
(enlivedImage) =>
|
|
232
|
-
new this({ ...filterOptions, image: enlivedImage }) as
|
|
218
|
+
new this({ ...filterOptions, image: enlivedImage }) as BlendImage
|
|
233
219
|
);
|
|
234
220
|
}
|
|
235
221
|
}
|
package/src/filters/Blur.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TClassProperties } from '../typedefs';
|
|
2
1
|
import { createCanvasElement } from '../util/misc/dom';
|
|
3
2
|
import { BaseFilter } from './BaseFilter';
|
|
4
3
|
import type {
|
|
@@ -10,9 +9,12 @@ import { isWebGLPipelineState } from './utils';
|
|
|
10
9
|
import { classRegistry } from '../ClassRegistry';
|
|
11
10
|
import { fragmentSource } from './shaders/blur';
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
type BlurOwnProps = {
|
|
13
|
+
blur: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const blurDefaultValues: BlurOwnProps = {
|
|
14
17
|
blur: 0,
|
|
15
|
-
mainParameter: 'blur',
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -25,7 +27,7 @@ export const blurDefaultValues: Partial<TClassProperties<Blur>> = {
|
|
|
25
27
|
* object.applyFilters();
|
|
26
28
|
* canvas.renderAll();
|
|
27
29
|
*/
|
|
28
|
-
export class Blur extends BaseFilter {
|
|
30
|
+
export class Blur extends BaseFilter<'Blur', BlurOwnProps> {
|
|
29
31
|
/**
|
|
30
32
|
* blur value, in percentage of image dimensions.
|
|
31
33
|
* specific to keep the image blur constant at different resolutions
|
|
@@ -33,7 +35,7 @@ export class Blur extends BaseFilter {
|
|
|
33
35
|
* @type Number
|
|
34
36
|
* @default
|
|
35
37
|
*/
|
|
36
|
-
declare blur:
|
|
38
|
+
declare blur: BlurOwnProps['blur'];
|
|
37
39
|
|
|
38
40
|
declare horizontal: boolean;
|
|
39
41
|
declare aspectRatio: number;
|
|
@@ -42,6 +44,8 @@ export class Blur extends BaseFilter {
|
|
|
42
44
|
|
|
43
45
|
static defaults = blurDefaultValues;
|
|
44
46
|
|
|
47
|
+
static uniformLocations = ['uDelta'];
|
|
48
|
+
|
|
45
49
|
getFragmentSource(): string {
|
|
46
50
|
return fragmentSource;
|
|
47
51
|
}
|
|
@@ -121,21 +125,6 @@ export class Blur extends BaseFilter {
|
|
|
121
125
|
return newImageData;
|
|
122
126
|
}
|
|
123
127
|
|
|
124
|
-
/**
|
|
125
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
126
|
-
*
|
|
127
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
128
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
129
|
-
*/
|
|
130
|
-
getUniformLocations(
|
|
131
|
-
gl: WebGLRenderingContext,
|
|
132
|
-
program: WebGLProgram
|
|
133
|
-
): TWebGLUniformLocationMap {
|
|
134
|
-
return {
|
|
135
|
-
delta: gl.getUniformLocation(program, 'uDelta'),
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
128
|
/**
|
|
140
129
|
* Send data from this filter to its shader program's uniforms.
|
|
141
130
|
*
|
|
@@ -150,6 +139,10 @@ export class Blur extends BaseFilter {
|
|
|
150
139
|
gl.uniform2fv(uniformLocations.delta, delta);
|
|
151
140
|
}
|
|
152
141
|
|
|
142
|
+
isNeutralState() {
|
|
143
|
+
return this.blur === 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
153
146
|
/**
|
|
154
147
|
* choose right value of image percentage to blur with
|
|
155
148
|
* @returns {Array} a numeric array with delta values
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { TClassProperties } from '../typedefs';
|
|
2
1
|
import { BaseFilter } from './BaseFilter';
|
|
3
2
|
import type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
type MyFilterOwnProps = {
|
|
5
|
+
myParameter: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const myFilterDefaultValues: MyFilterOwnProps = {
|
|
6
9
|
myParameter: 0,
|
|
7
|
-
mainParameter: 'myParameter',
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -16,7 +18,7 @@ export const myFilterDefaultValues: Partial<TClassProperties<MyFilter>> = {
|
|
|
16
18
|
* object.filters.push(filter);
|
|
17
19
|
* object.applyFilters();
|
|
18
20
|
*/
|
|
19
|
-
export class MyFilter extends BaseFilter {
|
|
21
|
+
export class MyFilter extends BaseFilter<'MyFilter', MyFilterOwnProps> {
|
|
20
22
|
/**
|
|
21
23
|
* MyFilter value, from -1 to 1.
|
|
22
24
|
* translated to -255 to 255 for 2d
|
|
@@ -24,10 +26,14 @@ export class MyFilter extends BaseFilter {
|
|
|
24
26
|
* @param {Number} myParameter
|
|
25
27
|
* @default
|
|
26
28
|
*/
|
|
27
|
-
declare myParameter:
|
|
29
|
+
declare myParameter: MyFilterOwnProps['myParameter'];
|
|
30
|
+
|
|
31
|
+
static type = 'MyFilter';
|
|
28
32
|
|
|
29
33
|
static defaults = myFilterDefaultValues;
|
|
30
34
|
|
|
35
|
+
static uniformLocations = ['uMyParameter'];
|
|
36
|
+
|
|
31
37
|
getFragmentSource() {
|
|
32
38
|
return `
|
|
33
39
|
precision highp float;
|
|
@@ -58,21 +64,6 @@ export class MyFilter extends BaseFilter {
|
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
/**
|
|
62
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
63
|
-
*
|
|
64
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
65
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
66
|
-
*/
|
|
67
|
-
getUniformLocations(
|
|
68
|
-
gl: WebGLRenderingContext,
|
|
69
|
-
program: WebGLProgram
|
|
70
|
-
): TWebGLUniformLocationMap {
|
|
71
|
-
return {
|
|
72
|
-
uMyParameter: gl.getUniformLocation(program, 'uMyParameter'),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
67
|
/**
|
|
77
68
|
* Send data from this filter to its shader program's uniforms.
|
|
78
69
|
*
|
|
@@ -86,9 +77,9 @@ export class MyFilter extends BaseFilter {
|
|
|
86
77
|
gl.uniform1f(uniformLocations.uMyParameter, this.myParameter);
|
|
87
78
|
}
|
|
88
79
|
|
|
89
|
-
static async fromObject(object: any) {
|
|
80
|
+
static async fromObject(object: any): Promise<MyFilter> {
|
|
90
81
|
// or overide with custom logic if your filter needs to
|
|
91
82
|
// deserialize something that is not a plain value
|
|
92
|
-
return new this(object)
|
|
83
|
+
return new this(object);
|
|
93
84
|
}
|
|
94
85
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type { TClassProperties } from '../typedefs';
|
|
2
1
|
import { BaseFilter } from './BaseFilter';
|
|
3
2
|
import type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';
|
|
4
3
|
import { classRegistry } from '../ClassRegistry';
|
|
5
4
|
import { fragmentSource } from './shaders/brightness';
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
type BrightnessOwnProps = {
|
|
7
|
+
brightness: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const brightnessDefaultValues: BrightnessOwnProps = {
|
|
7
11
|
brightness: 0,
|
|
8
|
-
mainParameter: 'brightness',
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
/**
|
|
@@ -17,7 +20,7 @@ export const brightnessDefaultValues: Partial<TClassProperties<Brightness>> = {
|
|
|
17
20
|
* object.filters.push(filter);
|
|
18
21
|
* object.applyFilters();
|
|
19
22
|
*/
|
|
20
|
-
export class Brightness extends BaseFilter {
|
|
23
|
+
export class Brightness extends BaseFilter<'Brightness', BrightnessOwnProps> {
|
|
21
24
|
/**
|
|
22
25
|
* Brightness value, from -1 to 1.
|
|
23
26
|
* translated to -255 to 255 for 2d
|
|
@@ -25,12 +28,14 @@ export class Brightness extends BaseFilter {
|
|
|
25
28
|
* @param {Number} brightness
|
|
26
29
|
* @default
|
|
27
30
|
*/
|
|
28
|
-
declare brightness:
|
|
31
|
+
declare brightness: BrightnessOwnProps['brightness'];
|
|
29
32
|
|
|
30
33
|
static type = 'Brightness';
|
|
31
34
|
|
|
32
35
|
static defaults = brightnessDefaultValues;
|
|
33
36
|
|
|
37
|
+
static uniformLocations = ['uBrightness'];
|
|
38
|
+
|
|
34
39
|
getFragmentSource() {
|
|
35
40
|
return fragmentSource;
|
|
36
41
|
}
|
|
@@ -42,9 +47,6 @@ export class Brightness extends BaseFilter {
|
|
|
42
47
|
* @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.
|
|
43
48
|
*/
|
|
44
49
|
applyTo2d({ imageData: { data } }: T2DPipelineState) {
|
|
45
|
-
if (this.brightness === 0) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
50
|
const brightness = Math.round(this.brightness * 255);
|
|
49
51
|
for (let i = 0; i < data.length; i += 4) {
|
|
50
52
|
data[i] = data[i] + brightness;
|
|
@@ -53,19 +55,8 @@ export class Brightness extends BaseFilter {
|
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*
|
|
59
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
60
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
61
|
-
*/
|
|
62
|
-
getUniformLocations(
|
|
63
|
-
gl: WebGLRenderingContext,
|
|
64
|
-
program: WebGLProgram
|
|
65
|
-
): TWebGLUniformLocationMap {
|
|
66
|
-
return {
|
|
67
|
-
uBrightness: gl.getUniformLocation(program, 'uBrightness'),
|
|
68
|
-
};
|
|
58
|
+
isNeutralState() {
|
|
59
|
+
return this.brightness === 0;
|
|
69
60
|
}
|
|
70
61
|
|
|
71
62
|
/**
|
|
@@ -25,7 +25,7 @@ export class Canvas2dFilterBackend {
|
|
|
25
25
|
* @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.
|
|
26
26
|
*/
|
|
27
27
|
applyFilters(
|
|
28
|
-
filters: BaseFilter[],
|
|
28
|
+
filters: BaseFilter<string, Record<string, any>>[],
|
|
29
29
|
sourceElement: CanvasImageSource,
|
|
30
30
|
sourceWidth: number,
|
|
31
31
|
sourceHeight: number,
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import type { TClassProperties } from '../typedefs';
|
|
2
1
|
import { BaseFilter } from './BaseFilter';
|
|
3
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
T2DPipelineState,
|
|
4
|
+
TMatColorMatrix,
|
|
5
|
+
TWebGLUniformLocationMap,
|
|
6
|
+
} from './typedefs';
|
|
4
7
|
import { classRegistry } from '../ClassRegistry';
|
|
5
8
|
import { fragmentSource } from './shaders/colorMatrix';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
|
|
10
|
+
type ColorMatrixOwnProps = {
|
|
11
|
+
matrix: TMatColorMatrix;
|
|
12
|
+
colorsOnly: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const colorMatrixDefaultValues: ColorMatrixOwnProps = {
|
|
16
|
+
matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
|
|
17
|
+
colorsOnly: true,
|
|
18
|
+
};
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
21
|
* Color Matrix filter class
|
|
@@ -26,7 +33,10 @@ export const colorMatrixDefaultValues: Partial<TClassProperties<ColorMatrix>> =
|
|
|
26
33
|
* object.filters.push(filter);
|
|
27
34
|
* object.applyFilters();
|
|
28
35
|
*/
|
|
29
|
-
export class ColorMatrix
|
|
36
|
+
export class ColorMatrix<
|
|
37
|
+
Name extends string = 'ColorMatrix',
|
|
38
|
+
OwnProps extends object = ColorMatrixOwnProps
|
|
39
|
+
> extends BaseFilter<Name, OwnProps> {
|
|
30
40
|
/**
|
|
31
41
|
* Colormatrix for pixels.
|
|
32
42
|
* array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning
|
|
@@ -35,7 +45,7 @@ export class ColorMatrix extends BaseFilter {
|
|
|
35
45
|
* @param {Array} matrix array of 20 numbers.
|
|
36
46
|
* @default
|
|
37
47
|
*/
|
|
38
|
-
declare matrix:
|
|
48
|
+
declare matrix: ColorMatrixOwnProps['matrix'];
|
|
39
49
|
|
|
40
50
|
/**
|
|
41
51
|
* Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario
|
|
@@ -43,19 +53,13 @@ export class ColorMatrix extends BaseFilter {
|
|
|
43
53
|
* @type Boolean
|
|
44
54
|
* @default true
|
|
45
55
|
*/
|
|
46
|
-
declare colorsOnly:
|
|
56
|
+
declare colorsOnly: ColorMatrixOwnProps['colorsOnly'];
|
|
47
57
|
|
|
48
58
|
static type = 'ColorMatrix';
|
|
49
59
|
|
|
50
60
|
static defaults = colorMatrixDefaultValues;
|
|
51
61
|
|
|
52
|
-
|
|
53
|
-
if (matrix) {
|
|
54
|
-
// safeguard against mutation
|
|
55
|
-
this.matrix = [...matrix];
|
|
56
|
-
}
|
|
57
|
-
Object.assign(this, options);
|
|
58
|
-
}
|
|
62
|
+
static uniformLocations = ['uColorMatrix', 'uConstants'];
|
|
59
63
|
|
|
60
64
|
getFragmentSource(): string {
|
|
61
65
|
return fragmentSource;
|
|
@@ -93,22 +97,6 @@ export class ColorMatrix extends BaseFilter {
|
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
/**
|
|
97
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
98
|
-
*
|
|
99
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
100
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
101
|
-
*/
|
|
102
|
-
getUniformLocations(
|
|
103
|
-
gl: WebGLRenderingContext,
|
|
104
|
-
program: WebGLProgram
|
|
105
|
-
): TWebGLUniformLocationMap {
|
|
106
|
-
return {
|
|
107
|
-
uColorMatrix: gl.getUniformLocation(program, 'uColorMatrix'),
|
|
108
|
-
uConstants: gl.getUniformLocation(program, 'uConstants'),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
100
|
/**
|
|
113
101
|
* Send data from this filter to its shader program's uniforms.
|
|
114
102
|
*
|
|
@@ -142,6 +130,13 @@ export class ColorMatrix extends BaseFilter {
|
|
|
142
130
|
gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);
|
|
143
131
|
gl.uniform4fv(uniformLocations.uConstants, constants);
|
|
144
132
|
}
|
|
133
|
+
|
|
134
|
+
toObject() {
|
|
135
|
+
return {
|
|
136
|
+
...super.toObject(),
|
|
137
|
+
matrix: [...this.matrix] as TMatColorMatrix,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
145
140
|
}
|
|
146
141
|
|
|
147
142
|
classRegistry.setClass(ColorMatrix);
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { ColorMatrix
|
|
1
|
+
import { ColorMatrix } from './ColorMatrix';
|
|
2
2
|
import { classRegistry } from '../ClassRegistry';
|
|
3
|
+
import type { TMatColorMatrix } from './typedefs';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
type FixedFiltersOwnProps = {
|
|
6
|
+
colorsOnly: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function createColorMatrixFilter(key: string, matrix: TMatColorMatrix) {
|
|
10
|
+
const newClass = class extends ColorMatrix<typeof key, FixedFiltersOwnProps> {
|
|
6
11
|
static type = key;
|
|
7
12
|
|
|
8
13
|
static defaults = {
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Lock the matrix export for this kind of static, parameter less filters.
|
|
12
|
-
*/
|
|
13
|
-
mainParameter: undefined,
|
|
14
|
+
colorsOnly: false,
|
|
14
15
|
matrix,
|
|
15
16
|
};
|
|
17
|
+
|
|
18
|
+
//@ts-expect-error TS wants matrix to be exported.
|
|
19
|
+
toObject(): { type: string } & FixedFiltersOwnProps {
|
|
20
|
+
return { type: this.type, colorsOnly: this.colorsOnly };
|
|
21
|
+
}
|
|
16
22
|
};
|
|
17
23
|
classRegistry.setClass(newClass, key);
|
|
18
|
-
return newClass
|
|
24
|
+
return newClass as typeof ColorMatrix<typeof key, FixedFiltersOwnProps>;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
export const Brownie = createColorMatrixFilter(
|