@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
package/dist/index.mjs
CHANGED
|
@@ -417,7 +417,7 @@ class Cache {
|
|
|
417
417
|
}
|
|
418
418
|
const cache = new Cache();
|
|
419
419
|
|
|
420
|
-
var version = "6.0.0
|
|
420
|
+
var version = "6.0.0";
|
|
421
421
|
|
|
422
422
|
// use this syntax so babel plugin see this import here
|
|
423
423
|
const VERSION = version;
|
|
@@ -2365,6 +2365,7 @@ class Color {
|
|
|
2365
2365
|
* @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list
|
|
2366
2366
|
*/
|
|
2367
2367
|
constructor(color) {
|
|
2368
|
+
_defineProperty(this, "isUnrecognised", false);
|
|
2368
2369
|
if (!color) {
|
|
2369
2370
|
// we default to black as canvas does
|
|
2370
2371
|
this.setSource([0, 0, 0, 1]);
|
|
@@ -2390,7 +2391,7 @@ class Color {
|
|
|
2390
2391
|
return color === 'transparent' ? [255, 255, 255, 0] : Color.sourceFromHex(color) || Color.sourceFromRgb(color) || Color.sourceFromHsl(color) ||
|
|
2391
2392
|
// color is not recognized
|
|
2392
2393
|
// we default to black as canvas does
|
|
2393
|
-
[0, 0, 0, 1];
|
|
2394
|
+
(this.isUnrecognised = true) && [0, 0, 0, 1];
|
|
2394
2395
|
}
|
|
2395
2396
|
|
|
2396
2397
|
/**
|
|
@@ -3317,20 +3318,7 @@ class StaticCanvas extends createCollectionMixin(CommonMethods) {
|
|
|
3317
3318
|
* @param {Array} vpt a Canvas 2D API transform matrix
|
|
3318
3319
|
*/
|
|
3319
3320
|
setViewportTransform(vpt) {
|
|
3320
|
-
const backgroundObject = this.backgroundImage,
|
|
3321
|
-
overlayObject = this.overlayImage,
|
|
3322
|
-
len = this._objects.length;
|
|
3323
3321
|
this.viewportTransform = vpt;
|
|
3324
|
-
for (let i = 0; i < len; i++) {
|
|
3325
|
-
const object = this._objects[i];
|
|
3326
|
-
object.group || object.setCoords();
|
|
3327
|
-
}
|
|
3328
|
-
if (backgroundObject) {
|
|
3329
|
-
backgroundObject.setCoords();
|
|
3330
|
-
}
|
|
3331
|
-
if (overlayObject) {
|
|
3332
|
-
overlayObject.setCoords();
|
|
3333
|
-
}
|
|
3334
3322
|
this.calcViewportBoundaries();
|
|
3335
3323
|
this.renderOnAddRemove && this.requestRenderAll();
|
|
3336
3324
|
}
|
|
@@ -4382,7 +4370,7 @@ const makeBoundingBoxFromPoints = points => {
|
|
|
4382
4370
|
};
|
|
4383
4371
|
};
|
|
4384
4372
|
|
|
4385
|
-
const _excluded$
|
|
4373
|
+
const _excluded$i = ["translateX", "translateY", "scaleX", "scaleY"];
|
|
4386
4374
|
|
|
4387
4375
|
/**
|
|
4388
4376
|
* given an object and a transform, apply the inverse transform to the object,
|
|
@@ -4424,7 +4412,7 @@ const applyTransformToObject = (object, transform) => {
|
|
|
4424
4412
|
scaleX,
|
|
4425
4413
|
scaleY
|
|
4426
4414
|
} = _qrDecompose,
|
|
4427
|
-
otherOptions = _objectWithoutProperties(_qrDecompose, _excluded$
|
|
4415
|
+
otherOptions = _objectWithoutProperties(_qrDecompose, _excluded$i),
|
|
4428
4416
|
center = new Point(translateX, translateY);
|
|
4429
4417
|
object.flipX = false;
|
|
4430
4418
|
object.flipY = false;
|
|
@@ -5339,14 +5327,14 @@ class AnimationBase {
|
|
|
5339
5327
|
}
|
|
5340
5328
|
}
|
|
5341
5329
|
|
|
5342
|
-
const _excluded$
|
|
5330
|
+
const _excluded$h = ["startValue", "endValue"];
|
|
5343
5331
|
class ValueAnimation extends AnimationBase {
|
|
5344
5332
|
constructor(_ref) {
|
|
5345
5333
|
let {
|
|
5346
5334
|
startValue = 0,
|
|
5347
5335
|
endValue = 100
|
|
5348
5336
|
} = _ref,
|
|
5349
|
-
otherOptions = _objectWithoutProperties(_ref, _excluded$
|
|
5337
|
+
otherOptions = _objectWithoutProperties(_ref, _excluded$h);
|
|
5350
5338
|
super(_objectSpread2(_objectSpread2({}, otherOptions), {}, {
|
|
5351
5339
|
startValue,
|
|
5352
5340
|
byValue: endValue - startValue
|
|
@@ -5361,14 +5349,14 @@ class ValueAnimation extends AnimationBase {
|
|
|
5361
5349
|
}
|
|
5362
5350
|
}
|
|
5363
5351
|
|
|
5364
|
-
const _excluded$
|
|
5352
|
+
const _excluded$g = ["startValue", "endValue"];
|
|
5365
5353
|
class ArrayAnimation extends AnimationBase {
|
|
5366
5354
|
constructor(_ref) {
|
|
5367
5355
|
let {
|
|
5368
5356
|
startValue = [0],
|
|
5369
5357
|
endValue = [100]
|
|
5370
5358
|
} = _ref,
|
|
5371
|
-
options = _objectWithoutProperties(_ref, _excluded$
|
|
5359
|
+
options = _objectWithoutProperties(_ref, _excluded$g);
|
|
5372
5360
|
super(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
5373
5361
|
startValue,
|
|
5374
5362
|
byValue: endValue.map((value, i) => value - startValue[i])
|
|
@@ -5385,7 +5373,7 @@ class ArrayAnimation extends AnimationBase {
|
|
|
5385
5373
|
|
|
5386
5374
|
const capValue = (min, value, max) => Math.max(min, Math.min(value, max));
|
|
5387
5375
|
|
|
5388
|
-
const _excluded$
|
|
5376
|
+
const _excluded$f = ["startValue", "endValue", "easing", "onChange", "onComplete", "abort"];
|
|
5389
5377
|
const defaultColorEasing = (timeElapsed, startValue, byValue, duration) => {
|
|
5390
5378
|
const durationProgress = 1 - Math.cos(timeElapsed / duration * halfPI);
|
|
5391
5379
|
return startValue + byValue * durationProgress;
|
|
@@ -5401,7 +5389,7 @@ class ColorAnimation extends AnimationBase {
|
|
|
5401
5389
|
onComplete,
|
|
5402
5390
|
abort
|
|
5403
5391
|
} = _ref,
|
|
5404
|
-
options = _objectWithoutProperties(_ref, _excluded$
|
|
5392
|
+
options = _objectWithoutProperties(_ref, _excluded$f);
|
|
5405
5393
|
const startColor = new Color(startValue).getSource();
|
|
5406
5394
|
const endColor = new Color(endValue).getSource();
|
|
5407
5395
|
super(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
@@ -6442,10 +6430,6 @@ class ObjectGeometry extends ObjectOrigin {
|
|
|
6442
6430
|
}
|
|
6443
6431
|
}
|
|
6444
6432
|
|
|
6445
|
-
/**
|
|
6446
|
-
* Strict: only ancestors that are objects (without canvas)
|
|
6447
|
-
*/
|
|
6448
|
-
|
|
6449
6433
|
class StackedObject extends ObjectGeometry {
|
|
6450
6434
|
/**
|
|
6451
6435
|
* A reference to the parent of the object
|
|
@@ -6469,17 +6453,14 @@ class StackedObject extends ObjectGeometry {
|
|
|
6469
6453
|
}
|
|
6470
6454
|
|
|
6471
6455
|
/**
|
|
6472
|
-
*
|
|
6473
|
-
* @param {boolean} [strict] returns only ancestors that are objects (without canvas)
|
|
6474
6456
|
* @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top
|
|
6475
6457
|
*/
|
|
6476
|
-
getAncestors(
|
|
6458
|
+
getAncestors() {
|
|
6477
6459
|
const ancestors = [];
|
|
6478
6460
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
6479
6461
|
let parent = this;
|
|
6480
6462
|
do {
|
|
6481
|
-
|
|
6482
|
-
parent = parent instanceof StackedObject ? (_parent$parent = parent.parent) !== null && _parent$parent !== void 0 ? _parent$parent : !strict ? parent.canvas : undefined : undefined;
|
|
6463
|
+
parent = parent instanceof StackedObject ? parent.parent : undefined;
|
|
6483
6464
|
parent && ancestors.push(parent);
|
|
6484
6465
|
} while (parent);
|
|
6485
6466
|
return ancestors;
|
|
@@ -6489,19 +6470,18 @@ class StackedObject extends ObjectGeometry {
|
|
|
6489
6470
|
* Compare ancestors
|
|
6490
6471
|
*
|
|
6491
6472
|
* @param {StackedObject} other
|
|
6492
|
-
* @param {boolean} [strict] finds only ancestors that are objects (without canvas)
|
|
6493
6473
|
* @returns {AncestryComparison} an object that represent the ancestry situation.
|
|
6494
6474
|
*/
|
|
6495
|
-
findCommonAncestors(other
|
|
6475
|
+
findCommonAncestors(other) {
|
|
6496
6476
|
if (this === other) {
|
|
6497
6477
|
return {
|
|
6498
6478
|
fork: [],
|
|
6499
6479
|
otherFork: [],
|
|
6500
|
-
common: [this, ...this.getAncestors(
|
|
6480
|
+
common: [this, ...this.getAncestors()]
|
|
6501
6481
|
};
|
|
6502
6482
|
}
|
|
6503
|
-
const ancestors = this.getAncestors(
|
|
6504
|
-
const otherAncestors = other.getAncestors(
|
|
6483
|
+
const ancestors = this.getAncestors();
|
|
6484
|
+
const otherAncestors = other.getAncestors();
|
|
6505
6485
|
// if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case
|
|
6506
6486
|
if (ancestors.length === 0 && otherAncestors.length > 0 && this === otherAncestors[otherAncestors.length - 1]) {
|
|
6507
6487
|
return {
|
|
@@ -6548,11 +6528,10 @@ class StackedObject extends ObjectGeometry {
|
|
|
6548
6528
|
/**
|
|
6549
6529
|
*
|
|
6550
6530
|
* @param {StackedObject} other
|
|
6551
|
-
* @param {boolean} [strict] checks only ancestors that are objects (without canvas)
|
|
6552
6531
|
* @returns {boolean}
|
|
6553
6532
|
*/
|
|
6554
|
-
hasCommonAncestors(other
|
|
6555
|
-
const commonAncestors = this.findCommonAncestors(other
|
|
6533
|
+
hasCommonAncestors(other) {
|
|
6534
|
+
const commonAncestors = this.findCommonAncestors(other);
|
|
6556
6535
|
return commonAncestors && !!commonAncestors.common.length;
|
|
6557
6536
|
}
|
|
6558
6537
|
|
|
@@ -6566,16 +6545,15 @@ class StackedObject extends ObjectGeometry {
|
|
|
6566
6545
|
return undefined;
|
|
6567
6546
|
}
|
|
6568
6547
|
const ancestorData = this.findCommonAncestors(other);
|
|
6569
|
-
if (!ancestorData) {
|
|
6570
|
-
return undefined;
|
|
6571
|
-
}
|
|
6572
6548
|
if (ancestorData.fork.includes(other)) {
|
|
6573
6549
|
return true;
|
|
6574
6550
|
}
|
|
6575
6551
|
if (ancestorData.otherFork.includes(this)) {
|
|
6576
6552
|
return false;
|
|
6577
6553
|
}
|
|
6578
|
-
|
|
6554
|
+
// if there isn't a common ancestor, we take the canvas.
|
|
6555
|
+
// if there is no canvas, there is nothing to compare
|
|
6556
|
+
const firstCommonAncestor = ancestorData.common[0] || this.canvas;
|
|
6579
6557
|
if (!firstCommonAncestor) {
|
|
6580
6558
|
return undefined;
|
|
6581
6559
|
}
|
|
@@ -6948,7 +6926,7 @@ const interactiveObjectDefaultValues = {
|
|
|
6948
6926
|
moveCursor: null
|
|
6949
6927
|
};
|
|
6950
6928
|
|
|
6951
|
-
const _excluded$
|
|
6929
|
+
const _excluded$e = ["type"],
|
|
6952
6930
|
_excluded2$4 = ["extraParam"];
|
|
6953
6931
|
/**
|
|
6954
6932
|
* Root object class from which all 2d shape classes inherit from
|
|
@@ -7136,7 +7114,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
|
|
|
7136
7114
|
height = dims.height,
|
|
7137
7115
|
zoomX = dims.zoomX,
|
|
7138
7116
|
zoomY = dims.zoomY,
|
|
7139
|
-
dimensionsChanged = width !==
|
|
7117
|
+
dimensionsChanged = width !== canvas.width || height !== canvas.height,
|
|
7140
7118
|
zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;
|
|
7141
7119
|
if (!canvas || !context) {
|
|
7142
7120
|
return false;
|
|
@@ -7177,8 +7155,6 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
|
|
|
7177
7155
|
drawingHeight = dims.y / 2;
|
|
7178
7156
|
this.cacheTranslationX = Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;
|
|
7179
7157
|
this.cacheTranslationY = Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;
|
|
7180
|
-
this.cacheWidth = width;
|
|
7181
|
-
this.cacheHeight = height;
|
|
7182
7158
|
context.translate(this.cacheTranslationX, this.cacheTranslationY);
|
|
7183
7159
|
context.scale(zoomX, zoomY);
|
|
7184
7160
|
this.zoomX = zoomX;
|
|
@@ -7453,8 +7429,6 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
|
|
|
7453
7429
|
_removeCacheCanvas() {
|
|
7454
7430
|
this._cacheCanvas = undefined;
|
|
7455
7431
|
this._cacheContext = null;
|
|
7456
|
-
this.cacheWidth = 0;
|
|
7457
|
-
this.cacheHeight = 0;
|
|
7458
7432
|
}
|
|
7459
7433
|
|
|
7460
7434
|
/**
|
|
@@ -7613,15 +7587,18 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
|
|
|
7613
7587
|
if (this.isNotVisible()) {
|
|
7614
7588
|
return false;
|
|
7615
7589
|
}
|
|
7616
|
-
|
|
7590
|
+
const canvas = this._cacheCanvas;
|
|
7591
|
+
const ctx = this._cacheContext;
|
|
7592
|
+
if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {
|
|
7617
7593
|
// in this case the context is already cleared.
|
|
7618
7594
|
return true;
|
|
7619
7595
|
} else {
|
|
7620
7596
|
if (this.dirty || this.clipPath && this.clipPath.absolutePositioned) {
|
|
7621
|
-
if (
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7597
|
+
if (canvas && ctx && !skipCanvas) {
|
|
7598
|
+
ctx.save();
|
|
7599
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
7600
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
7601
|
+
ctx.restore();
|
|
7625
7602
|
}
|
|
7626
7603
|
return true;
|
|
7627
7604
|
}
|
|
@@ -8145,7 +8122,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
|
|
|
8145
8122
|
* @returns {Promise<FabricObject>}
|
|
8146
8123
|
*/
|
|
8147
8124
|
static _fromObject(_ref2) {
|
|
8148
|
-
let object = _objectWithoutProperties(_ref2, _excluded$
|
|
8125
|
+
let object = _objectWithoutProperties(_ref2, _excluded$e);
|
|
8149
8126
|
let _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
8150
8127
|
{
|
|
8151
8128
|
extraParam
|
|
@@ -8896,7 +8873,7 @@ const scalingEqually = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObj
|
|
|
8896
8873
|
const scalingX = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectX));
|
|
8897
8874
|
const scalingY = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectY));
|
|
8898
8875
|
|
|
8899
|
-
const _excluded$
|
|
8876
|
+
const _excluded$d = ["target", "ex", "ey", "skewingSide"];
|
|
8900
8877
|
const AXIS_KEYS = {
|
|
8901
8878
|
x: {
|
|
8902
8879
|
counterAxis: 'y',
|
|
@@ -8946,7 +8923,7 @@ function skewObject(axis, _ref, pointer) {
|
|
|
8946
8923
|
ey,
|
|
8947
8924
|
skewingSide
|
|
8948
8925
|
} = _ref,
|
|
8949
|
-
transform = _objectWithoutProperties(_ref, _excluded$
|
|
8926
|
+
transform = _objectWithoutProperties(_ref, _excluded$d);
|
|
8950
8927
|
const {
|
|
8951
8928
|
skew: skewKey
|
|
8952
8929
|
} = AXIS_KEYS[axis],
|
|
@@ -9532,6 +9509,9 @@ class InteractiveFabricObject extends FabricObject$1 {
|
|
|
9532
9509
|
* Draws corners of an object's bounding box.
|
|
9533
9510
|
* Requires public properties: width, height
|
|
9534
9511
|
* Requires public options: cornerSize, padding
|
|
9512
|
+
* Be aware that since fabric 6.0 this function does not call setCoords anymore.
|
|
9513
|
+
* setCoords needs to be called manually if the object of which we are rendering controls
|
|
9514
|
+
* is outside the standard selection and transform process.
|
|
9535
9515
|
* @param {CanvasRenderingContext2D} ctx Context to draw on
|
|
9536
9516
|
* @param {ControlRenderingStyleOverride} styleOverride object to override the object style
|
|
9537
9517
|
*/
|
|
@@ -9555,7 +9535,6 @@ class InteractiveFabricObject extends FabricObject$1 {
|
|
|
9555
9535
|
ctx.strokeStyle = options.cornerStrokeColor;
|
|
9556
9536
|
}
|
|
9557
9537
|
this._setLineDash(ctx, options.cornerDashArray);
|
|
9558
|
-
this.setCoords();
|
|
9559
9538
|
this.forEachControl((control, key) => {
|
|
9560
9539
|
if (control.getVisibility(this, key)) {
|
|
9561
9540
|
const p = this.oCoords[key];
|
|
@@ -10788,7 +10767,7 @@ function parseAttributes(element, attributes, cssRules) {
|
|
|
10788
10767
|
return svgValidParentsRegEx.test(element.nodeName) ? mergedAttrs : setStrokeFillOpacity(mergedAttrs);
|
|
10789
10768
|
}
|
|
10790
10769
|
|
|
10791
|
-
const _excluded$
|
|
10770
|
+
const _excluded$c = ["left", "top", "width", "height", "visible"];
|
|
10792
10771
|
const rectDefaultValues = {
|
|
10793
10772
|
rx: 0,
|
|
10794
10773
|
ry: 0
|
|
@@ -10902,7 +10881,7 @@ class Rect extends FabricObject {
|
|
|
10902
10881
|
height = 0,
|
|
10903
10882
|
visible = true
|
|
10904
10883
|
} = _parseAttributes,
|
|
10905
|
-
restOfparsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$
|
|
10884
|
+
restOfparsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$c);
|
|
10906
10885
|
return new this(_objectSpread2(_objectSpread2(_objectSpread2({}, options), restOfparsedAttributes), {}, {
|
|
10907
10886
|
left,
|
|
10908
10887
|
top,
|
|
@@ -11058,7 +11037,7 @@ class FitContentLayout extends LayoutStrategy {
|
|
|
11058
11037
|
_defineProperty(FitContentLayout, "type", 'fit-content');
|
|
11059
11038
|
classRegistry.setClass(FitContentLayout);
|
|
11060
11039
|
|
|
11061
|
-
const _excluded$
|
|
11040
|
+
const _excluded$b = ["strategy"],
|
|
11062
11041
|
_excluded2$3 = ["target", "strategy", "bubbles", "prevStrategy"];
|
|
11063
11042
|
const LAYOUT_MANAGER = 'layoutManager';
|
|
11064
11043
|
class LayoutManager {
|
|
@@ -11161,7 +11140,7 @@ class LayoutManager {
|
|
|
11161
11140
|
context
|
|
11162
11141
|
});
|
|
11163
11142
|
if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {
|
|
11164
|
-
const tricklingContext = _objectWithoutProperties(context, _excluded$
|
|
11143
|
+
const tricklingContext = _objectWithoutProperties(context, _excluded$b);
|
|
11165
11144
|
// traverse the tree
|
|
11166
11145
|
target.forEachObject(object => object.layoutManager && object.layoutManager.performLayout(_objectSpread2(_objectSpread2({}, tricklingContext), {}, {
|
|
11167
11146
|
bubbles: false,
|
|
@@ -11305,7 +11284,7 @@ class LayoutManager {
|
|
|
11305
11284
|
}
|
|
11306
11285
|
classRegistry.setClass(LayoutManager, LAYOUT_MANAGER);
|
|
11307
11286
|
|
|
11308
|
-
const _excluded$
|
|
11287
|
+
const _excluded$a = ["type", "objects", "layoutManager"];
|
|
11309
11288
|
/**
|
|
11310
11289
|
* This class handles the specific case of creating a group using {@link Group#fromObject} and is not meant to be used in any other case.
|
|
11311
11290
|
* We could have used a boolean in the constructor, as we did previously, but we think the boolean
|
|
@@ -11372,6 +11351,15 @@ class Group extends createCollectionMixin(FabricObject) {
|
|
|
11372
11351
|
_defineProperty(this, "__objectSelectionDisposer", void 0);
|
|
11373
11352
|
Object.assign(this, Group.ownDefaults);
|
|
11374
11353
|
this.setOptions(options);
|
|
11354
|
+
this.groupInit(objects, options);
|
|
11355
|
+
}
|
|
11356
|
+
|
|
11357
|
+
/**
|
|
11358
|
+
* Shared code between group and active selection
|
|
11359
|
+
* Meant to be used by the constructor.
|
|
11360
|
+
*/
|
|
11361
|
+
groupInit(objects, options) {
|
|
11362
|
+
var _options$layoutManage;
|
|
11375
11363
|
this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller
|
|
11376
11364
|
|
|
11377
11365
|
this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(this, true);
|
|
@@ -11381,7 +11369,7 @@ class Group extends createCollectionMixin(FabricObject) {
|
|
|
11381
11369
|
});
|
|
11382
11370
|
|
|
11383
11371
|
// perform initial layout
|
|
11384
|
-
this.layoutManager = options.layoutManager
|
|
11372
|
+
this.layoutManager = (_options$layoutManage = options.layoutManager) !== null && _options$layoutManage !== void 0 ? _options$layoutManage : new LayoutManager();
|
|
11385
11373
|
this.layoutManager.performLayout({
|
|
11386
11374
|
type: LAYOUT_TYPE_INITIALIZATION,
|
|
11387
11375
|
target: this,
|
|
@@ -11853,7 +11841,7 @@ class Group extends createCollectionMixin(FabricObject) {
|
|
|
11853
11841
|
objects = [],
|
|
11854
11842
|
layoutManager
|
|
11855
11843
|
} = _ref2,
|
|
11856
|
-
options = _objectWithoutProperties(_ref2, _excluded$
|
|
11844
|
+
options = _objectWithoutProperties(_ref2, _excluded$a);
|
|
11857
11845
|
return Promise.all([enlivenObjects(objects, abortable), enlivenObjectEnlivables(options, abortable)]).then(_ref3 => {
|
|
11858
11846
|
let [objects, hydratedOptions] = _ref3;
|
|
11859
11847
|
const group = new this(objects, _objectSpread2(_objectSpread2(_objectSpread2({}, options), hydratedOptions), {}, {
|
|
@@ -14009,8 +13997,8 @@ class SelectableCanvas extends StaticCanvas {
|
|
|
14009
13997
|
this._activeObject = object;
|
|
14010
13998
|
if (isActiveSelection(object) && prevActiveObject !== object) {
|
|
14011
13999
|
object.set('canvas', this);
|
|
14012
|
-
object.setCoords();
|
|
14013
14000
|
}
|
|
14001
|
+
object.setCoords();
|
|
14014
14002
|
return true;
|
|
14015
14003
|
}
|
|
14016
14004
|
|
|
@@ -14263,7 +14251,7 @@ class TextEditingManager {
|
|
|
14263
14251
|
}
|
|
14264
14252
|
}
|
|
14265
14253
|
|
|
14266
|
-
const _excluded$
|
|
14254
|
+
const _excluded$9 = ["target", "oldTarget", "fireCanvas", "e"];
|
|
14267
14255
|
const addEventOptions = {
|
|
14268
14256
|
passive: false
|
|
14269
14257
|
};
|
|
@@ -15277,7 +15265,7 @@ class Canvas extends SelectableCanvas {
|
|
|
15277
15265
|
fireCanvas,
|
|
15278
15266
|
e
|
|
15279
15267
|
} = _ref,
|
|
15280
|
-
data = _objectWithoutProperties(_ref, _excluded$
|
|
15268
|
+
data = _objectWithoutProperties(_ref, _excluded$9);
|
|
15281
15269
|
const {
|
|
15282
15270
|
targetIn,
|
|
15283
15271
|
targetOut,
|
|
@@ -15336,16 +15324,15 @@ class Canvas extends SelectableCanvas {
|
|
|
15336
15324
|
* @private
|
|
15337
15325
|
*/
|
|
15338
15326
|
_performTransformAction(e, transform, pointer) {
|
|
15339
|
-
const
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
|
|
15343
|
-
|
|
15344
|
-
|
|
15327
|
+
const {
|
|
15328
|
+
action,
|
|
15329
|
+
actionHandler,
|
|
15330
|
+
target
|
|
15331
|
+
} = transform;
|
|
15332
|
+
const actionPerformed = !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);
|
|
15333
|
+
actionPerformed && target.setCoords();
|
|
15345
15334
|
|
|
15346
|
-
|
|
15347
|
-
actionPerformed = actionHandler(e, transform, x, y);
|
|
15348
|
-
}
|
|
15335
|
+
// this object could be created from the function in the control handlers
|
|
15349
15336
|
if (action === 'drag' && actionPerformed) {
|
|
15350
15337
|
transform.target.isMoving = true;
|
|
15351
15338
|
this.setCursor(transform.target.moveCursor || this.moveCursor);
|
|
@@ -15972,7 +15959,7 @@ classRegistry.setClass(Gradient, 'gradient');
|
|
|
15972
15959
|
classRegistry.setClass(Gradient, 'linear');
|
|
15973
15960
|
classRegistry.setClass(Gradient, 'radial');
|
|
15974
15961
|
|
|
15975
|
-
const _excluded$
|
|
15962
|
+
const _excluded$8 = ["type", "source"];
|
|
15976
15963
|
|
|
15977
15964
|
/**
|
|
15978
15965
|
* @see {@link http://fabricjs.com/patterns demo}
|
|
@@ -16130,7 +16117,7 @@ class Pattern {
|
|
|
16130
16117
|
type,
|
|
16131
16118
|
source
|
|
16132
16119
|
} = _ref2,
|
|
16133
|
-
serialized = _objectWithoutProperties(_ref2, _excluded$
|
|
16120
|
+
serialized = _objectWithoutProperties(_ref2, _excluded$8);
|
|
16134
16121
|
const img = await loadImage(source, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
16135
16122
|
crossOrigin: serialized.crossOrigin
|
|
16136
16123
|
}));
|
|
@@ -16277,7 +16264,7 @@ class BaseBrush {
|
|
|
16277
16264
|
}
|
|
16278
16265
|
}
|
|
16279
16266
|
|
|
16280
|
-
const _excluded$
|
|
16267
|
+
const _excluded$7 = ["path", "left", "top"],
|
|
16281
16268
|
_excluded2$2 = ["d"];
|
|
16282
16269
|
class Path extends FabricObject {
|
|
16283
16270
|
/**
|
|
@@ -16293,7 +16280,7 @@ class Path extends FabricObject {
|
|
|
16293
16280
|
left,
|
|
16294
16281
|
top
|
|
16295
16282
|
} = _ref,
|
|
16296
|
-
options = _objectWithoutProperties(_ref, _excluded$
|
|
16283
|
+
options = _objectWithoutProperties(_ref, _excluded$7);
|
|
16297
16284
|
super();
|
|
16298
16285
|
Object.assign(this, Path.ownDefaults);
|
|
16299
16286
|
this.setOptions(options);
|
|
@@ -16429,7 +16416,7 @@ class Path extends FabricObject {
|
|
|
16429
16416
|
toClipPathSVG(reviver) {
|
|
16430
16417
|
const additionalTransform = this._getOffsetTransform();
|
|
16431
16418
|
return '\t' + this._createBaseClipPathSVGMarkup(this._toSVG(), {
|
|
16432
|
-
reviver
|
|
16419
|
+
reviver,
|
|
16433
16420
|
additionalTransform: additionalTransform
|
|
16434
16421
|
});
|
|
16435
16422
|
}
|
|
@@ -16442,7 +16429,7 @@ class Path extends FabricObject {
|
|
|
16442
16429
|
toSVG(reviver) {
|
|
16443
16430
|
const additionalTransform = this._getOffsetTransform();
|
|
16444
16431
|
return this._createBaseSVGMarkup(this._toSVG(), {
|
|
16445
|
-
reviver
|
|
16432
|
+
reviver,
|
|
16446
16433
|
additionalTransform: additionalTransform
|
|
16447
16434
|
});
|
|
16448
16435
|
}
|
|
@@ -16865,7 +16852,7 @@ class PencilBrush extends BaseBrush {
|
|
|
16865
16852
|
}
|
|
16866
16853
|
}
|
|
16867
16854
|
|
|
16868
|
-
const _excluded$
|
|
16855
|
+
const _excluded$6 = ["left", "top", "radius"];
|
|
16869
16856
|
const CIRCLE_PROPS = ['radius', 'startAngle', 'endAngle', 'counterClockwise'];
|
|
16870
16857
|
const circleDefaultValues = {
|
|
16871
16858
|
radius: 0,
|
|
@@ -16999,7 +16986,7 @@ class Circle extends FabricObject {
|
|
|
16999
16986
|
top = 0,
|
|
17000
16987
|
radius = 0
|
|
17001
16988
|
} = _ref,
|
|
17002
|
-
otherParsedAttributes = _objectWithoutProperties(_ref, _excluded$
|
|
16989
|
+
otherParsedAttributes = _objectWithoutProperties(_ref, _excluded$6);
|
|
17003
16990
|
|
|
17004
16991
|
// this probably requires to be fixed for default origins not being top/left.
|
|
17005
16992
|
|
|
@@ -17382,7 +17369,7 @@ class PatternBrush extends PencilBrush {
|
|
|
17382
17369
|
}
|
|
17383
17370
|
}
|
|
17384
17371
|
|
|
17385
|
-
const _excluded$
|
|
17372
|
+
const _excluded$5 = ["x1", "y1", "x2", "y2"],
|
|
17386
17373
|
_excluded2$1 = ["x1", "y1", "x2", "y2"];
|
|
17387
17374
|
// @TODO this code is terrible and Line should be a special case of polyline.
|
|
17388
17375
|
|
|
@@ -17594,7 +17581,7 @@ class Line extends FabricObject {
|
|
|
17594
17581
|
x2 = 0,
|
|
17595
17582
|
y2 = 0
|
|
17596
17583
|
} = _parseAttributes,
|
|
17597
|
-
parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$
|
|
17584
|
+
parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$5);
|
|
17598
17585
|
return new this([x1, y1, x2, y2], parsedAttributes);
|
|
17599
17586
|
}
|
|
17600
17587
|
|
|
@@ -17860,7 +17847,7 @@ function parsePointsAttribute(points) {
|
|
|
17860
17847
|
return parsedPoints;
|
|
17861
17848
|
}
|
|
17862
17849
|
|
|
17863
|
-
const _excluded$
|
|
17850
|
+
const _excluded$4 = ["left", "top"];
|
|
17864
17851
|
const polylineDefaultValues = {
|
|
17865
17852
|
/**
|
|
17866
17853
|
* @deprecated transient option soon to be removed in favor of a different design
|
|
@@ -18143,7 +18130,7 @@ class Polyline extends FabricObject {
|
|
|
18143
18130
|
static async fromElement(element, options, cssRules) {
|
|
18144
18131
|
const points = parsePointsAttribute(element.getAttribute('points')),
|
|
18145
18132
|
_parseAttributes = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules),
|
|
18146
|
-
parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$
|
|
18133
|
+
parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$4);
|
|
18147
18134
|
return new this(points, _objectSpread2(_objectSpread2({}, parsedAttributes), options));
|
|
18148
18135
|
}
|
|
18149
18136
|
|
|
@@ -18735,7 +18722,7 @@ class TextSVGExportMixin extends FabricObjectSVGExportMixin {
|
|
|
18735
18722
|
}
|
|
18736
18723
|
}
|
|
18737
18724
|
|
|
18738
|
-
const _excluded$
|
|
18725
|
+
const _excluded$3 = ["textAnchor", "textDecoration", "dx", "dy", "top", "left", "fontSize", "strokeWidth"];
|
|
18739
18726
|
let measuringContext;
|
|
18740
18727
|
|
|
18741
18728
|
/**
|
|
@@ -19939,7 +19926,7 @@ class FabricText extends StyledText {
|
|
|
19939
19926
|
fontSize = DEFAULT_SVG_FONT_SIZE,
|
|
19940
19927
|
strokeWidth = 1
|
|
19941
19928
|
} = _options$parsedAttrib,
|
|
19942
|
-
restOfOptions = _objectWithoutProperties(_options$parsedAttrib, _excluded$
|
|
19929
|
+
restOfOptions = _objectWithoutProperties(_options$parsedAttrib, _excluded$3);
|
|
19943
19930
|
const textContent = (element.textContent || '').replace(/^\s+|\s+$|\n+/g, '').replace(/\s+/g, ' ');
|
|
19944
19931
|
|
|
19945
19932
|
// this code here is probably the usual issue for SVG center find
|
|
@@ -23306,7 +23293,6 @@ class ActiveSelectionLayoutManager extends LayoutManager {
|
|
|
23306
23293
|
}
|
|
23307
23294
|
}
|
|
23308
23295
|
|
|
23309
|
-
const _excluded$6 = ["layoutManager"];
|
|
23310
23296
|
const activeSelectionDefaultValues = {
|
|
23311
23297
|
multiSelectionStacking: 'canvas-stacking'
|
|
23312
23298
|
};
|
|
@@ -23342,16 +23328,20 @@ class ActiveSelection extends Group {
|
|
|
23342
23328
|
|
|
23343
23329
|
constructor() {
|
|
23344
23330
|
let objects = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
23345
|
-
let
|
|
23346
|
-
|
|
23347
|
-
layoutManager
|
|
23348
|
-
} = _ref,
|
|
23349
|
-
options = _objectWithoutProperties(_ref, _excluded$6);
|
|
23350
|
-
super(objects, {
|
|
23351
|
-
layoutManager: layoutManager !== null && layoutManager !== void 0 ? layoutManager : new ActiveSelectionLayoutManager()
|
|
23352
|
-
});
|
|
23331
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
23332
|
+
super();
|
|
23353
23333
|
Object.assign(this, ActiveSelection.ownDefaults);
|
|
23354
23334
|
this.setOptions(options);
|
|
23335
|
+
const {
|
|
23336
|
+
left,
|
|
23337
|
+
top,
|
|
23338
|
+
layoutManager
|
|
23339
|
+
} = options;
|
|
23340
|
+
this.groupInit(objects, {
|
|
23341
|
+
left,
|
|
23342
|
+
top,
|
|
23343
|
+
layoutManager: layoutManager !== null && layoutManager !== void 0 ? layoutManager : new ActiveSelectionLayoutManager()
|
|
23344
|
+
});
|
|
23355
23345
|
}
|
|
23356
23346
|
|
|
23357
23347
|
/**
|
|
@@ -23931,7 +23921,7 @@ function setFilterBackend(backend) {
|
|
|
23931
23921
|
filterBackend = backend;
|
|
23932
23922
|
}
|
|
23933
23923
|
|
|
23934
|
-
const _excluded$
|
|
23924
|
+
const _excluded$2 = ["filters", "resizeFilter", "src", "crossOrigin", "type"];
|
|
23935
23925
|
|
|
23936
23926
|
// @todo Would be nice to have filtering code not imported directly.
|
|
23937
23927
|
|
|
@@ -24514,7 +24504,7 @@ class FabricImage extends FabricObject {
|
|
|
24514
24504
|
crossOrigin,
|
|
24515
24505
|
type
|
|
24516
24506
|
} = _ref,
|
|
24517
|
-
object = _objectWithoutProperties(_ref, _excluded$
|
|
24507
|
+
object = _objectWithoutProperties(_ref, _excluded$2);
|
|
24518
24508
|
return Promise.all([loadImage(src, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
24519
24509
|
crossOrigin
|
|
24520
24510
|
})), f && enlivenObjects(f, options),
|
|
@@ -25284,9 +25274,9 @@ const isPutImageFaster = (width, height) => {
|
|
|
25284
25274
|
|
|
25285
25275
|
const highPsourceCode = "precision highp float";
|
|
25286
25276
|
const identityFragmentShader = "\n ".concat(highPsourceCode, ";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }");
|
|
25287
|
-
const vertexSource = "\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n void main() {\n vTexCoord = aPosition;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }";
|
|
25277
|
+
const vertexSource$1 = "\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n void main() {\n vTexCoord = aPosition;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }";
|
|
25288
25278
|
|
|
25289
|
-
const _excluded$
|
|
25279
|
+
const _excluded$1 = ["type"],
|
|
25290
25280
|
_excluded2 = ["type"];
|
|
25291
25281
|
const regex = new RegExp(highPsourceCode, 'g');
|
|
25292
25282
|
class BaseFilter {
|
|
@@ -25307,30 +25297,21 @@ class BaseFilter {
|
|
|
25307
25297
|
* to avoid doing that.
|
|
25308
25298
|
*/
|
|
25309
25299
|
|
|
25310
|
-
/**
|
|
25311
|
-
* Name of the parameter that can be changed in the filter.
|
|
25312
|
-
* Some filters have more than one parameter and there is no
|
|
25313
|
-
* mainParameter
|
|
25314
|
-
* @private
|
|
25315
|
-
*/
|
|
25316
|
-
|
|
25317
25300
|
/**
|
|
25318
25301
|
* Constructor
|
|
25319
25302
|
* @param {Object} [options] Options object
|
|
25320
25303
|
*/
|
|
25321
25304
|
constructor() {
|
|
25322
25305
|
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
25323
|
-
options = _objectWithoutProperties(_ref, _excluded$
|
|
25324
|
-
/**
|
|
25325
|
-
* Array of attributes to send with buffers. do not modify
|
|
25326
|
-
* @private
|
|
25327
|
-
*/
|
|
25328
|
-
_defineProperty(this, "vertexSource", vertexSource);
|
|
25306
|
+
options = _objectWithoutProperties(_ref, _excluded$1);
|
|
25329
25307
|
Object.assign(this, this.constructor.defaults, options);
|
|
25330
25308
|
}
|
|
25331
25309
|
getFragmentSource() {
|
|
25332
25310
|
return identityFragmentShader;
|
|
25333
25311
|
}
|
|
25312
|
+
getVertexSource() {
|
|
25313
|
+
return vertexSource$1;
|
|
25314
|
+
}
|
|
25334
25315
|
|
|
25335
25316
|
/**
|
|
25336
25317
|
* Compile this filter's shader program.
|
|
@@ -25341,7 +25322,7 @@ class BaseFilter {
|
|
|
25341
25322
|
*/
|
|
25342
25323
|
createProgram(gl) {
|
|
25343
25324
|
let fragmentSource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFragmentSource();
|
|
25344
|
-
let vertexSource = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.
|
|
25325
|
+
let vertexSource = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getVertexSource();
|
|
25345
25326
|
const {
|
|
25346
25327
|
WebGLProbe: {
|
|
25347
25328
|
GLPrecision = 'highp'
|
|
@@ -25398,14 +25379,17 @@ class BaseFilter {
|
|
|
25398
25379
|
/**
|
|
25399
25380
|
* Return a map of uniform names to WebGLUniformLocation objects.
|
|
25400
25381
|
*
|
|
25401
|
-
* Intended to be overridden by subclasses.
|
|
25402
|
-
*
|
|
25403
25382
|
* @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.
|
|
25404
25383
|
* @param {WebGLShaderProgram} program The shader program from which to take uniform locations.
|
|
25405
25384
|
* @returns {Object} A map of uniform names to uniform locations.
|
|
25406
25385
|
*/
|
|
25407
25386
|
getUniformLocations(gl, program) {
|
|
25408
|
-
|
|
25387
|
+
const locations = this.constructor.uniformLocations;
|
|
25388
|
+
const uniformLocations = {};
|
|
25389
|
+
for (let i = 0; i < locations.length; i++) {
|
|
25390
|
+
uniformLocations[locations[i]] = gl.getUniformLocation(program, locations[i]);
|
|
25391
|
+
}
|
|
25392
|
+
return uniformLocations;
|
|
25409
25393
|
}
|
|
25410
25394
|
|
|
25411
25395
|
/**
|
|
@@ -25455,18 +25439,7 @@ class BaseFilter {
|
|
|
25455
25439
|
**/
|
|
25456
25440
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25457
25441
|
isNeutralState(options) {
|
|
25458
|
-
|
|
25459
|
-
defaultValue = this.constructor.defaults[main];
|
|
25460
|
-
if (main) {
|
|
25461
|
-
const thisValue = this[main];
|
|
25462
|
-
if (Array.isArray(defaultValue) && Array.isArray(thisValue)) {
|
|
25463
|
-
return defaultValue.every((value, i) => value === thisValue[i]);
|
|
25464
|
-
} else {
|
|
25465
|
-
return defaultValue === thisValue;
|
|
25466
|
-
}
|
|
25467
|
-
} else {
|
|
25468
|
-
return false;
|
|
25469
|
-
}
|
|
25442
|
+
return false;
|
|
25470
25443
|
}
|
|
25471
25444
|
|
|
25472
25445
|
/**
|
|
@@ -25558,14 +25531,6 @@ class BaseFilter {
|
|
|
25558
25531
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
25559
25532
|
gl.activeTexture(gl.TEXTURE0);
|
|
25560
25533
|
}
|
|
25561
|
-
getMainParameter() {
|
|
25562
|
-
return this.mainParameter ? this[this.mainParameter] : undefined;
|
|
25563
|
-
}
|
|
25564
|
-
setMainParameter(value) {
|
|
25565
|
-
if (this.mainParameter) {
|
|
25566
|
-
this[this.mainParameter] = value;
|
|
25567
|
-
}
|
|
25568
|
-
}
|
|
25569
25534
|
|
|
25570
25535
|
/**
|
|
25571
25536
|
* Send uniform data from this filter to its shader program on the GPU.
|
|
@@ -25597,12 +25562,14 @@ class BaseFilter {
|
|
|
25597
25562
|
* @return {Object} Object representation of an instance
|
|
25598
25563
|
*/
|
|
25599
25564
|
toObject() {
|
|
25600
|
-
const
|
|
25565
|
+
const defaultKeys = Object.keys(this.constructor.defaults);
|
|
25601
25566
|
return _objectSpread2({
|
|
25602
25567
|
type: this.type
|
|
25603
|
-
},
|
|
25604
|
-
|
|
25605
|
-
|
|
25568
|
+
}, defaultKeys.reduce((acc, key) => {
|
|
25569
|
+
//@ts-expect-error TS doesn't get i want an object that looks like this
|
|
25570
|
+
acc[key] = this[key];
|
|
25571
|
+
return acc;
|
|
25572
|
+
}, {}));
|
|
25606
25573
|
}
|
|
25607
25574
|
|
|
25608
25575
|
/**
|
|
@@ -25619,6 +25586,12 @@ class BaseFilter {
|
|
|
25619
25586
|
}
|
|
25620
25587
|
}
|
|
25621
25588
|
_defineProperty(BaseFilter, "type", 'BaseFilter');
|
|
25589
|
+
/**
|
|
25590
|
+
* Contains the uniform locations for the fragment shader.
|
|
25591
|
+
* uStepW and uStepH are handled by the BaseFilter, each filter class
|
|
25592
|
+
* needs to specify all the one that are needed
|
|
25593
|
+
*/
|
|
25594
|
+
_defineProperty(BaseFilter, "uniformLocations", []);
|
|
25622
25595
|
|
|
25623
25596
|
const blendColorFragmentSource = {
|
|
25624
25597
|
multiply: 'gl_FragColor.rgb *= uColor.rgb;\n',
|
|
@@ -25738,18 +25711,6 @@ class BlendColor extends BaseFilter {
|
|
|
25738
25711
|
}
|
|
25739
25712
|
}
|
|
25740
25713
|
|
|
25741
|
-
/**
|
|
25742
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
25743
|
-
*
|
|
25744
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
25745
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
25746
|
-
*/
|
|
25747
|
-
getUniformLocations(gl, program) {
|
|
25748
|
-
return {
|
|
25749
|
-
uColor: gl.getUniformLocation(program, 'uColor')
|
|
25750
|
-
};
|
|
25751
|
-
}
|
|
25752
|
-
|
|
25753
25714
|
/**
|
|
25754
25715
|
* Send data from this filter to its shader program's uniforms.
|
|
25755
25716
|
*
|
|
@@ -25764,19 +25725,6 @@ class BlendColor extends BaseFilter {
|
|
|
25764
25725
|
source[3] = this.alpha;
|
|
25765
25726
|
gl.uniform4fv(uniformLocations.uColor, source);
|
|
25766
25727
|
}
|
|
25767
|
-
|
|
25768
|
-
/**
|
|
25769
|
-
* Returns object representation of an instance
|
|
25770
|
-
* @return {Object} Object representation of an instance
|
|
25771
|
-
*/
|
|
25772
|
-
toObject() {
|
|
25773
|
-
return {
|
|
25774
|
-
type: this.type,
|
|
25775
|
-
color: this.color,
|
|
25776
|
-
mode: this.mode,
|
|
25777
|
-
alpha: this.alpha
|
|
25778
|
-
};
|
|
25779
|
-
}
|
|
25780
25728
|
}
|
|
25781
25729
|
/**
|
|
25782
25730
|
* Color to make the blend operation with. default to a reddish color since black or white
|
|
@@ -25797,18 +25745,19 @@ class BlendColor extends BaseFilter {
|
|
|
25797
25745
|
**/
|
|
25798
25746
|
_defineProperty(BlendColor, "defaults", blendColorDefaultValues);
|
|
25799
25747
|
_defineProperty(BlendColor, "type", 'BlendColor');
|
|
25748
|
+
_defineProperty(BlendColor, "uniformLocations", ['uColor']);
|
|
25800
25749
|
classRegistry.setClass(BlendColor);
|
|
25801
25750
|
|
|
25802
25751
|
const fragmentSource$c = {
|
|
25803
25752
|
multiply: "\n precision highp float;\n uniform sampler2D uTexture;\n uniform sampler2D uImage;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec4 color2 = texture2D(uImage, vTexCoord2);\n color.rgba *= color2.rgba;\n gl_FragColor = color;\n }\n ",
|
|
25804
25753
|
mask: "\n precision highp float;\n uniform sampler2D uTexture;\n uniform sampler2D uImage;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec4 color2 = texture2D(uImage, vTexCoord2);\n color.a = color2.a;\n gl_FragColor = color;\n }\n "
|
|
25805
25754
|
};
|
|
25755
|
+
const vertexSource = "\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n ";
|
|
25806
25756
|
|
|
25807
|
-
const _excluded
|
|
25757
|
+
const _excluded = ["type", "image"];
|
|
25808
25758
|
const blendImageDefaultValues = {
|
|
25809
25759
|
mode: 'multiply',
|
|
25810
|
-
alpha: 1
|
|
25811
|
-
vertexSource: "\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n "
|
|
25760
|
+
alpha: 1
|
|
25812
25761
|
};
|
|
25813
25762
|
|
|
25814
25763
|
/**
|
|
@@ -25834,6 +25783,9 @@ class BlendImage extends BaseFilter {
|
|
|
25834
25783
|
getFragmentSource() {
|
|
25835
25784
|
return fragmentSource$c[this.mode];
|
|
25836
25785
|
}
|
|
25786
|
+
getVertexSource() {
|
|
25787
|
+
return vertexSource;
|
|
25788
|
+
}
|
|
25837
25789
|
applyToWebGL(options) {
|
|
25838
25790
|
const gl = options.context,
|
|
25839
25791
|
texture = this.createTexture(options.filterBackend, this.image);
|
|
@@ -25915,19 +25867,6 @@ class BlendImage extends BaseFilter {
|
|
|
25915
25867
|
}
|
|
25916
25868
|
}
|
|
25917
25869
|
|
|
25918
|
-
/**
|
|
25919
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
25920
|
-
*
|
|
25921
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
25922
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
25923
|
-
*/
|
|
25924
|
-
getUniformLocations(gl, program) {
|
|
25925
|
-
return {
|
|
25926
|
-
uTransformMatrix: gl.getUniformLocation(program, 'uTransformMatrix'),
|
|
25927
|
-
uImage: gl.getUniformLocation(program, 'uImage')
|
|
25928
|
-
};
|
|
25929
|
-
}
|
|
25930
|
-
|
|
25931
25870
|
/**
|
|
25932
25871
|
* Send data from this filter to its shader program's uniforms.
|
|
25933
25872
|
*
|
|
@@ -25942,15 +25881,14 @@ class BlendImage extends BaseFilter {
|
|
|
25942
25881
|
|
|
25943
25882
|
/**
|
|
25944
25883
|
* Returns object representation of an instance
|
|
25884
|
+
* TODO: Handle the possibility of missing image better.
|
|
25885
|
+
* As of now a BlendImage filter without image can't be used with fromObject
|
|
25945
25886
|
* @return {Object} Object representation of an instance
|
|
25946
25887
|
*/
|
|
25947
25888
|
toObject() {
|
|
25948
|
-
return {
|
|
25949
|
-
|
|
25950
|
-
|
|
25951
|
-
mode: this.mode,
|
|
25952
|
-
alpha: this.alpha
|
|
25953
|
-
};
|
|
25889
|
+
return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
|
|
25890
|
+
image: this.image && this.image.toObject()
|
|
25891
|
+
});
|
|
25954
25892
|
}
|
|
25955
25893
|
|
|
25956
25894
|
/**
|
|
@@ -25961,12 +25899,12 @@ class BlendImage extends BaseFilter {
|
|
|
25961
25899
|
* @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
|
|
25962
25900
|
* @returns {Promise<BlendImage>}
|
|
25963
25901
|
*/
|
|
25964
|
-
static fromObject(_ref2, options) {
|
|
25902
|
+
static async fromObject(_ref2, options) {
|
|
25965
25903
|
let {
|
|
25966
25904
|
type,
|
|
25967
25905
|
image
|
|
25968
25906
|
} = _ref2,
|
|
25969
|
-
filterOptions = _objectWithoutProperties(_ref2, _excluded
|
|
25907
|
+
filterOptions = _objectWithoutProperties(_ref2, _excluded);
|
|
25970
25908
|
return FabricImage.fromObject(image, options).then(enlivedImage => new this(_objectSpread2(_objectSpread2({}, filterOptions), {}, {
|
|
25971
25909
|
image: enlivedImage
|
|
25972
25910
|
})));
|
|
@@ -25990,13 +25928,13 @@ class BlendImage extends BaseFilter {
|
|
|
25990
25928
|
**/
|
|
25991
25929
|
_defineProperty(BlendImage, "type", 'BlendImage');
|
|
25992
25930
|
_defineProperty(BlendImage, "defaults", blendImageDefaultValues);
|
|
25931
|
+
_defineProperty(BlendImage, "uniformLocations", ['uTransformMatrix', 'uImage']);
|
|
25993
25932
|
classRegistry.setClass(BlendImage);
|
|
25994
25933
|
|
|
25995
25934
|
const fragmentSource$b = "\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n const float nSamples = 15.0;\n vec3 v3offset = vec3(12.9898, 78.233, 151.7182);\n float random(vec3 scale) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n }\n void main() {\n vec4 color = vec4(0.0);\n float total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n ";
|
|
25996
25935
|
|
|
25997
25936
|
const blurDefaultValues = {
|
|
25998
|
-
blur: 0
|
|
25999
|
-
mainParameter: 'blur'
|
|
25937
|
+
blur: 0
|
|
26000
25938
|
};
|
|
26001
25939
|
|
|
26002
25940
|
/**
|
|
@@ -26091,18 +26029,6 @@ class Blur extends BaseFilter {
|
|
|
26091
26029
|
return newImageData;
|
|
26092
26030
|
}
|
|
26093
26031
|
|
|
26094
|
-
/**
|
|
26095
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
26096
|
-
*
|
|
26097
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
26098
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
26099
|
-
*/
|
|
26100
|
-
getUniformLocations(gl, program) {
|
|
26101
|
-
return {
|
|
26102
|
-
delta: gl.getUniformLocation(program, 'uDelta')
|
|
26103
|
-
};
|
|
26104
|
-
}
|
|
26105
|
-
|
|
26106
26032
|
/**
|
|
26107
26033
|
* Send data from this filter to its shader program's uniforms.
|
|
26108
26034
|
*
|
|
@@ -26113,6 +26039,9 @@ class Blur extends BaseFilter {
|
|
|
26113
26039
|
const delta = this.chooseRightDelta();
|
|
26114
26040
|
gl.uniform2fv(uniformLocations.delta, delta);
|
|
26115
26041
|
}
|
|
26042
|
+
isNeutralState() {
|
|
26043
|
+
return this.blur === 0;
|
|
26044
|
+
}
|
|
26116
26045
|
|
|
26117
26046
|
/**
|
|
26118
26047
|
* choose right value of image percentage to blur with
|
|
@@ -26150,13 +26079,13 @@ class Blur extends BaseFilter {
|
|
|
26150
26079
|
*/
|
|
26151
26080
|
_defineProperty(Blur, "type", 'Blur');
|
|
26152
26081
|
_defineProperty(Blur, "defaults", blurDefaultValues);
|
|
26082
|
+
_defineProperty(Blur, "uniformLocations", ['uDelta']);
|
|
26153
26083
|
classRegistry.setClass(Blur);
|
|
26154
26084
|
|
|
26155
26085
|
const fragmentSource$a = "\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uBrightness;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color.rgb += uBrightness;\n gl_FragColor = color;\n }\n";
|
|
26156
26086
|
|
|
26157
26087
|
const brightnessDefaultValues = {
|
|
26158
|
-
brightness: 0
|
|
26159
|
-
mainParameter: 'brightness'
|
|
26088
|
+
brightness: 0
|
|
26160
26089
|
};
|
|
26161
26090
|
|
|
26162
26091
|
/**
|
|
@@ -26185,9 +26114,6 @@ class Brightness extends BaseFilter {
|
|
|
26185
26114
|
data
|
|
26186
26115
|
}
|
|
26187
26116
|
} = _ref;
|
|
26188
|
-
if (this.brightness === 0) {
|
|
26189
|
-
return;
|
|
26190
|
-
}
|
|
26191
26117
|
const brightness = Math.round(this.brightness * 255);
|
|
26192
26118
|
for (let i = 0; i < data.length; i += 4) {
|
|
26193
26119
|
data[i] = data[i] + brightness;
|
|
@@ -26195,17 +26121,8 @@ class Brightness extends BaseFilter {
|
|
|
26195
26121
|
data[i + 2] = data[i + 2] + brightness;
|
|
26196
26122
|
}
|
|
26197
26123
|
}
|
|
26198
|
-
|
|
26199
|
-
|
|
26200
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
26201
|
-
*
|
|
26202
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
26203
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
26204
|
-
*/
|
|
26205
|
-
getUniformLocations(gl, program) {
|
|
26206
|
-
return {
|
|
26207
|
-
uBrightness: gl.getUniformLocation(program, 'uBrightness')
|
|
26208
|
-
};
|
|
26124
|
+
isNeutralState() {
|
|
26125
|
+
return this.brightness === 0;
|
|
26209
26126
|
}
|
|
26210
26127
|
|
|
26211
26128
|
/**
|
|
@@ -26227,14 +26144,13 @@ class Brightness extends BaseFilter {
|
|
|
26227
26144
|
*/
|
|
26228
26145
|
_defineProperty(Brightness, "type", 'Brightness');
|
|
26229
26146
|
_defineProperty(Brightness, "defaults", brightnessDefaultValues);
|
|
26147
|
+
_defineProperty(Brightness, "uniformLocations", ['uBrightness']);
|
|
26230
26148
|
classRegistry.setClass(Brightness);
|
|
26231
26149
|
|
|
26232
26150
|
const fragmentSource$9 = "\n precision highp float;\n uniform sampler2D uTexture;\n varying vec2 vTexCoord;\n uniform mat4 uColorMatrix;\n uniform vec4 uConstants;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color *= uColorMatrix;\n color += uConstants;\n gl_FragColor = color;\n }";
|
|
26233
26151
|
|
|
26234
|
-
const _excluded$2 = ["matrix"];
|
|
26235
26152
|
const colorMatrixDefaultValues = {
|
|
26236
26153
|
matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
|
|
26237
|
-
mainParameter: 'matrix',
|
|
26238
26154
|
colorsOnly: true
|
|
26239
26155
|
};
|
|
26240
26156
|
|
|
@@ -26255,17 +26171,6 @@ const colorMatrixDefaultValues = {
|
|
|
26255
26171
|
* object.applyFilters();
|
|
26256
26172
|
*/
|
|
26257
26173
|
class ColorMatrix extends BaseFilter {
|
|
26258
|
-
setOptions(_ref) {
|
|
26259
|
-
let {
|
|
26260
|
-
matrix
|
|
26261
|
-
} = _ref,
|
|
26262
|
-
options = _objectWithoutProperties(_ref, _excluded$2);
|
|
26263
|
-
if (matrix) {
|
|
26264
|
-
// safeguard against mutation
|
|
26265
|
-
this.matrix = [...matrix];
|
|
26266
|
-
}
|
|
26267
|
-
Object.assign(this, options);
|
|
26268
|
-
}
|
|
26269
26174
|
getFragmentSource() {
|
|
26270
26175
|
return fragmentSource$9;
|
|
26271
26176
|
}
|
|
@@ -26299,19 +26204,6 @@ class ColorMatrix extends BaseFilter {
|
|
|
26299
26204
|
}
|
|
26300
26205
|
}
|
|
26301
26206
|
|
|
26302
|
-
/**
|
|
26303
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
26304
|
-
*
|
|
26305
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
26306
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
26307
|
-
*/
|
|
26308
|
-
getUniformLocations(gl, program) {
|
|
26309
|
-
return {
|
|
26310
|
-
uColorMatrix: gl.getUniformLocation(program, 'uColorMatrix'),
|
|
26311
|
-
uConstants: gl.getUniformLocation(program, 'uConstants')
|
|
26312
|
-
};
|
|
26313
|
-
}
|
|
26314
|
-
|
|
26315
26207
|
/**
|
|
26316
26208
|
* Send data from this filter to its shader program's uniforms.
|
|
26317
26209
|
*
|
|
@@ -26325,6 +26217,11 @@ class ColorMatrix extends BaseFilter {
|
|
|
26325
26217
|
gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);
|
|
26326
26218
|
gl.uniform4fv(uniformLocations.uConstants, constants);
|
|
26327
26219
|
}
|
|
26220
|
+
toObject() {
|
|
26221
|
+
return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
|
|
26222
|
+
matrix: [...this.matrix]
|
|
26223
|
+
});
|
|
26224
|
+
}
|
|
26328
26225
|
}
|
|
26329
26226
|
/**
|
|
26330
26227
|
* Colormatrix for pixels.
|
|
@@ -26342,17 +26239,23 @@ class ColorMatrix extends BaseFilter {
|
|
|
26342
26239
|
*/
|
|
26343
26240
|
_defineProperty(ColorMatrix, "type", 'ColorMatrix');
|
|
26344
26241
|
_defineProperty(ColorMatrix, "defaults", colorMatrixDefaultValues);
|
|
26242
|
+
_defineProperty(ColorMatrix, "uniformLocations", ['uColorMatrix', 'uConstants']);
|
|
26345
26243
|
classRegistry.setClass(ColorMatrix);
|
|
26346
26244
|
|
|
26347
26245
|
function createColorMatrixFilter(key, matrix) {
|
|
26348
26246
|
var _class;
|
|
26349
|
-
const newClass = (_class = class newClass extends ColorMatrix {
|
|
26350
|
-
|
|
26351
|
-
|
|
26352
|
-
|
|
26353
|
-
|
|
26247
|
+
const newClass = (_class = class newClass extends ColorMatrix {
|
|
26248
|
+
//@ts-expect-error TS wants matrix to be exported.
|
|
26249
|
+
toObject() {
|
|
26250
|
+
return {
|
|
26251
|
+
type: this.type,
|
|
26252
|
+
colorsOnly: this.colorsOnly
|
|
26253
|
+
};
|
|
26254
|
+
}
|
|
26255
|
+
}, _defineProperty(_class, "type", key), _defineProperty(_class, "defaults", {
|
|
26256
|
+
colorsOnly: false,
|
|
26354
26257
|
matrix
|
|
26355
|
-
})
|
|
26258
|
+
}), _class);
|
|
26356
26259
|
classRegistry.setClass(newClass, key);
|
|
26357
26260
|
return newClass;
|
|
26358
26261
|
}
|
|
@@ -26364,20 +26267,14 @@ const Polaroid = createColorMatrixFilter('Polaroid', [1.438, -0.062, -0.062, 0,
|
|
|
26364
26267
|
const Sepia = createColorMatrixFilter('Sepia', [0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131, 0, 0, 0, 0, 0, 1, 0]);
|
|
26365
26268
|
const BlackWhite = createColorMatrixFilter('BlackWhite', [1.5, 1.5, 1.5, 0, -1, 1.5, 1.5, 1.5, 0, -1, 1.5, 1.5, 1.5, 0, -1, 0, 0, 0, 1, 0]);
|
|
26366
26269
|
|
|
26367
|
-
const _excluded$1 = ["subFilters"];
|
|
26368
|
-
|
|
26369
26270
|
/**
|
|
26370
26271
|
* A container class that knows how to apply a sequence of filters to an input image.
|
|
26371
26272
|
*/
|
|
26372
26273
|
class Composed extends BaseFilter {
|
|
26373
26274
|
constructor() {
|
|
26374
|
-
let
|
|
26375
|
-
{
|
|
26376
|
-
subFilters = []
|
|
26377
|
-
} = _ref,
|
|
26378
|
-
options = _objectWithoutProperties(_ref, _excluded$1);
|
|
26275
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26379
26276
|
super(options);
|
|
26380
|
-
this.subFilters = subFilters;
|
|
26277
|
+
this.subFilters = options.subFilters || [];
|
|
26381
26278
|
}
|
|
26382
26279
|
|
|
26383
26280
|
/**
|
|
@@ -26397,13 +26294,14 @@ class Composed extends BaseFilter {
|
|
|
26397
26294
|
|
|
26398
26295
|
/**
|
|
26399
26296
|
* Serialize this filter into JSON.
|
|
26400
|
-
*
|
|
26401
26297
|
* @returns {Object} A JSON representation of this filter.
|
|
26402
26298
|
*/
|
|
26299
|
+
//@ts-expect-error TS doesn't like this toObject
|
|
26403
26300
|
toObject() {
|
|
26404
|
-
return
|
|
26301
|
+
return {
|
|
26302
|
+
type: this.type,
|
|
26405
26303
|
subFilters: this.subFilters.map(filter => filter.toObject())
|
|
26406
|
-
}
|
|
26304
|
+
};
|
|
26407
26305
|
}
|
|
26408
26306
|
isNeutralState() {
|
|
26409
26307
|
return !this.subFilters.some(filter => !filter.isNeutralState());
|
|
@@ -26432,8 +26330,7 @@ classRegistry.setClass(Composed);
|
|
|
26432
26330
|
const fragmentSource$8 = "\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uContrast;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\n color.rgb = contrastF * (color.rgb - 0.5) + 0.5;\n gl_FragColor = color;\n }";
|
|
26433
26331
|
|
|
26434
26332
|
const contrastDefaultValues = {
|
|
26435
|
-
contrast: 0
|
|
26436
|
-
mainParameter: 'contrast'
|
|
26333
|
+
contrast: 0
|
|
26437
26334
|
};
|
|
26438
26335
|
|
|
26439
26336
|
/**
|
|
@@ -26449,6 +26346,10 @@ class Contrast extends BaseFilter {
|
|
|
26449
26346
|
getFragmentSource() {
|
|
26450
26347
|
return fragmentSource$8;
|
|
26451
26348
|
}
|
|
26349
|
+
isNeutralState() {
|
|
26350
|
+
return this.contrast === 0;
|
|
26351
|
+
}
|
|
26352
|
+
|
|
26452
26353
|
/**
|
|
26453
26354
|
* Apply the Contrast operation to a Uint8Array representing the pixels of an image.
|
|
26454
26355
|
*
|
|
@@ -26461,9 +26362,6 @@ class Contrast extends BaseFilter {
|
|
|
26461
26362
|
data
|
|
26462
26363
|
}
|
|
26463
26364
|
} = _ref;
|
|
26464
|
-
if (this.contrast === 0) {
|
|
26465
|
-
return;
|
|
26466
|
-
}
|
|
26467
26365
|
const contrast = Math.floor(this.contrast * 255),
|
|
26468
26366
|
contrastF = 259 * (contrast + 255) / (255 * (259 - contrast));
|
|
26469
26367
|
for (let i = 0; i < data.length; i += 4) {
|
|
@@ -26473,18 +26371,6 @@ class Contrast extends BaseFilter {
|
|
|
26473
26371
|
}
|
|
26474
26372
|
}
|
|
26475
26373
|
|
|
26476
|
-
/**
|
|
26477
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
26478
|
-
*
|
|
26479
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
26480
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
26481
|
-
*/
|
|
26482
|
-
getUniformLocations(gl, program) {
|
|
26483
|
-
return {
|
|
26484
|
-
uContrast: gl.getUniformLocation(program, 'uContrast')
|
|
26485
|
-
};
|
|
26486
|
-
}
|
|
26487
|
-
|
|
26488
26374
|
/**
|
|
26489
26375
|
* Send data from this filter to its shader program's uniforms.
|
|
26490
26376
|
*
|
|
@@ -26502,6 +26388,7 @@ class Contrast extends BaseFilter {
|
|
|
26502
26388
|
*/
|
|
26503
26389
|
_defineProperty(Contrast, "type", 'Contrast');
|
|
26504
26390
|
_defineProperty(Contrast, "defaults", contrastDefaultValues);
|
|
26391
|
+
_defineProperty(Contrast, "uniformLocations", ['uContrast']);
|
|
26505
26392
|
classRegistry.setClass(Contrast);
|
|
26506
26393
|
|
|
26507
26394
|
const fragmentSource$7 = {
|
|
@@ -26629,21 +26516,6 @@ class Convolute extends BaseFilter {
|
|
|
26629
26516
|
options.imageData = output;
|
|
26630
26517
|
}
|
|
26631
26518
|
|
|
26632
|
-
/**
|
|
26633
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
26634
|
-
*
|
|
26635
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
26636
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
26637
|
-
*/
|
|
26638
|
-
getUniformLocations(gl, program) {
|
|
26639
|
-
return {
|
|
26640
|
-
uMatrix: gl.getUniformLocation(program, 'uMatrix'),
|
|
26641
|
-
uOpaque: gl.getUniformLocation(program, 'uOpaque'),
|
|
26642
|
-
uHalfSize: gl.getUniformLocation(program, 'uHalfSize'),
|
|
26643
|
-
uSize: gl.getUniformLocation(program, 'uSize')
|
|
26644
|
-
};
|
|
26645
|
-
}
|
|
26646
|
-
|
|
26647
26519
|
/**
|
|
26648
26520
|
* Send data from this filter to its shader program's uniforms.
|
|
26649
26521
|
*
|
|
@@ -26673,13 +26545,13 @@ class Convolute extends BaseFilter {
|
|
|
26673
26545
|
*/
|
|
26674
26546
|
_defineProperty(Convolute, "type", 'Convolute');
|
|
26675
26547
|
_defineProperty(Convolute, "defaults", convoluteDefaultValues);
|
|
26548
|
+
_defineProperty(Convolute, "uniformLocations", ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize']);
|
|
26676
26549
|
classRegistry.setClass(Convolute);
|
|
26677
26550
|
|
|
26678
26551
|
const fragmentSource$6 = "\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec3 uGamma;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec3 correction = (1.0 / uGamma);\n color.r = pow(color.r, correction.r);\n color.g = pow(color.g, correction.g);\n color.b = pow(color.b, correction.b);\n gl_FragColor = color;\n gl_FragColor.rgb *= color.a;\n }\n";
|
|
26679
26552
|
|
|
26680
|
-
const
|
|
26553
|
+
const GAMMA = 'Gamma';
|
|
26681
26554
|
const gammaDefaultValues = {
|
|
26682
|
-
mainParameter: 'gamma',
|
|
26683
26555
|
gamma: [1, 1, 1]
|
|
26684
26556
|
};
|
|
26685
26557
|
|
|
@@ -26697,13 +26569,9 @@ class Gamma extends BaseFilter {
|
|
|
26697
26569
|
return fragmentSource$6;
|
|
26698
26570
|
}
|
|
26699
26571
|
constructor() {
|
|
26700
|
-
let
|
|
26701
|
-
{
|
|
26702
|
-
gamma = [1, 1, 1]
|
|
26703
|
-
} = _ref,
|
|
26704
|
-
options = _objectWithoutProperties(_ref, _excluded);
|
|
26572
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26705
26573
|
super(options);
|
|
26706
|
-
this.gamma = gamma;
|
|
26574
|
+
this.gamma = options.gamma || this.constructor.defaults.gamma.concat();
|
|
26707
26575
|
}
|
|
26708
26576
|
|
|
26709
26577
|
/**
|
|
@@ -26712,12 +26580,12 @@ class Gamma extends BaseFilter {
|
|
|
26712
26580
|
* @param {Object} options
|
|
26713
26581
|
* @param {ImageData} options.imageData The Uint8Array to be filtered.
|
|
26714
26582
|
*/
|
|
26715
|
-
applyTo2d(
|
|
26583
|
+
applyTo2d(_ref) {
|
|
26716
26584
|
let {
|
|
26717
26585
|
imageData: {
|
|
26718
26586
|
data
|
|
26719
26587
|
}
|
|
26720
|
-
} =
|
|
26588
|
+
} = _ref;
|
|
26721
26589
|
const gamma = this.gamma,
|
|
26722
26590
|
rInv = 1 / gamma[0],
|
|
26723
26591
|
gInv = 1 / gamma[1],
|
|
@@ -26745,18 +26613,6 @@ class Gamma extends BaseFilter {
|
|
|
26745
26613
|
}
|
|
26746
26614
|
}
|
|
26747
26615
|
|
|
26748
|
-
/**
|
|
26749
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
26750
|
-
*
|
|
26751
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
26752
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
26753
|
-
*/
|
|
26754
|
-
getUniformLocations(gl, program) {
|
|
26755
|
-
return {
|
|
26756
|
-
uGamma: gl.getUniformLocation(program, 'uGamma')
|
|
26757
|
-
};
|
|
26758
|
-
}
|
|
26759
|
-
|
|
26760
26616
|
/**
|
|
26761
26617
|
* Send data from this filter to its shader program's uniforms.
|
|
26762
26618
|
*
|
|
@@ -26766,14 +26622,27 @@ class Gamma extends BaseFilter {
|
|
|
26766
26622
|
sendUniformData(gl, uniformLocations) {
|
|
26767
26623
|
gl.uniform3fv(uniformLocations.uGamma, this.gamma);
|
|
26768
26624
|
}
|
|
26625
|
+
isNeutralState() {
|
|
26626
|
+
const {
|
|
26627
|
+
gamma
|
|
26628
|
+
} = this;
|
|
26629
|
+
return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;
|
|
26630
|
+
}
|
|
26631
|
+
toObject() {
|
|
26632
|
+
return {
|
|
26633
|
+
type: GAMMA,
|
|
26634
|
+
gamma: this.gamma.concat()
|
|
26635
|
+
};
|
|
26636
|
+
}
|
|
26769
26637
|
}
|
|
26770
26638
|
/**
|
|
26771
26639
|
* Gamma array value, from 0.01 to 2.2.
|
|
26772
26640
|
* @param {Array} gamma
|
|
26773
26641
|
* @default
|
|
26774
26642
|
*/
|
|
26775
|
-
_defineProperty(Gamma, "type",
|
|
26643
|
+
_defineProperty(Gamma, "type", GAMMA);
|
|
26776
26644
|
_defineProperty(Gamma, "defaults", gammaDefaultValues);
|
|
26645
|
+
_defineProperty(Gamma, "uniformLocations", ['uGamma']);
|
|
26777
26646
|
classRegistry.setClass(Gamma);
|
|
26778
26647
|
|
|
26779
26648
|
const fragmentSource$5 = {
|
|
@@ -26783,8 +26652,7 @@ const fragmentSource$5 = {
|
|
|
26783
26652
|
};
|
|
26784
26653
|
|
|
26785
26654
|
const grayscaleDefaultValues = {
|
|
26786
|
-
mode: 'average'
|
|
26787
|
-
mainParameter: 'mode'
|
|
26655
|
+
mode: 'average'
|
|
26788
26656
|
};
|
|
26789
26657
|
|
|
26790
26658
|
/**
|
|
@@ -26831,18 +26699,6 @@ class Grayscale extends BaseFilter {
|
|
|
26831
26699
|
return fragmentSource$5[this.mode];
|
|
26832
26700
|
}
|
|
26833
26701
|
|
|
26834
|
-
/**
|
|
26835
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
26836
|
-
*
|
|
26837
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
26838
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
26839
|
-
*/
|
|
26840
|
-
getUniformLocations(gl, program) {
|
|
26841
|
-
return {
|
|
26842
|
-
uMode: gl.getUniformLocation(program, 'uMode')
|
|
26843
|
-
};
|
|
26844
|
-
}
|
|
26845
|
-
|
|
26846
26702
|
/**
|
|
26847
26703
|
* Send data from this filter to its shader program's uniforms.
|
|
26848
26704
|
*
|
|
@@ -26865,11 +26721,11 @@ class Grayscale extends BaseFilter {
|
|
|
26865
26721
|
}
|
|
26866
26722
|
_defineProperty(Grayscale, "type", 'Grayscale');
|
|
26867
26723
|
_defineProperty(Grayscale, "defaults", grayscaleDefaultValues);
|
|
26724
|
+
_defineProperty(Grayscale, "uniformLocations", ['uMode']);
|
|
26868
26725
|
classRegistry.setClass(Grayscale);
|
|
26869
26726
|
|
|
26870
26727
|
const hueRotationDefaultValues = {
|
|
26871
|
-
rotation: 0
|
|
26872
|
-
mainParameter: 'rotation'
|
|
26728
|
+
rotation: 0
|
|
26873
26729
|
};
|
|
26874
26730
|
|
|
26875
26731
|
/**
|
|
@@ -26881,7 +26737,6 @@ const hueRotationDefaultValues = {
|
|
|
26881
26737
|
* object.filters.push(filter);
|
|
26882
26738
|
* object.applyFilters();
|
|
26883
26739
|
*/
|
|
26884
|
-
// @ts-expect-error some babbling about mainParameter
|
|
26885
26740
|
class HueRotation extends ColorMatrix {
|
|
26886
26741
|
calculateMatrix() {
|
|
26887
26742
|
const rad = this.rotation * Math.PI,
|
|
@@ -26902,13 +26757,20 @@ class HueRotation extends ColorMatrix {
|
|
|
26902
26757
|
this.matrix[12] = cosine + aThird * OneMinusCos;
|
|
26903
26758
|
}
|
|
26904
26759
|
isNeutralState() {
|
|
26905
|
-
this.
|
|
26906
|
-
return super.isNeutralState();
|
|
26760
|
+
return this.rotation === 0;
|
|
26907
26761
|
}
|
|
26908
26762
|
applyTo(options) {
|
|
26909
26763
|
this.calculateMatrix();
|
|
26910
26764
|
super.applyTo(options);
|
|
26911
26765
|
}
|
|
26766
|
+
|
|
26767
|
+
//@ts-expect-error TS and classes with different methods
|
|
26768
|
+
toObject() {
|
|
26769
|
+
return {
|
|
26770
|
+
type: this.type,
|
|
26771
|
+
rotation: this.rotation
|
|
26772
|
+
};
|
|
26773
|
+
}
|
|
26912
26774
|
}
|
|
26913
26775
|
/**
|
|
26914
26776
|
* HueRotation value, from -1 to 1.
|
|
@@ -26921,8 +26783,7 @@ const fragmentSource$4 = "\n precision highp float;\n uniform sampler2D uTextu
|
|
|
26921
26783
|
|
|
26922
26784
|
const invertDefaultValues = {
|
|
26923
26785
|
alpha: false,
|
|
26924
|
-
invert: true
|
|
26925
|
-
mainParameter: 'invert'
|
|
26786
|
+
invert: true
|
|
26926
26787
|
};
|
|
26927
26788
|
|
|
26928
26789
|
/**
|
|
@@ -26967,19 +26828,6 @@ class Invert extends BaseFilter {
|
|
|
26967
26828
|
return !this.invert;
|
|
26968
26829
|
}
|
|
26969
26830
|
|
|
26970
|
-
/**
|
|
26971
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
26972
|
-
*
|
|
26973
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
26974
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
26975
|
-
*/
|
|
26976
|
-
getUniformLocations(gl, program) {
|
|
26977
|
-
return {
|
|
26978
|
-
uInvert: gl.getUniformLocation(program, 'uInvert'),
|
|
26979
|
-
uAlpha: gl.getUniformLocation(program, 'uAlpha')
|
|
26980
|
-
};
|
|
26981
|
-
}
|
|
26982
|
-
|
|
26983
26831
|
/**
|
|
26984
26832
|
* Send data from this filter to its shader program's uniforms.
|
|
26985
26833
|
*
|
|
@@ -27003,12 +26851,12 @@ class Invert extends BaseFilter {
|
|
|
27003
26851
|
*/
|
|
27004
26852
|
_defineProperty(Invert, "type", 'Invert');
|
|
27005
26853
|
_defineProperty(Invert, "defaults", invertDefaultValues);
|
|
26854
|
+
_defineProperty(Invert, "uniformLocations", ['uInvert', 'uAlpha']);
|
|
27006
26855
|
classRegistry.setClass(Invert);
|
|
27007
26856
|
|
|
27008
26857
|
const fragmentSource$3 = "\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uStepH;\n uniform float uNoise;\n uniform float uSeed;\n varying vec2 vTexCoord;\n float rand(vec2 co, float seed, float vScale) {\n return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n }\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\n gl_FragColor = color;\n }\n";
|
|
27009
26858
|
|
|
27010
26859
|
const noiseDefaultValues = {
|
|
27011
|
-
mainParameter: 'noise',
|
|
27012
26860
|
noise: 0
|
|
27013
26861
|
};
|
|
27014
26862
|
|
|
@@ -27039,9 +26887,6 @@ class Noise extends BaseFilter {
|
|
|
27039
26887
|
data
|
|
27040
26888
|
}
|
|
27041
26889
|
} = _ref;
|
|
27042
|
-
if (this.noise === 0) {
|
|
27043
|
-
return;
|
|
27044
|
-
}
|
|
27045
26890
|
const noise = this.noise;
|
|
27046
26891
|
for (let i = 0; i < data.length; i += 4) {
|
|
27047
26892
|
const rand = (0.5 - Math.random()) * noise;
|
|
@@ -27051,19 +26896,6 @@ class Noise extends BaseFilter {
|
|
|
27051
26896
|
}
|
|
27052
26897
|
}
|
|
27053
26898
|
|
|
27054
|
-
/**
|
|
27055
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
27056
|
-
*
|
|
27057
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
27058
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
27059
|
-
*/
|
|
27060
|
-
getUniformLocations(gl, program) {
|
|
27061
|
-
return {
|
|
27062
|
-
uNoise: gl.getUniformLocation(program, 'uNoise'),
|
|
27063
|
-
uSeed: gl.getUniformLocation(program, 'uSeed')
|
|
27064
|
-
};
|
|
27065
|
-
}
|
|
27066
|
-
|
|
27067
26899
|
/**
|
|
27068
26900
|
* Send data from this filter to its shader program's uniforms.
|
|
27069
26901
|
*
|
|
@@ -27074,15 +26906,8 @@ class Noise extends BaseFilter {
|
|
|
27074
26906
|
gl.uniform1f(uniformLocations.uNoise, this.noise / 255);
|
|
27075
26907
|
gl.uniform1f(uniformLocations.uSeed, Math.random());
|
|
27076
26908
|
}
|
|
27077
|
-
|
|
27078
|
-
|
|
27079
|
-
* Returns object representation of an instance
|
|
27080
|
-
* @return {Object} Object representation of an instance
|
|
27081
|
-
*/
|
|
27082
|
-
toObject() {
|
|
27083
|
-
return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
|
|
27084
|
-
noise: this.noise
|
|
27085
|
-
});
|
|
26909
|
+
isNeutralState() {
|
|
26910
|
+
return this.noise === 0;
|
|
27086
26911
|
}
|
|
27087
26912
|
}
|
|
27088
26913
|
/**
|
|
@@ -27092,13 +26917,13 @@ class Noise extends BaseFilter {
|
|
|
27092
26917
|
*/
|
|
27093
26918
|
_defineProperty(Noise, "type", 'Noise');
|
|
27094
26919
|
_defineProperty(Noise, "defaults", noiseDefaultValues);
|
|
26920
|
+
_defineProperty(Noise, "uniformLocations", ['uNoise', 'uSeed']);
|
|
27095
26921
|
classRegistry.setClass(Noise);
|
|
27096
26922
|
|
|
27097
26923
|
const fragmentSource$2 = "\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uBlocksize;\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n float blockW = uBlocksize * uStepW;\n float blockH = uBlocksize * uStepW;\n int posX = int(vTexCoord.x / blockW);\n int posY = int(vTexCoord.y / blockH);\n float fposX = float(posX);\n float fposY = float(posY);\n vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\n vec4 color = texture2D(uTexture, squareCoords);\n gl_FragColor = color;\n }\n";
|
|
27098
26924
|
|
|
27099
26925
|
const pixelateDefaultValues = {
|
|
27100
|
-
blocksize: 4
|
|
27101
|
-
mainParameter: 'blocksize'
|
|
26926
|
+
blocksize: 4
|
|
27102
26927
|
};
|
|
27103
26928
|
|
|
27104
26929
|
/**
|
|
@@ -27155,20 +26980,6 @@ class Pixelate extends BaseFilter {
|
|
|
27155
26980
|
return fragmentSource$2;
|
|
27156
26981
|
}
|
|
27157
26982
|
|
|
27158
|
-
/**
|
|
27159
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
27160
|
-
*
|
|
27161
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
27162
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
27163
|
-
*/
|
|
27164
|
-
getUniformLocations(gl, program) {
|
|
27165
|
-
return {
|
|
27166
|
-
uBlocksize: gl.getUniformLocation(program, 'uBlocksize'),
|
|
27167
|
-
uStepW: gl.getUniformLocation(program, 'uStepW'),
|
|
27168
|
-
uStepH: gl.getUniformLocation(program, 'uStepH')
|
|
27169
|
-
};
|
|
27170
|
-
}
|
|
27171
|
-
|
|
27172
26983
|
/**
|
|
27173
26984
|
* Send data from this filter to its shader program's uniforms.
|
|
27174
26985
|
*
|
|
@@ -27181,6 +26992,7 @@ class Pixelate extends BaseFilter {
|
|
|
27181
26992
|
}
|
|
27182
26993
|
_defineProperty(Pixelate, "type", 'Pixelate');
|
|
27183
26994
|
_defineProperty(Pixelate, "defaults", pixelateDefaultValues);
|
|
26995
|
+
_defineProperty(Pixelate, "uniformLocations", ['uBlockSize']);
|
|
27184
26996
|
classRegistry.setClass(Pixelate);
|
|
27185
26997
|
|
|
27186
26998
|
const fragmentShader = "\nprecision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\n gl_FragColor.a = 0.0;\n }\n}\n";
|
|
@@ -27230,19 +27042,6 @@ class RemoveColor extends BaseFilter {
|
|
|
27230
27042
|
}
|
|
27231
27043
|
}
|
|
27232
27044
|
|
|
27233
|
-
/**
|
|
27234
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
27235
|
-
*
|
|
27236
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
27237
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
27238
|
-
*/
|
|
27239
|
-
getUniformLocations(gl, program) {
|
|
27240
|
-
return {
|
|
27241
|
-
uLow: gl.getUniformLocation(program, 'uLow'),
|
|
27242
|
-
uHigh: gl.getUniformLocation(program, 'uHigh')
|
|
27243
|
-
};
|
|
27244
|
-
}
|
|
27245
|
-
|
|
27246
27045
|
/**
|
|
27247
27046
|
* Send data from this filter to its shader program's uniforms.
|
|
27248
27047
|
*
|
|
@@ -27257,17 +27056,6 @@ class RemoveColor extends BaseFilter {
|
|
|
27257
27056
|
gl.uniform4fv(uniformLocations.uLow, lowC);
|
|
27258
27057
|
gl.uniform4fv(uniformLocations.uHigh, highC);
|
|
27259
27058
|
}
|
|
27260
|
-
|
|
27261
|
-
/**
|
|
27262
|
-
* Returns object representation of an instance
|
|
27263
|
-
* @return {Object} Object representation of an instance
|
|
27264
|
-
*/
|
|
27265
|
-
toObject() {
|
|
27266
|
-
return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
|
|
27267
|
-
color: this.color,
|
|
27268
|
-
distance: this.distance
|
|
27269
|
-
});
|
|
27270
|
-
}
|
|
27271
27059
|
}
|
|
27272
27060
|
/**
|
|
27273
27061
|
* Color to remove, in any format understood by {@link Color}.
|
|
@@ -27284,14 +27072,14 @@ class RemoveColor extends BaseFilter {
|
|
|
27284
27072
|
**/
|
|
27285
27073
|
_defineProperty(RemoveColor, "type", 'RemoveColor');
|
|
27286
27074
|
_defineProperty(RemoveColor, "defaults", removeColorDefaultValues);
|
|
27075
|
+
_defineProperty(RemoveColor, "uniformLocations", ['uLow', 'uHigh']);
|
|
27287
27076
|
classRegistry.setClass(RemoveColor);
|
|
27288
27077
|
|
|
27289
27078
|
const resizeDefaultValues = {
|
|
27290
27079
|
resizeType: 'hermite',
|
|
27291
27080
|
scaleX: 1,
|
|
27292
27081
|
scaleY: 1,
|
|
27293
|
-
lanczosLobes: 3
|
|
27294
|
-
fragmentSourceTOP: "\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n "
|
|
27082
|
+
lanczosLobes: 3
|
|
27295
27083
|
};
|
|
27296
27084
|
/**
|
|
27297
27085
|
* Resize image filter class
|
|
@@ -27301,19 +27089,6 @@ const resizeDefaultValues = {
|
|
|
27301
27089
|
* object.applyFilters(canvas.renderAll.bind(canvas));
|
|
27302
27090
|
*/
|
|
27303
27091
|
class Resize extends BaseFilter {
|
|
27304
|
-
/**
|
|
27305
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
27306
|
-
*
|
|
27307
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
27308
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
27309
|
-
*/
|
|
27310
|
-
getUniformLocations(gl, program) {
|
|
27311
|
-
return {
|
|
27312
|
-
uDelta: gl.getUniformLocation(program, 'uDelta'),
|
|
27313
|
-
uTaps: gl.getUniformLocation(program, 'uTaps')
|
|
27314
|
-
};
|
|
27315
|
-
}
|
|
27316
|
-
|
|
27317
27092
|
/**
|
|
27318
27093
|
* Send data from this filter to its shader program's uniforms.
|
|
27319
27094
|
*
|
|
@@ -27356,7 +27131,7 @@ class Resize extends BaseFilter {
|
|
|
27356
27131
|
for (let i = 1; i <= filterWindow; i++) {
|
|
27357
27132
|
offsets[i - 1] = "".concat(i, ".0 * uDelta");
|
|
27358
27133
|
}
|
|
27359
|
-
return "\n
|
|
27134
|
+
return "\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[".concat(filterWindow, "];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ").concat(offsets.map((offset, i) => "\n color += texture2D(uTexture, vTexCoord + ".concat(offset, ") * uTaps[").concat(i, "] + texture2D(uTexture, vTexCoord - ").concat(offset, ") * uTaps[").concat(i, "];\n sum += 2.0 * uTaps[").concat(i, "];\n ")).join('\n'), "\n gl_FragColor = color / sum;\n }\n ");
|
|
27360
27135
|
}
|
|
27361
27136
|
applyToForWebgl(options) {
|
|
27362
27137
|
options.passes++;
|
|
@@ -27699,20 +27474,6 @@ class Resize extends BaseFilter {
|
|
|
27699
27474
|
}
|
|
27700
27475
|
return img2;
|
|
27701
27476
|
}
|
|
27702
|
-
|
|
27703
|
-
/**
|
|
27704
|
-
* Returns object representation of an instance
|
|
27705
|
-
* @return {Object} Object representation of an instance
|
|
27706
|
-
*/
|
|
27707
|
-
toObject() {
|
|
27708
|
-
return {
|
|
27709
|
-
type: this.type,
|
|
27710
|
-
scaleX: this.scaleX,
|
|
27711
|
-
scaleY: this.scaleY,
|
|
27712
|
-
resizeType: this.resizeType,
|
|
27713
|
-
lanczosLobes: this.lanczosLobes
|
|
27714
|
-
};
|
|
27715
|
-
}
|
|
27716
27477
|
}
|
|
27717
27478
|
/**
|
|
27718
27479
|
* Resize type
|
|
@@ -27737,10 +27498,15 @@ class Resize extends BaseFilter {
|
|
|
27737
27498
|
*/
|
|
27738
27499
|
_defineProperty(Resize, "type", 'Resize');
|
|
27739
27500
|
_defineProperty(Resize, "defaults", resizeDefaultValues);
|
|
27501
|
+
_defineProperty(Resize, "uniformLocations", ['uDelta', 'uTaps']);
|
|
27740
27502
|
classRegistry.setClass(Resize);
|
|
27741
27503
|
|
|
27742
27504
|
const fragmentSource$1 = "\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uSaturation;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float rgMax = max(color.r, color.g);\n float rgbMax = max(rgMax, color.b);\n color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\n color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\n color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\n gl_FragColor = color;\n }\n";
|
|
27743
27505
|
|
|
27506
|
+
const saturationDefaultValues = {
|
|
27507
|
+
saturation: 0
|
|
27508
|
+
};
|
|
27509
|
+
|
|
27744
27510
|
/**
|
|
27745
27511
|
* Saturate filter class
|
|
27746
27512
|
* @example
|
|
@@ -27750,11 +27516,6 @@ const fragmentSource$1 = "\n precision highp float;\n uniform sampler2D uTextu
|
|
|
27750
27516
|
* object.filters.push(filter);
|
|
27751
27517
|
* object.applyFilters();
|
|
27752
27518
|
*/
|
|
27753
|
-
|
|
27754
|
-
const saturationDefaultValues = {
|
|
27755
|
-
saturation: 0,
|
|
27756
|
-
mainParameter: 'saturation'
|
|
27757
|
-
};
|
|
27758
27519
|
class Saturation extends BaseFilter {
|
|
27759
27520
|
getFragmentSource() {
|
|
27760
27521
|
return fragmentSource$1;
|
|
@@ -27772,9 +27533,6 @@ class Saturation extends BaseFilter {
|
|
|
27772
27533
|
data
|
|
27773
27534
|
}
|
|
27774
27535
|
} = _ref;
|
|
27775
|
-
if (this.saturation === 0) {
|
|
27776
|
-
return;
|
|
27777
|
-
}
|
|
27778
27536
|
const adjust = -this.saturation;
|
|
27779
27537
|
for (let i = 0; i < data.length; i += 4) {
|
|
27780
27538
|
const max = Math.max(data[i], data[i + 1], data[i + 2]);
|
|
@@ -27784,18 +27542,6 @@ class Saturation extends BaseFilter {
|
|
|
27784
27542
|
}
|
|
27785
27543
|
}
|
|
27786
27544
|
|
|
27787
|
-
/**
|
|
27788
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
27789
|
-
*
|
|
27790
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
27791
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
27792
|
-
*/
|
|
27793
|
-
getUniformLocations(gl, program) {
|
|
27794
|
-
return {
|
|
27795
|
-
uSaturation: gl.getUniformLocation(program, 'uSaturation')
|
|
27796
|
-
};
|
|
27797
|
-
}
|
|
27798
|
-
|
|
27799
27545
|
/**
|
|
27800
27546
|
* Send data from this filter to its shader program's uniforms.
|
|
27801
27547
|
*
|
|
@@ -27805,6 +27551,9 @@ class Saturation extends BaseFilter {
|
|
|
27805
27551
|
sendUniformData(gl, uniformLocations) {
|
|
27806
27552
|
gl.uniform1f(uniformLocations.uSaturation, -this.saturation);
|
|
27807
27553
|
}
|
|
27554
|
+
isNeutralState() {
|
|
27555
|
+
return this.saturation === 0;
|
|
27556
|
+
}
|
|
27808
27557
|
}
|
|
27809
27558
|
/**
|
|
27810
27559
|
* Saturation value, from -1 to 1.
|
|
@@ -27816,13 +27565,13 @@ class Saturation extends BaseFilter {
|
|
|
27816
27565
|
*/
|
|
27817
27566
|
_defineProperty(Saturation, "type", 'Saturation');
|
|
27818
27567
|
_defineProperty(Saturation, "defaults", saturationDefaultValues);
|
|
27568
|
+
_defineProperty(Saturation, "uniformLocations", ['uSaturation']);
|
|
27819
27569
|
classRegistry.setClass(Saturation);
|
|
27820
27570
|
|
|
27821
27571
|
const fragmentSource = "\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uVibrance;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float max = max(color.r, max(color.g, color.b));\n float avg = (color.r + color.g + color.b) / 3.0;\n float amt = (abs(max - avg) * 2.0) * uVibrance;\n color.r += max != color.r ? (max - color.r) * amt : 0.00;\n color.g += max != color.g ? (max - color.g) * amt : 0.00;\n color.b += max != color.b ? (max - color.b) * amt : 0.00;\n gl_FragColor = color;\n }\n";
|
|
27822
27572
|
|
|
27823
27573
|
const vibranceDefaultValues = {
|
|
27824
|
-
vibrance: 0
|
|
27825
|
-
mainParameter: 'vibrance'
|
|
27574
|
+
vibrance: 0
|
|
27826
27575
|
};
|
|
27827
27576
|
|
|
27828
27577
|
/**
|
|
@@ -27851,9 +27600,6 @@ class Vibrance extends BaseFilter {
|
|
|
27851
27600
|
data
|
|
27852
27601
|
}
|
|
27853
27602
|
} = _ref;
|
|
27854
|
-
if (this.vibrance === 0) {
|
|
27855
|
-
return;
|
|
27856
|
-
}
|
|
27857
27603
|
const adjust = -this.vibrance;
|
|
27858
27604
|
for (let i = 0; i < data.length; i += 4) {
|
|
27859
27605
|
const max = Math.max(data[i], data[i + 1], data[i + 2]);
|
|
@@ -27865,27 +27611,18 @@ class Vibrance extends BaseFilter {
|
|
|
27865
27611
|
}
|
|
27866
27612
|
}
|
|
27867
27613
|
|
|
27868
|
-
/**
|
|
27869
|
-
* Return WebGL uniform locations for this filter's shader.
|
|
27870
|
-
*
|
|
27871
|
-
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
27872
|
-
* @param {WebGLShaderProgram} program This filter's compiled shader program.
|
|
27873
|
-
*/
|
|
27874
|
-
getUniformLocations(gl, program) {
|
|
27875
|
-
return {
|
|
27876
|
-
uVibrance: gl.getUniformLocation(program, 'uVibrance')
|
|
27877
|
-
};
|
|
27878
|
-
}
|
|
27879
|
-
|
|
27880
27614
|
/**
|
|
27881
27615
|
* Send data from this filter to its shader program's uniforms.
|
|
27882
27616
|
*
|
|
27883
27617
|
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
|
|
27884
|
-
* @param {
|
|
27618
|
+
* @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects
|
|
27885
27619
|
*/
|
|
27886
27620
|
sendUniformData(gl, uniformLocations) {
|
|
27887
27621
|
gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);
|
|
27888
27622
|
}
|
|
27623
|
+
isNeutralState() {
|
|
27624
|
+
return this.vibrance === 0;
|
|
27625
|
+
}
|
|
27889
27626
|
}
|
|
27890
27627
|
/**
|
|
27891
27628
|
* Vibrance value, from -1 to 1.
|
|
@@ -27897,6 +27634,7 @@ class Vibrance extends BaseFilter {
|
|
|
27897
27634
|
*/
|
|
27898
27635
|
_defineProperty(Vibrance, "type", 'Vibrance');
|
|
27899
27636
|
_defineProperty(Vibrance, "defaults", vibranceDefaultValues);
|
|
27637
|
+
_defineProperty(Vibrance, "uniformLocations", ['uVibrance']);
|
|
27900
27638
|
classRegistry.setClass(Vibrance);
|
|
27901
27639
|
|
|
27902
27640
|
var filters = /*#__PURE__*/Object.freeze({
|