@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.
Files changed (268) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/dist/index.js +229 -491
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/dist/index.min.mjs +1 -1
  7. package/dist/index.min.mjs.map +1 -1
  8. package/dist/index.mjs +229 -491
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/index.node.cjs +229 -491
  11. package/dist/index.node.cjs.map +1 -1
  12. package/dist/index.node.mjs +229 -491
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/package.json.min.mjs +1 -1
  15. package/dist/package.json.mjs +1 -1
  16. package/dist/src/canvas/Canvas.d.ts.map +1 -1
  17. package/dist/src/canvas/Canvas.min.mjs +1 -1
  18. package/dist/src/canvas/Canvas.min.mjs.map +1 -1
  19. package/dist/src/canvas/Canvas.mjs +8 -9
  20. package/dist/src/canvas/Canvas.mjs.map +1 -1
  21. package/dist/src/canvas/SelectableCanvas.d.ts +1 -1
  22. package/dist/src/canvas/SelectableCanvas.d.ts.map +1 -1
  23. package/dist/src/canvas/SelectableCanvas.min.mjs +1 -1
  24. package/dist/src/canvas/SelectableCanvas.min.mjs.map +1 -1
  25. package/dist/src/canvas/SelectableCanvas.mjs +1 -1
  26. package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
  27. package/dist/src/canvas/StaticCanvas.d.ts +4 -4
  28. package/dist/src/canvas/StaticCanvas.d.ts.map +1 -1
  29. package/dist/src/canvas/StaticCanvas.min.mjs +1 -1
  30. package/dist/src/canvas/StaticCanvas.min.mjs.map +1 -1
  31. package/dist/src/canvas/StaticCanvas.mjs +0 -13
  32. package/dist/src/canvas/StaticCanvas.mjs.map +1 -1
  33. package/dist/src/color/Color.d.ts +1 -0
  34. package/dist/src/color/Color.d.ts.map +1 -1
  35. package/dist/src/color/Color.min.mjs +1 -1
  36. package/dist/src/color/Color.min.mjs.map +1 -1
  37. package/dist/src/color/Color.mjs +3 -1
  38. package/dist/src/color/Color.mjs.map +1 -1
  39. package/dist/src/filters/BaseFilter.d.ts +16 -23
  40. package/dist/src/filters/BaseFilter.d.ts.map +1 -1
  41. package/dist/src/filters/BaseFilter.min.mjs +1 -1
  42. package/dist/src/filters/BaseFilter.min.mjs.map +1 -1
  43. package/dist/src/filters/BaseFilter.mjs +24 -41
  44. package/dist/src/filters/BaseFilter.mjs.map +1 -1
  45. package/dist/src/filters/BlendColor.d.ts +13 -24
  46. package/dist/src/filters/BlendColor.d.ts.map +1 -1
  47. package/dist/src/filters/BlendColor.min.mjs +1 -1
  48. package/dist/src/filters/BlendColor.min.mjs.map +1 -1
  49. package/dist/src/filters/BlendColor.mjs +1 -25
  50. package/dist/src/filters/BlendColor.mjs.map +1 -1
  51. package/dist/src/filters/BlendImage.d.ts +18 -19
  52. package/dist/src/filters/BlendImage.d.ts.map +1 -1
  53. package/dist/src/filters/BlendImage.min.mjs +1 -1
  54. package/dist/src/filters/BlendImage.min.mjs.map +1 -1
  55. package/dist/src/filters/BlendImage.mjs +13 -24
  56. package/dist/src/filters/BlendImage.mjs.map +1 -1
  57. package/dist/src/filters/Blur.d.ts +10 -12
  58. package/dist/src/filters/Blur.d.ts.map +1 -1
  59. package/dist/src/filters/Blur.min.mjs +1 -1
  60. package/dist/src/filters/Blur.min.mjs.map +1 -1
  61. package/dist/src/filters/Blur.mjs +5 -14
  62. package/dist/src/filters/Blur.mjs.map +1 -1
  63. package/dist/src/filters/Boilerplate.d.ts +11 -13
  64. package/dist/src/filters/Boilerplate.d.ts.map +1 -1
  65. package/dist/src/filters/Brightness.d.ts +10 -12
  66. package/dist/src/filters/Brightness.d.ts.map +1 -1
  67. package/dist/src/filters/Brightness.min.mjs +1 -1
  68. package/dist/src/filters/Brightness.min.mjs.map +1 -1
  69. package/dist/src/filters/Brightness.mjs +4 -16
  70. package/dist/src/filters/Brightness.mjs.map +1 -1
  71. package/dist/src/filters/Canvas2dFilterBackend.d.ts +1 -1
  72. package/dist/src/filters/Canvas2dFilterBackend.d.ts.map +1 -1
  73. package/dist/src/filters/Canvas2dFilterBackend.min.mjs.map +1 -1
  74. package/dist/src/filters/Canvas2dFilterBackend.mjs.map +1 -1
  75. package/dist/src/filters/ColorMatrix.d.ts +17 -15
  76. package/dist/src/filters/ColorMatrix.d.ts.map +1 -1
  77. package/dist/src/filters/ColorMatrix.min.mjs +1 -1
  78. package/dist/src/filters/ColorMatrix.min.mjs.map +1 -1
  79. package/dist/src/filters/ColorMatrix.mjs +7 -27
  80. package/dist/src/filters/ColorMatrix.mjs.map +1 -1
  81. package/dist/src/filters/ColorMatrixFilters.d.ts +63 -497
  82. package/dist/src/filters/ColorMatrixFilters.d.ts.map +1 -1
  83. package/dist/src/filters/ColorMatrixFilters.min.mjs +1 -1
  84. package/dist/src/filters/ColorMatrixFilters.min.mjs.map +1 -1
  85. package/dist/src/filters/ColorMatrixFilters.mjs +13 -8
  86. package/dist/src/filters/ColorMatrixFilters.mjs.map +1 -1
  87. package/dist/src/filters/Composed.d.ts +11 -10
  88. package/dist/src/filters/Composed.d.ts.map +1 -1
  89. package/dist/src/filters/Composed.min.mjs +1 -1
  90. package/dist/src/filters/Composed.min.mjs.map +1 -1
  91. package/dist/src/filters/Composed.mjs +7 -12
  92. package/dist/src/filters/Composed.mjs.map +1 -1
  93. package/dist/src/filters/Contrast.d.ts +10 -12
  94. package/dist/src/filters/Contrast.d.ts.map +1 -1
  95. package/dist/src/filters/Contrast.min.mjs +1 -1
  96. package/dist/src/filters/Contrast.min.mjs.map +1 -1
  97. package/dist/src/filters/Contrast.mjs +6 -17
  98. package/dist/src/filters/Contrast.mjs.map +1 -1
  99. package/dist/src/filters/Convolute.d.ts +11 -14
  100. package/dist/src/filters/Convolute.d.ts.map +1 -1
  101. package/dist/src/filters/Convolute.min.mjs +1 -1
  102. package/dist/src/filters/Convolute.min.mjs.map +1 -1
  103. package/dist/src/filters/Convolute.mjs +1 -15
  104. package/dist/src/filters/Convolute.mjs.map +1 -1
  105. package/dist/src/filters/Gamma.d.ts +17 -14
  106. package/dist/src/filters/Gamma.d.ts.map +1 -1
  107. package/dist/src/filters/Gamma.min.mjs +1 -1
  108. package/dist/src/filters/Gamma.min.mjs.map +1 -1
  109. package/dist/src/filters/Gamma.mjs +20 -24
  110. package/dist/src/filters/Gamma.mjs.map +1 -1
  111. package/dist/src/filters/Grayscale.d.ts +8 -11
  112. package/dist/src/filters/Grayscale.d.ts.map +1 -1
  113. package/dist/src/filters/Grayscale.min.mjs +1 -1
  114. package/dist/src/filters/Grayscale.min.mjs.map +1 -1
  115. package/dist/src/filters/Grayscale.mjs +2 -14
  116. package/dist/src/filters/Grayscale.mjs.map +1 -1
  117. package/dist/src/filters/HueRotation.d.ts +11 -5
  118. package/dist/src/filters/HueRotation.d.ts.map +1 -1
  119. package/dist/src/filters/HueRotation.min.mjs +1 -1
  120. package/dist/src/filters/HueRotation.min.mjs.map +1 -1
  121. package/dist/src/filters/HueRotation.mjs +10 -5
  122. package/dist/src/filters/HueRotation.mjs.map +1 -1
  123. package/dist/src/filters/Invert.d.ts +10 -13
  124. package/dist/src/filters/Invert.d.ts.map +1 -1
  125. package/dist/src/filters/Invert.min.mjs +1 -1
  126. package/dist/src/filters/Invert.min.mjs.map +1 -1
  127. package/dist/src/filters/Invert.mjs +2 -15
  128. package/dist/src/filters/Invert.mjs.map +1 -1
  129. package/dist/src/filters/Noise.d.ts +9 -20
  130. package/dist/src/filters/Noise.d.ts.map +1 -1
  131. package/dist/src/filters/Noise.min.mjs +1 -1
  132. package/dist/src/filters/Noise.min.mjs.map +1 -1
  133. package/dist/src/filters/Noise.mjs +4 -27
  134. package/dist/src/filters/Noise.mjs.map +1 -1
  135. package/dist/src/filters/Pixelate.d.ts +8 -12
  136. package/dist/src/filters/Pixelate.d.ts.map +1 -1
  137. package/dist/src/filters/Pixelate.min.mjs +1 -1
  138. package/dist/src/filters/Pixelate.min.mjs.map +1 -1
  139. package/dist/src/filters/Pixelate.mjs +2 -16
  140. package/dist/src/filters/Pixelate.mjs.map +1 -1
  141. package/dist/src/filters/RemoveColor.d.ts +12 -23
  142. package/dist/src/filters/RemoveColor.d.ts.map +1 -1
  143. package/dist/src/filters/RemoveColor.min.mjs +1 -1
  144. package/dist/src/filters/RemoveColor.min.mjs.map +1 -1
  145. package/dist/src/filters/RemoveColor.mjs +2 -25
  146. package/dist/src/filters/RemoveColor.mjs.map +1 -1
  147. package/dist/src/filters/Resize.d.ts +14 -30
  148. package/dist/src/filters/Resize.d.ts.map +1 -1
  149. package/dist/src/filters/Resize.min.mjs +1 -1
  150. package/dist/src/filters/Resize.min.mjs.map +1 -1
  151. package/dist/src/filters/Resize.mjs +3 -30
  152. package/dist/src/filters/Resize.mjs.map +1 -1
  153. package/dist/src/filters/Saturation.d.ts +9 -12
  154. package/dist/src/filters/Saturation.d.ts.map +1 -1
  155. package/dist/src/filters/Saturation.min.mjs +1 -1
  156. package/dist/src/filters/Saturation.min.mjs.map +1 -1
  157. package/dist/src/filters/Saturation.mjs +8 -20
  158. package/dist/src/filters/Saturation.mjs.map +1 -1
  159. package/dist/src/filters/Vibrance.d.ts +10 -13
  160. package/dist/src/filters/Vibrance.d.ts.map +1 -1
  161. package/dist/src/filters/Vibrance.min.mjs +1 -1
  162. package/dist/src/filters/Vibrance.min.mjs.map +1 -1
  163. package/dist/src/filters/Vibrance.mjs +6 -18
  164. package/dist/src/filters/Vibrance.mjs.map +1 -1
  165. package/dist/src/filters/WebGLFilterBackend.d.ts +1 -1
  166. package/dist/src/filters/WebGLFilterBackend.d.ts.map +1 -1
  167. package/dist/src/filters/WebGLFilterBackend.min.mjs.map +1 -1
  168. package/dist/src/filters/WebGLFilterBackend.mjs.map +1 -1
  169. package/dist/src/filters/shaders/blendImage.d.ts +1 -0
  170. package/dist/src/filters/shaders/blendImage.d.ts.map +1 -1
  171. package/dist/src/filters/shaders/blendImage.min.mjs +1 -1
  172. package/dist/src/filters/shaders/blendImage.min.mjs.map +1 -1
  173. package/dist/src/filters/shaders/blendImage.mjs +2 -1
  174. package/dist/src/filters/shaders/blendImage.mjs.map +1 -1
  175. package/dist/src/filters/typedefs.d.ts +22 -0
  176. package/dist/src/filters/typedefs.d.ts.map +1 -1
  177. package/dist/src/parser/elements_parser.d.ts +1 -1
  178. package/dist/src/parser/elements_parser.d.ts.map +1 -1
  179. package/dist/src/parser/elements_parser.min.mjs.map +1 -1
  180. package/dist/src/parser/elements_parser.mjs.map +1 -1
  181. package/dist/src/shapes/ActiveSelection.d.ts +1 -1
  182. package/dist/src/shapes/ActiveSelection.d.ts.map +1 -1
  183. package/dist/src/shapes/ActiveSelection.min.mjs +1 -1
  184. package/dist/src/shapes/ActiveSelection.min.mjs.map +1 -1
  185. package/dist/src/shapes/ActiveSelection.mjs +13 -10
  186. package/dist/src/shapes/ActiveSelection.mjs.map +1 -1
  187. package/dist/src/shapes/Group.d.ts +9 -0
  188. package/dist/src/shapes/Group.d.ts.map +1 -1
  189. package/dist/src/shapes/Group.min.mjs +1 -1
  190. package/dist/src/shapes/Group.min.mjs.map +1 -1
  191. package/dist/src/shapes/Group.mjs +10 -1
  192. package/dist/src/shapes/Group.mjs.map +1 -1
  193. package/dist/src/shapes/Image.d.ts +4 -4
  194. package/dist/src/shapes/Image.d.ts.map +1 -1
  195. package/dist/src/shapes/Image.min.mjs.map +1 -1
  196. package/dist/src/shapes/Image.mjs.map +1 -1
  197. package/dist/src/shapes/Object/InteractiveObject.d.ts +3 -0
  198. package/dist/src/shapes/Object/InteractiveObject.d.ts.map +1 -1
  199. package/dist/src/shapes/Object/InteractiveObject.min.mjs +1 -1
  200. package/dist/src/shapes/Object/InteractiveObject.min.mjs.map +1 -1
  201. package/dist/src/shapes/Object/InteractiveObject.mjs +3 -1
  202. package/dist/src/shapes/Object/InteractiveObject.mjs.map +1 -1
  203. package/dist/src/shapes/Object/Object.d.ts +1 -16
  204. package/dist/src/shapes/Object/Object.d.ts.map +1 -1
  205. package/dist/src/shapes/Object/Object.min.mjs +1 -1
  206. package/dist/src/shapes/Object/Object.min.mjs.map +1 -1
  207. package/dist/src/shapes/Object/Object.mjs +9 -10
  208. package/dist/src/shapes/Object/Object.mjs.map +1 -1
  209. package/dist/src/shapes/Object/StackedObject.d.ts +8 -15
  210. package/dist/src/shapes/Object/StackedObject.d.ts.map +1 -1
  211. package/dist/src/shapes/Object/StackedObject.min.mjs +1 -1
  212. package/dist/src/shapes/Object/StackedObject.min.mjs.map +1 -1
  213. package/dist/src/shapes/Object/StackedObject.mjs +11 -21
  214. package/dist/src/shapes/Object/StackedObject.mjs.map +1 -1
  215. package/dist/src/shapes/Path.d.ts +2 -2
  216. package/dist/src/shapes/Path.d.ts.map +1 -1
  217. package/dist/src/shapes/Path.min.mjs.map +1 -1
  218. package/dist/src/shapes/Path.mjs +2 -2
  219. package/dist/src/shapes/Path.mjs.map +1 -1
  220. package/dist/src/shapes/Text/TextSVGExportMixin.d.ts +1 -1
  221. package/dist/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
  222. package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs.map +1 -1
  223. package/dist/src/shapes/Text/TextSVGExportMixin.mjs.map +1 -1
  224. package/dist/src/util/misc/objectEnlive.d.ts +2 -2
  225. package/dist/src/util/misc/objectEnlive.d.ts.map +1 -1
  226. package/dist/src/util/misc/objectEnlive.min.mjs.map +1 -1
  227. package/dist/src/util/misc/objectEnlive.mjs.map +1 -1
  228. package/package.json +2 -2
  229. package/src/canvas/Canvas.ts +6 -9
  230. package/src/canvas/SelectableCanvas.ts +2 -2
  231. package/src/canvas/StaticCanvas.ts +4 -18
  232. package/src/color/Color.ts +2 -1
  233. package/src/color/color.test.ts +6 -0
  234. package/src/filters/BaseFilter.ts +45 -51
  235. package/src/filters/BlendColor.ts +13 -35
  236. package/src/filters/BlendImage.ts +26 -40
  237. package/src/filters/Blur.ts +13 -20
  238. package/src/filters/Boilerplate.ts +13 -22
  239. package/src/filters/Brightness.ts +12 -21
  240. package/src/filters/Canvas2dFilterBackend.ts +1 -1
  241. package/src/filters/ColorMatrix.ts +29 -34
  242. package/src/filters/ColorMatrixFilters.ts +15 -9
  243. package/src/filters/Composed.ts +26 -16
  244. package/src/filters/Contrast.ts +15 -23
  245. package/src/filters/Convolute.ts +11 -23
  246. package/src/filters/Gamma.ts +32 -24
  247. package/src/filters/Grayscale.ts +8 -19
  248. package/src/filters/HueRotation.ts +21 -11
  249. package/src/filters/Invert.ts +11 -22
  250. package/src/filters/Noise.ts +11 -30
  251. package/src/filters/Pixelate.ts +9 -22
  252. package/src/filters/RemoveColor.ts +21 -35
  253. package/src/filters/Resize.ts +20 -44
  254. package/src/filters/Saturation.ts +16 -27
  255. package/src/filters/Vibrance.ts +14 -24
  256. package/src/filters/WebGLFilterBackend.ts +1 -1
  257. package/src/filters/shaders/blendImage.ts +12 -0
  258. package/src/filters/typedefs.ts +23 -0
  259. package/src/parser/elements_parser.ts +1 -1
  260. package/src/shapes/ActiveSelection.ts +8 -4
  261. package/src/shapes/Group.ts +16 -1
  262. package/src/shapes/Image.ts +8 -6
  263. package/src/shapes/Object/InteractiveObject.ts +3 -1
  264. package/src/shapes/Object/Object.ts +10 -35
  265. package/src/shapes/Object/StackedObject.ts +28 -44
  266. package/src/shapes/Path.ts +4 -4
  267. package/src/shapes/Text/TextSVGExportMixin.ts +1 -1
  268. package/src/util/misc/objectEnlive.ts +12 -2
@@ -473,7 +473,7 @@ class Cache {
473
473
  }
474
474
  const cache = new Cache();
475
475
 
476
- var version = "6.0.0-rc2.0";
476
+ var version = "6.0.0";
477
477
 
478
478
  // use this syntax so babel plugin see this import here
479
479
  const VERSION = version;
@@ -2421,6 +2421,7 @@ class Color {
2421
2421
  * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list
2422
2422
  */
2423
2423
  constructor(color) {
2424
+ _defineProperty(this, "isUnrecognised", false);
2424
2425
  if (!color) {
2425
2426
  // we default to black as canvas does
2426
2427
  this.setSource([0, 0, 0, 1]);
@@ -2446,7 +2447,7 @@ class Color {
2446
2447
  return color === 'transparent' ? [255, 255, 255, 0] : Color.sourceFromHex(color) || Color.sourceFromRgb(color) || Color.sourceFromHsl(color) ||
2447
2448
  // color is not recognized
2448
2449
  // we default to black as canvas does
2449
- [0, 0, 0, 1];
2450
+ (this.isUnrecognised = true) && [0, 0, 0, 1];
2450
2451
  }
2451
2452
 
2452
2453
  /**
@@ -3373,20 +3374,7 @@ let StaticCanvas$1 = class StaticCanvas extends createCollectionMixin(CommonMeth
3373
3374
  * @param {Array} vpt a Canvas 2D API transform matrix
3374
3375
  */
3375
3376
  setViewportTransform(vpt) {
3376
- const backgroundObject = this.backgroundImage,
3377
- overlayObject = this.overlayImage,
3378
- len = this._objects.length;
3379
3377
  this.viewportTransform = vpt;
3380
- for (let i = 0; i < len; i++) {
3381
- const object = this._objects[i];
3382
- object.group || object.setCoords();
3383
- }
3384
- if (backgroundObject) {
3385
- backgroundObject.setCoords();
3386
- }
3387
- if (overlayObject) {
3388
- overlayObject.setCoords();
3389
- }
3390
3378
  this.calcViewportBoundaries();
3391
3379
  this.renderOnAddRemove && this.requestRenderAll();
3392
3380
  }
@@ -4438,7 +4426,7 @@ const makeBoundingBoxFromPoints = points => {
4438
4426
  };
4439
4427
  };
4440
4428
 
4441
- const _excluded$m = ["translateX", "translateY", "scaleX", "scaleY"];
4429
+ const _excluded$i = ["translateX", "translateY", "scaleX", "scaleY"];
4442
4430
 
4443
4431
  /**
4444
4432
  * given an object and a transform, apply the inverse transform to the object,
@@ -4480,7 +4468,7 @@ const applyTransformToObject = (object, transform) => {
4480
4468
  scaleX,
4481
4469
  scaleY
4482
4470
  } = _qrDecompose,
4483
- otherOptions = _objectWithoutProperties(_qrDecompose, _excluded$m),
4471
+ otherOptions = _objectWithoutProperties(_qrDecompose, _excluded$i),
4484
4472
  center = new Point(translateX, translateY);
4485
4473
  object.flipX = false;
4486
4474
  object.flipY = false;
@@ -5395,14 +5383,14 @@ class AnimationBase {
5395
5383
  }
5396
5384
  }
5397
5385
 
5398
- const _excluded$l = ["startValue", "endValue"];
5386
+ const _excluded$h = ["startValue", "endValue"];
5399
5387
  class ValueAnimation extends AnimationBase {
5400
5388
  constructor(_ref) {
5401
5389
  let {
5402
5390
  startValue = 0,
5403
5391
  endValue = 100
5404
5392
  } = _ref,
5405
- otherOptions = _objectWithoutProperties(_ref, _excluded$l);
5393
+ otherOptions = _objectWithoutProperties(_ref, _excluded$h);
5406
5394
  super(_objectSpread2(_objectSpread2({}, otherOptions), {}, {
5407
5395
  startValue,
5408
5396
  byValue: endValue - startValue
@@ -5417,14 +5405,14 @@ class ValueAnimation extends AnimationBase {
5417
5405
  }
5418
5406
  }
5419
5407
 
5420
- const _excluded$k = ["startValue", "endValue"];
5408
+ const _excluded$g = ["startValue", "endValue"];
5421
5409
  class ArrayAnimation extends AnimationBase {
5422
5410
  constructor(_ref) {
5423
5411
  let {
5424
5412
  startValue = [0],
5425
5413
  endValue = [100]
5426
5414
  } = _ref,
5427
- options = _objectWithoutProperties(_ref, _excluded$k);
5415
+ options = _objectWithoutProperties(_ref, _excluded$g);
5428
5416
  super(_objectSpread2(_objectSpread2({}, options), {}, {
5429
5417
  startValue,
5430
5418
  byValue: endValue.map((value, i) => value - startValue[i])
@@ -5441,7 +5429,7 @@ class ArrayAnimation extends AnimationBase {
5441
5429
 
5442
5430
  const capValue = (min, value, max) => Math.max(min, Math.min(value, max));
5443
5431
 
5444
- const _excluded$j = ["startValue", "endValue", "easing", "onChange", "onComplete", "abort"];
5432
+ const _excluded$f = ["startValue", "endValue", "easing", "onChange", "onComplete", "abort"];
5445
5433
  const defaultColorEasing = (timeElapsed, startValue, byValue, duration) => {
5446
5434
  const durationProgress = 1 - Math.cos(timeElapsed / duration * halfPI);
5447
5435
  return startValue + byValue * durationProgress;
@@ -5457,7 +5445,7 @@ class ColorAnimation extends AnimationBase {
5457
5445
  onComplete,
5458
5446
  abort
5459
5447
  } = _ref,
5460
- options = _objectWithoutProperties(_ref, _excluded$j);
5448
+ options = _objectWithoutProperties(_ref, _excluded$f);
5461
5449
  const startColor = new Color(startValue).getSource();
5462
5450
  const endColor = new Color(endValue).getSource();
5463
5451
  super(_objectSpread2(_objectSpread2({}, options), {}, {
@@ -6498,10 +6486,6 @@ class ObjectGeometry extends ObjectOrigin {
6498
6486
  }
6499
6487
  }
6500
6488
 
6501
- /**
6502
- * Strict: only ancestors that are objects (without canvas)
6503
- */
6504
-
6505
6489
  class StackedObject extends ObjectGeometry {
6506
6490
  /**
6507
6491
  * A reference to the parent of the object
@@ -6525,17 +6509,14 @@ class StackedObject extends ObjectGeometry {
6525
6509
  }
6526
6510
 
6527
6511
  /**
6528
- *
6529
- * @param {boolean} [strict] returns only ancestors that are objects (without canvas)
6530
6512
  * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top
6531
6513
  */
6532
- getAncestors(strict) {
6514
+ getAncestors() {
6533
6515
  const ancestors = [];
6534
6516
  // eslint-disable-next-line @typescript-eslint/no-this-alias
6535
6517
  let parent = this;
6536
6518
  do {
6537
- var _parent$parent;
6538
- parent = parent instanceof StackedObject ? (_parent$parent = parent.parent) !== null && _parent$parent !== void 0 ? _parent$parent : !strict ? parent.canvas : undefined : undefined;
6519
+ parent = parent instanceof StackedObject ? parent.parent : undefined;
6539
6520
  parent && ancestors.push(parent);
6540
6521
  } while (parent);
6541
6522
  return ancestors;
@@ -6545,19 +6526,18 @@ class StackedObject extends ObjectGeometry {
6545
6526
  * Compare ancestors
6546
6527
  *
6547
6528
  * @param {StackedObject} other
6548
- * @param {boolean} [strict] finds only ancestors that are objects (without canvas)
6549
6529
  * @returns {AncestryComparison} an object that represent the ancestry situation.
6550
6530
  */
6551
- findCommonAncestors(other, strict) {
6531
+ findCommonAncestors(other) {
6552
6532
  if (this === other) {
6553
6533
  return {
6554
6534
  fork: [],
6555
6535
  otherFork: [],
6556
- common: [this, ...this.getAncestors(strict)]
6536
+ common: [this, ...this.getAncestors()]
6557
6537
  };
6558
6538
  }
6559
- const ancestors = this.getAncestors(strict);
6560
- const otherAncestors = other.getAncestors(strict);
6539
+ const ancestors = this.getAncestors();
6540
+ const otherAncestors = other.getAncestors();
6561
6541
  // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case
6562
6542
  if (ancestors.length === 0 && otherAncestors.length > 0 && this === otherAncestors[otherAncestors.length - 1]) {
6563
6543
  return {
@@ -6604,11 +6584,10 @@ class StackedObject extends ObjectGeometry {
6604
6584
  /**
6605
6585
  *
6606
6586
  * @param {StackedObject} other
6607
- * @param {boolean} [strict] checks only ancestors that are objects (without canvas)
6608
6587
  * @returns {boolean}
6609
6588
  */
6610
- hasCommonAncestors(other, strict) {
6611
- const commonAncestors = this.findCommonAncestors(other, strict);
6589
+ hasCommonAncestors(other) {
6590
+ const commonAncestors = this.findCommonAncestors(other);
6612
6591
  return commonAncestors && !!commonAncestors.common.length;
6613
6592
  }
6614
6593
 
@@ -6622,16 +6601,15 @@ class StackedObject extends ObjectGeometry {
6622
6601
  return undefined;
6623
6602
  }
6624
6603
  const ancestorData = this.findCommonAncestors(other);
6625
- if (!ancestorData) {
6626
- return undefined;
6627
- }
6628
6604
  if (ancestorData.fork.includes(other)) {
6629
6605
  return true;
6630
6606
  }
6631
6607
  if (ancestorData.otherFork.includes(this)) {
6632
6608
  return false;
6633
6609
  }
6634
- const firstCommonAncestor = ancestorData.common[0];
6610
+ // if there isn't a common ancestor, we take the canvas.
6611
+ // if there is no canvas, there is nothing to compare
6612
+ const firstCommonAncestor = ancestorData.common[0] || this.canvas;
6635
6613
  if (!firstCommonAncestor) {
6636
6614
  return undefined;
6637
6615
  }
@@ -7004,7 +6982,7 @@ const interactiveObjectDefaultValues = {
7004
6982
  moveCursor: null
7005
6983
  };
7006
6984
 
7007
- const _excluded$i = ["type"],
6985
+ const _excluded$e = ["type"],
7008
6986
  _excluded2$4 = ["extraParam"];
7009
6987
  /**
7010
6988
  * Root object class from which all 2d shape classes inherit from
@@ -7192,7 +7170,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7192
7170
  height = dims.height,
7193
7171
  zoomX = dims.zoomX,
7194
7172
  zoomY = dims.zoomY,
7195
- dimensionsChanged = width !== this.cacheWidth || height !== this.cacheHeight,
7173
+ dimensionsChanged = width !== canvas.width || height !== canvas.height,
7196
7174
  zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;
7197
7175
  if (!canvas || !context) {
7198
7176
  return false;
@@ -7233,8 +7211,6 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7233
7211
  drawingHeight = dims.y / 2;
7234
7212
  this.cacheTranslationX = Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;
7235
7213
  this.cacheTranslationY = Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;
7236
- this.cacheWidth = width;
7237
- this.cacheHeight = height;
7238
7214
  context.translate(this.cacheTranslationX, this.cacheTranslationY);
7239
7215
  context.scale(zoomX, zoomY);
7240
7216
  this.zoomX = zoomX;
@@ -7509,8 +7485,6 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7509
7485
  _removeCacheCanvas() {
7510
7486
  this._cacheCanvas = undefined;
7511
7487
  this._cacheContext = null;
7512
- this.cacheWidth = 0;
7513
- this.cacheHeight = 0;
7514
7488
  }
7515
7489
 
7516
7490
  /**
@@ -7669,15 +7643,18 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7669
7643
  if (this.isNotVisible()) {
7670
7644
  return false;
7671
7645
  }
7672
- if (this._cacheCanvas && this._cacheContext && !skipCanvas && this._updateCacheCanvas()) {
7646
+ const canvas = this._cacheCanvas;
7647
+ const ctx = this._cacheContext;
7648
+ if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {
7673
7649
  // in this case the context is already cleared.
7674
7650
  return true;
7675
7651
  } else {
7676
7652
  if (this.dirty || this.clipPath && this.clipPath.absolutePositioned) {
7677
- if (this._cacheCanvas && this._cacheContext && !skipCanvas) {
7678
- const width = this.cacheWidth / this.zoomX;
7679
- const height = this.cacheHeight / this.zoomY;
7680
- this._cacheContext.clearRect(-width / 2, -height / 2, width, height);
7653
+ if (canvas && ctx && !skipCanvas) {
7654
+ ctx.save();
7655
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
7656
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
7657
+ ctx.restore();
7681
7658
  }
7682
7659
  return true;
7683
7660
  }
@@ -8201,7 +8178,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
8201
8178
  * @returns {Promise<FabricObject>}
8202
8179
  */
8203
8180
  static _fromObject(_ref2) {
8204
- let object = _objectWithoutProperties(_ref2, _excluded$i);
8181
+ let object = _objectWithoutProperties(_ref2, _excluded$e);
8205
8182
  let _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
8206
8183
  {
8207
8184
  extraParam
@@ -8952,7 +8929,7 @@ const scalingEqually = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObj
8952
8929
  const scalingX = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectX));
8953
8930
  const scalingY = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectY));
8954
8931
 
8955
- const _excluded$h = ["target", "ex", "ey", "skewingSide"];
8932
+ const _excluded$d = ["target", "ex", "ey", "skewingSide"];
8956
8933
  const AXIS_KEYS = {
8957
8934
  x: {
8958
8935
  counterAxis: 'y',
@@ -9002,7 +8979,7 @@ function skewObject(axis, _ref, pointer) {
9002
8979
  ey,
9003
8980
  skewingSide
9004
8981
  } = _ref,
9005
- transform = _objectWithoutProperties(_ref, _excluded$h);
8982
+ transform = _objectWithoutProperties(_ref, _excluded$d);
9006
8983
  const {
9007
8984
  skew: skewKey
9008
8985
  } = AXIS_KEYS[axis],
@@ -9588,6 +9565,9 @@ class InteractiveFabricObject extends FabricObject$1 {
9588
9565
  * Draws corners of an object's bounding box.
9589
9566
  * Requires public properties: width, height
9590
9567
  * Requires public options: cornerSize, padding
9568
+ * Be aware that since fabric 6.0 this function does not call setCoords anymore.
9569
+ * setCoords needs to be called manually if the object of which we are rendering controls
9570
+ * is outside the standard selection and transform process.
9591
9571
  * @param {CanvasRenderingContext2D} ctx Context to draw on
9592
9572
  * @param {ControlRenderingStyleOverride} styleOverride object to override the object style
9593
9573
  */
@@ -9611,7 +9591,6 @@ class InteractiveFabricObject extends FabricObject$1 {
9611
9591
  ctx.strokeStyle = options.cornerStrokeColor;
9612
9592
  }
9613
9593
  this._setLineDash(ctx, options.cornerDashArray);
9614
- this.setCoords();
9615
9594
  this.forEachControl((control, key) => {
9616
9595
  if (control.getVisibility(this, key)) {
9617
9596
  const p = this.oCoords[key];
@@ -10844,7 +10823,7 @@ function parseAttributes(element, attributes, cssRules) {
10844
10823
  return svgValidParentsRegEx.test(element.nodeName) ? mergedAttrs : setStrokeFillOpacity(mergedAttrs);
10845
10824
  }
10846
10825
 
10847
- const _excluded$g = ["left", "top", "width", "height", "visible"];
10826
+ const _excluded$c = ["left", "top", "width", "height", "visible"];
10848
10827
  const rectDefaultValues = {
10849
10828
  rx: 0,
10850
10829
  ry: 0
@@ -10958,7 +10937,7 @@ class Rect extends FabricObject {
10958
10937
  height = 0,
10959
10938
  visible = true
10960
10939
  } = _parseAttributes,
10961
- restOfparsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$g);
10940
+ restOfparsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$c);
10962
10941
  return new this(_objectSpread2(_objectSpread2(_objectSpread2({}, options), restOfparsedAttributes), {}, {
10963
10942
  left,
10964
10943
  top,
@@ -11114,7 +11093,7 @@ class FitContentLayout extends LayoutStrategy {
11114
11093
  _defineProperty(FitContentLayout, "type", 'fit-content');
11115
11094
  classRegistry.setClass(FitContentLayout);
11116
11095
 
11117
- const _excluded$f = ["strategy"],
11096
+ const _excluded$b = ["strategy"],
11118
11097
  _excluded2$3 = ["target", "strategy", "bubbles", "prevStrategy"];
11119
11098
  const LAYOUT_MANAGER = 'layoutManager';
11120
11099
  class LayoutManager {
@@ -11217,7 +11196,7 @@ class LayoutManager {
11217
11196
  context
11218
11197
  });
11219
11198
  if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {
11220
- const tricklingContext = _objectWithoutProperties(context, _excluded$f);
11199
+ const tricklingContext = _objectWithoutProperties(context, _excluded$b);
11221
11200
  // traverse the tree
11222
11201
  target.forEachObject(object => object.layoutManager && object.layoutManager.performLayout(_objectSpread2(_objectSpread2({}, tricklingContext), {}, {
11223
11202
  bubbles: false,
@@ -11361,7 +11340,7 @@ class LayoutManager {
11361
11340
  }
11362
11341
  classRegistry.setClass(LayoutManager, LAYOUT_MANAGER);
11363
11342
 
11364
- const _excluded$e = ["type", "objects", "layoutManager"];
11343
+ const _excluded$a = ["type", "objects", "layoutManager"];
11365
11344
  /**
11366
11345
  * 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.
11367
11346
  * We could have used a boolean in the constructor, as we did previously, but we think the boolean
@@ -11428,6 +11407,15 @@ class Group extends createCollectionMixin(FabricObject) {
11428
11407
  _defineProperty(this, "__objectSelectionDisposer", void 0);
11429
11408
  Object.assign(this, Group.ownDefaults);
11430
11409
  this.setOptions(options);
11410
+ this.groupInit(objects, options);
11411
+ }
11412
+
11413
+ /**
11414
+ * Shared code between group and active selection
11415
+ * Meant to be used by the constructor.
11416
+ */
11417
+ groupInit(objects, options) {
11418
+ var _options$layoutManage;
11431
11419
  this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller
11432
11420
 
11433
11421
  this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(this, true);
@@ -11437,7 +11425,7 @@ class Group extends createCollectionMixin(FabricObject) {
11437
11425
  });
11438
11426
 
11439
11427
  // perform initial layout
11440
- this.layoutManager = options.layoutManager || new LayoutManager();
11428
+ this.layoutManager = (_options$layoutManage = options.layoutManager) !== null && _options$layoutManage !== void 0 ? _options$layoutManage : new LayoutManager();
11441
11429
  this.layoutManager.performLayout({
11442
11430
  type: LAYOUT_TYPE_INITIALIZATION,
11443
11431
  target: this,
@@ -11909,7 +11897,7 @@ class Group extends createCollectionMixin(FabricObject) {
11909
11897
  objects = [],
11910
11898
  layoutManager
11911
11899
  } = _ref2,
11912
- options = _objectWithoutProperties(_ref2, _excluded$e);
11900
+ options = _objectWithoutProperties(_ref2, _excluded$a);
11913
11901
  return Promise.all([enlivenObjects(objects, abortable), enlivenObjectEnlivables(options, abortable)]).then(_ref3 => {
11914
11902
  let [objects, hydratedOptions] = _ref3;
11915
11903
  const group = new this(objects, _objectSpread2(_objectSpread2(_objectSpread2({}, options), hydratedOptions), {}, {
@@ -14065,8 +14053,8 @@ class SelectableCanvas extends StaticCanvas$1 {
14065
14053
  this._activeObject = object;
14066
14054
  if (isActiveSelection(object) && prevActiveObject !== object) {
14067
14055
  object.set('canvas', this);
14068
- object.setCoords();
14069
14056
  }
14057
+ object.setCoords();
14070
14058
  return true;
14071
14059
  }
14072
14060
 
@@ -14319,7 +14307,7 @@ class TextEditingManager {
14319
14307
  }
14320
14308
  }
14321
14309
 
14322
- const _excluded$d = ["target", "oldTarget", "fireCanvas", "e"];
14310
+ const _excluded$9 = ["target", "oldTarget", "fireCanvas", "e"];
14323
14311
  const addEventOptions = {
14324
14312
  passive: false
14325
14313
  };
@@ -15333,7 +15321,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15333
15321
  fireCanvas,
15334
15322
  e
15335
15323
  } = _ref,
15336
- data = _objectWithoutProperties(_ref, _excluded$d);
15324
+ data = _objectWithoutProperties(_ref, _excluded$9);
15337
15325
  const {
15338
15326
  targetIn,
15339
15327
  targetOut,
@@ -15392,16 +15380,15 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15392
15380
  * @private
15393
15381
  */
15394
15382
  _performTransformAction(e, transform, pointer) {
15395
- const x = pointer.x,
15396
- y = pointer.y,
15397
- action = transform.action,
15398
- actionHandler = transform.actionHandler;
15399
- let actionPerformed = false;
15400
- // this object could be created from the function in the control handlers
15383
+ const {
15384
+ action,
15385
+ actionHandler,
15386
+ target
15387
+ } = transform;
15388
+ const actionPerformed = !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);
15389
+ actionPerformed && target.setCoords();
15401
15390
 
15402
- if (actionHandler) {
15403
- actionPerformed = actionHandler(e, transform, x, y);
15404
- }
15391
+ // this object could be created from the function in the control handlers
15405
15392
  if (action === 'drag' && actionPerformed) {
15406
15393
  transform.target.isMoving = true;
15407
15394
  this.setCursor(transform.target.moveCursor || this.moveCursor);
@@ -16028,7 +16015,7 @@ classRegistry.setClass(Gradient, 'gradient');
16028
16015
  classRegistry.setClass(Gradient, 'linear');
16029
16016
  classRegistry.setClass(Gradient, 'radial');
16030
16017
 
16031
- const _excluded$c = ["type", "source"];
16018
+ const _excluded$8 = ["type", "source"];
16032
16019
 
16033
16020
  /**
16034
16021
  * @see {@link http://fabricjs.com/patterns demo}
@@ -16186,7 +16173,7 @@ class Pattern {
16186
16173
  type,
16187
16174
  source
16188
16175
  } = _ref2,
16189
- serialized = _objectWithoutProperties(_ref2, _excluded$c);
16176
+ serialized = _objectWithoutProperties(_ref2, _excluded$8);
16190
16177
  const img = await loadImage(source, _objectSpread2(_objectSpread2({}, options), {}, {
16191
16178
  crossOrigin: serialized.crossOrigin
16192
16179
  }));
@@ -16333,7 +16320,7 @@ class BaseBrush {
16333
16320
  }
16334
16321
  }
16335
16322
 
16336
- const _excluded$b = ["path", "left", "top"],
16323
+ const _excluded$7 = ["path", "left", "top"],
16337
16324
  _excluded2$2 = ["d"];
16338
16325
  class Path extends FabricObject {
16339
16326
  /**
@@ -16349,7 +16336,7 @@ class Path extends FabricObject {
16349
16336
  left,
16350
16337
  top
16351
16338
  } = _ref,
16352
- options = _objectWithoutProperties(_ref, _excluded$b);
16339
+ options = _objectWithoutProperties(_ref, _excluded$7);
16353
16340
  super();
16354
16341
  Object.assign(this, Path.ownDefaults);
16355
16342
  this.setOptions(options);
@@ -16485,7 +16472,7 @@ class Path extends FabricObject {
16485
16472
  toClipPathSVG(reviver) {
16486
16473
  const additionalTransform = this._getOffsetTransform();
16487
16474
  return '\t' + this._createBaseClipPathSVGMarkup(this._toSVG(), {
16488
- reviver: reviver,
16475
+ reviver,
16489
16476
  additionalTransform: additionalTransform
16490
16477
  });
16491
16478
  }
@@ -16498,7 +16485,7 @@ class Path extends FabricObject {
16498
16485
  toSVG(reviver) {
16499
16486
  const additionalTransform = this._getOffsetTransform();
16500
16487
  return this._createBaseSVGMarkup(this._toSVG(), {
16501
- reviver: reviver,
16488
+ reviver,
16502
16489
  additionalTransform: additionalTransform
16503
16490
  });
16504
16491
  }
@@ -16921,7 +16908,7 @@ class PencilBrush extends BaseBrush {
16921
16908
  }
16922
16909
  }
16923
16910
 
16924
- const _excluded$a = ["left", "top", "radius"];
16911
+ const _excluded$6 = ["left", "top", "radius"];
16925
16912
  const CIRCLE_PROPS = ['radius', 'startAngle', 'endAngle', 'counterClockwise'];
16926
16913
  const circleDefaultValues = {
16927
16914
  radius: 0,
@@ -17055,7 +17042,7 @@ class Circle extends FabricObject {
17055
17042
  top = 0,
17056
17043
  radius = 0
17057
17044
  } = _ref,
17058
- otherParsedAttributes = _objectWithoutProperties(_ref, _excluded$a);
17045
+ otherParsedAttributes = _objectWithoutProperties(_ref, _excluded$6);
17059
17046
 
17060
17047
  // this probably requires to be fixed for default origins not being top/left.
17061
17048
 
@@ -17438,7 +17425,7 @@ class PatternBrush extends PencilBrush {
17438
17425
  }
17439
17426
  }
17440
17427
 
17441
- const _excluded$9 = ["x1", "y1", "x2", "y2"],
17428
+ const _excluded$5 = ["x1", "y1", "x2", "y2"],
17442
17429
  _excluded2$1 = ["x1", "y1", "x2", "y2"];
17443
17430
  // @TODO this code is terrible and Line should be a special case of polyline.
17444
17431
 
@@ -17650,7 +17637,7 @@ class Line extends FabricObject {
17650
17637
  x2 = 0,
17651
17638
  y2 = 0
17652
17639
  } = _parseAttributes,
17653
- parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$9);
17640
+ parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$5);
17654
17641
  return new this([x1, y1, x2, y2], parsedAttributes);
17655
17642
  }
17656
17643
 
@@ -17916,7 +17903,7 @@ function parsePointsAttribute(points) {
17916
17903
  return parsedPoints;
17917
17904
  }
17918
17905
 
17919
- const _excluded$8 = ["left", "top"];
17906
+ const _excluded$4 = ["left", "top"];
17920
17907
  const polylineDefaultValues = {
17921
17908
  /**
17922
17909
  * @deprecated transient option soon to be removed in favor of a different design
@@ -18199,7 +18186,7 @@ class Polyline extends FabricObject {
18199
18186
  static async fromElement(element, options, cssRules) {
18200
18187
  const points = parsePointsAttribute(element.getAttribute('points')),
18201
18188
  _parseAttributes = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules),
18202
- parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$8);
18189
+ parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$4);
18203
18190
  return new this(points, _objectSpread2(_objectSpread2({}, parsedAttributes), options));
18204
18191
  }
18205
18192
 
@@ -18791,7 +18778,7 @@ class TextSVGExportMixin extends FabricObjectSVGExportMixin {
18791
18778
  }
18792
18779
  }
18793
18780
 
18794
- const _excluded$7 = ["textAnchor", "textDecoration", "dx", "dy", "top", "left", "fontSize", "strokeWidth"];
18781
+ const _excluded$3 = ["textAnchor", "textDecoration", "dx", "dy", "top", "left", "fontSize", "strokeWidth"];
18795
18782
  let measuringContext;
18796
18783
 
18797
18784
  /**
@@ -19995,7 +19982,7 @@ class FabricText extends StyledText {
19995
19982
  fontSize = DEFAULT_SVG_FONT_SIZE,
19996
19983
  strokeWidth = 1
19997
19984
  } = _options$parsedAttrib,
19998
- restOfOptions = _objectWithoutProperties(_options$parsedAttrib, _excluded$7);
19985
+ restOfOptions = _objectWithoutProperties(_options$parsedAttrib, _excluded$3);
19999
19986
  const textContent = (element.textContent || '').replace(/^\s+|\s+$|\n+/g, '').replace(/\s+/g, ' ');
20000
19987
 
20001
19988
  // this code here is probably the usual issue for SVG center find
@@ -23362,7 +23349,6 @@ class ActiveSelectionLayoutManager extends LayoutManager {
23362
23349
  }
23363
23350
  }
23364
23351
 
23365
- const _excluded$6 = ["layoutManager"];
23366
23352
  const activeSelectionDefaultValues = {
23367
23353
  multiSelectionStacking: 'canvas-stacking'
23368
23354
  };
@@ -23398,16 +23384,20 @@ class ActiveSelection extends Group {
23398
23384
 
23399
23385
  constructor() {
23400
23386
  let objects = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
23401
- let _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
23402
- {
23403
- layoutManager
23404
- } = _ref,
23405
- options = _objectWithoutProperties(_ref, _excluded$6);
23406
- super(objects, {
23407
- layoutManager: layoutManager !== null && layoutManager !== void 0 ? layoutManager : new ActiveSelectionLayoutManager()
23408
- });
23387
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
23388
+ super();
23409
23389
  Object.assign(this, ActiveSelection.ownDefaults);
23410
23390
  this.setOptions(options);
23391
+ const {
23392
+ left,
23393
+ top,
23394
+ layoutManager
23395
+ } = options;
23396
+ this.groupInit(objects, {
23397
+ left,
23398
+ top,
23399
+ layoutManager: layoutManager !== null && layoutManager !== void 0 ? layoutManager : new ActiveSelectionLayoutManager()
23400
+ });
23411
23401
  }
23412
23402
 
23413
23403
  /**
@@ -23987,7 +23977,7 @@ function setFilterBackend(backend) {
23987
23977
  filterBackend = backend;
23988
23978
  }
23989
23979
 
23990
- const _excluded$5 = ["filters", "resizeFilter", "src", "crossOrigin", "type"];
23980
+ const _excluded$2 = ["filters", "resizeFilter", "src", "crossOrigin", "type"];
23991
23981
 
23992
23982
  // @todo Would be nice to have filtering code not imported directly.
23993
23983
 
@@ -24570,7 +24560,7 @@ class FabricImage extends FabricObject {
24570
24560
  crossOrigin,
24571
24561
  type
24572
24562
  } = _ref,
24573
- object = _objectWithoutProperties(_ref, _excluded$5);
24563
+ object = _objectWithoutProperties(_ref, _excluded$2);
24574
24564
  return Promise.all([loadImage(src, _objectSpread2(_objectSpread2({}, options), {}, {
24575
24565
  crossOrigin
24576
24566
  })), f && enlivenObjects(f, options),
@@ -25340,9 +25330,9 @@ const isPutImageFaster = (width, height) => {
25340
25330
 
25341
25331
  const highPsourceCode = "precision highp float";
25342
25332
  const identityFragmentShader = "\n ".concat(highPsourceCode, ";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }");
25343
- 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 }";
25333
+ 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 }";
25344
25334
 
25345
- const _excluded$4 = ["type"],
25335
+ const _excluded$1 = ["type"],
25346
25336
  _excluded2 = ["type"];
25347
25337
  const regex = new RegExp(highPsourceCode, 'g');
25348
25338
  class BaseFilter {
@@ -25363,30 +25353,21 @@ class BaseFilter {
25363
25353
  * to avoid doing that.
25364
25354
  */
25365
25355
 
25366
- /**
25367
- * Name of the parameter that can be changed in the filter.
25368
- * Some filters have more than one parameter and there is no
25369
- * mainParameter
25370
- * @private
25371
- */
25372
-
25373
25356
  /**
25374
25357
  * Constructor
25375
25358
  * @param {Object} [options] Options object
25376
25359
  */
25377
25360
  constructor() {
25378
25361
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
25379
- options = _objectWithoutProperties(_ref, _excluded$4);
25380
- /**
25381
- * Array of attributes to send with buffers. do not modify
25382
- * @private
25383
- */
25384
- _defineProperty(this, "vertexSource", vertexSource);
25362
+ options = _objectWithoutProperties(_ref, _excluded$1);
25385
25363
  Object.assign(this, this.constructor.defaults, options);
25386
25364
  }
25387
25365
  getFragmentSource() {
25388
25366
  return identityFragmentShader;
25389
25367
  }
25368
+ getVertexSource() {
25369
+ return vertexSource$1;
25370
+ }
25390
25371
 
25391
25372
  /**
25392
25373
  * Compile this filter's shader program.
@@ -25397,7 +25378,7 @@ class BaseFilter {
25397
25378
  */
25398
25379
  createProgram(gl) {
25399
25380
  let fragmentSource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFragmentSource();
25400
- let vertexSource = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.vertexSource;
25381
+ let vertexSource = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getVertexSource();
25401
25382
  const {
25402
25383
  WebGLProbe: {
25403
25384
  GLPrecision = 'highp'
@@ -25454,14 +25435,17 @@ class BaseFilter {
25454
25435
  /**
25455
25436
  * Return a map of uniform names to WebGLUniformLocation objects.
25456
25437
  *
25457
- * Intended to be overridden by subclasses.
25458
- *
25459
25438
  * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.
25460
25439
  * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.
25461
25440
  * @returns {Object} A map of uniform names to uniform locations.
25462
25441
  */
25463
25442
  getUniformLocations(gl, program) {
25464
- return {};
25443
+ const locations = this.constructor.uniformLocations;
25444
+ const uniformLocations = {};
25445
+ for (let i = 0; i < locations.length; i++) {
25446
+ uniformLocations[locations[i]] = gl.getUniformLocation(program, locations[i]);
25447
+ }
25448
+ return uniformLocations;
25465
25449
  }
25466
25450
 
25467
25451
  /**
@@ -25511,18 +25495,7 @@ class BaseFilter {
25511
25495
  **/
25512
25496
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
25513
25497
  isNeutralState(options) {
25514
- const main = this.mainParameter,
25515
- defaultValue = this.constructor.defaults[main];
25516
- if (main) {
25517
- const thisValue = this[main];
25518
- if (Array.isArray(defaultValue) && Array.isArray(thisValue)) {
25519
- return defaultValue.every((value, i) => value === thisValue[i]);
25520
- } else {
25521
- return defaultValue === thisValue;
25522
- }
25523
- } else {
25524
- return false;
25525
- }
25498
+ return false;
25526
25499
  }
25527
25500
 
25528
25501
  /**
@@ -25614,14 +25587,6 @@ class BaseFilter {
25614
25587
  gl.bindTexture(gl.TEXTURE_2D, null);
25615
25588
  gl.activeTexture(gl.TEXTURE0);
25616
25589
  }
25617
- getMainParameter() {
25618
- return this.mainParameter ? this[this.mainParameter] : undefined;
25619
- }
25620
- setMainParameter(value) {
25621
- if (this.mainParameter) {
25622
- this[this.mainParameter] = value;
25623
- }
25624
- }
25625
25590
 
25626
25591
  /**
25627
25592
  * Send uniform data from this filter to its shader program on the GPU.
@@ -25653,12 +25618,14 @@ class BaseFilter {
25653
25618
  * @return {Object} Object representation of an instance
25654
25619
  */
25655
25620
  toObject() {
25656
- const mainP = this.mainParameter;
25621
+ const defaultKeys = Object.keys(this.constructor.defaults);
25657
25622
  return _objectSpread2({
25658
25623
  type: this.type
25659
- }, mainP ? {
25660
- [mainP]: this[mainP]
25661
- } : {});
25624
+ }, defaultKeys.reduce((acc, key) => {
25625
+ //@ts-expect-error TS doesn't get i want an object that looks like this
25626
+ acc[key] = this[key];
25627
+ return acc;
25628
+ }, {}));
25662
25629
  }
25663
25630
 
25664
25631
  /**
@@ -25675,6 +25642,12 @@ class BaseFilter {
25675
25642
  }
25676
25643
  }
25677
25644
  _defineProperty(BaseFilter, "type", 'BaseFilter');
25645
+ /**
25646
+ * Contains the uniform locations for the fragment shader.
25647
+ * uStepW and uStepH are handled by the BaseFilter, each filter class
25648
+ * needs to specify all the one that are needed
25649
+ */
25650
+ _defineProperty(BaseFilter, "uniformLocations", []);
25678
25651
 
25679
25652
  const blendColorFragmentSource = {
25680
25653
  multiply: 'gl_FragColor.rgb *= uColor.rgb;\n',
@@ -25794,18 +25767,6 @@ class BlendColor extends BaseFilter {
25794
25767
  }
25795
25768
  }
25796
25769
 
25797
- /**
25798
- * Return WebGL uniform locations for this filter's shader.
25799
- *
25800
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
25801
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
25802
- */
25803
- getUniformLocations(gl, program) {
25804
- return {
25805
- uColor: gl.getUniformLocation(program, 'uColor')
25806
- };
25807
- }
25808
-
25809
25770
  /**
25810
25771
  * Send data from this filter to its shader program's uniforms.
25811
25772
  *
@@ -25820,19 +25781,6 @@ class BlendColor extends BaseFilter {
25820
25781
  source[3] = this.alpha;
25821
25782
  gl.uniform4fv(uniformLocations.uColor, source);
25822
25783
  }
25823
-
25824
- /**
25825
- * Returns object representation of an instance
25826
- * @return {Object} Object representation of an instance
25827
- */
25828
- toObject() {
25829
- return {
25830
- type: this.type,
25831
- color: this.color,
25832
- mode: this.mode,
25833
- alpha: this.alpha
25834
- };
25835
- }
25836
25784
  }
25837
25785
  /**
25838
25786
  * Color to make the blend operation with. default to a reddish color since black or white
@@ -25853,18 +25801,19 @@ class BlendColor extends BaseFilter {
25853
25801
  **/
25854
25802
  _defineProperty(BlendColor, "defaults", blendColorDefaultValues);
25855
25803
  _defineProperty(BlendColor, "type", 'BlendColor');
25804
+ _defineProperty(BlendColor, "uniformLocations", ['uColor']);
25856
25805
  classRegistry.setClass(BlendColor);
25857
25806
 
25858
25807
  const fragmentSource$c = {
25859
25808
  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 ",
25860
25809
  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 "
25861
25810
  };
25811
+ 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 ";
25862
25812
 
25863
- const _excluded$3 = ["type", "image"];
25813
+ const _excluded = ["type", "image"];
25864
25814
  const blendImageDefaultValues = {
25865
25815
  mode: 'multiply',
25866
- alpha: 1,
25867
- 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 "
25816
+ alpha: 1
25868
25817
  };
25869
25818
 
25870
25819
  /**
@@ -25890,6 +25839,9 @@ class BlendImage extends BaseFilter {
25890
25839
  getFragmentSource() {
25891
25840
  return fragmentSource$c[this.mode];
25892
25841
  }
25842
+ getVertexSource() {
25843
+ return vertexSource;
25844
+ }
25893
25845
  applyToWebGL(options) {
25894
25846
  const gl = options.context,
25895
25847
  texture = this.createTexture(options.filterBackend, this.image);
@@ -25971,19 +25923,6 @@ class BlendImage extends BaseFilter {
25971
25923
  }
25972
25924
  }
25973
25925
 
25974
- /**
25975
- * Return WebGL uniform locations for this filter's shader.
25976
- *
25977
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
25978
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
25979
- */
25980
- getUniformLocations(gl, program) {
25981
- return {
25982
- uTransformMatrix: gl.getUniformLocation(program, 'uTransformMatrix'),
25983
- uImage: gl.getUniformLocation(program, 'uImage')
25984
- };
25985
- }
25986
-
25987
25926
  /**
25988
25927
  * Send data from this filter to its shader program's uniforms.
25989
25928
  *
@@ -25998,15 +25937,14 @@ class BlendImage extends BaseFilter {
25998
25937
 
25999
25938
  /**
26000
25939
  * Returns object representation of an instance
25940
+ * TODO: Handle the possibility of missing image better.
25941
+ * As of now a BlendImage filter without image can't be used with fromObject
26001
25942
  * @return {Object} Object representation of an instance
26002
25943
  */
26003
25944
  toObject() {
26004
- return {
26005
- type: this.type,
26006
- image: this.image && this.image.toObject(),
26007
- mode: this.mode,
26008
- alpha: this.alpha
26009
- };
25945
+ return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
25946
+ image: this.image && this.image.toObject()
25947
+ });
26010
25948
  }
26011
25949
 
26012
25950
  /**
@@ -26017,12 +25955,12 @@ class BlendImage extends BaseFilter {
26017
25955
  * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
26018
25956
  * @returns {Promise<BlendImage>}
26019
25957
  */
26020
- static fromObject(_ref2, options) {
25958
+ static async fromObject(_ref2, options) {
26021
25959
  let {
26022
25960
  type,
26023
25961
  image
26024
25962
  } = _ref2,
26025
- filterOptions = _objectWithoutProperties(_ref2, _excluded$3);
25963
+ filterOptions = _objectWithoutProperties(_ref2, _excluded);
26026
25964
  return FabricImage.fromObject(image, options).then(enlivedImage => new this(_objectSpread2(_objectSpread2({}, filterOptions), {}, {
26027
25965
  image: enlivedImage
26028
25966
  })));
@@ -26046,13 +25984,13 @@ class BlendImage extends BaseFilter {
26046
25984
  **/
26047
25985
  _defineProperty(BlendImage, "type", 'BlendImage');
26048
25986
  _defineProperty(BlendImage, "defaults", blendImageDefaultValues);
25987
+ _defineProperty(BlendImage, "uniformLocations", ['uTransformMatrix', 'uImage']);
26049
25988
  classRegistry.setClass(BlendImage);
26050
25989
 
26051
25990
  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 ";
26052
25991
 
26053
25992
  const blurDefaultValues = {
26054
- blur: 0,
26055
- mainParameter: 'blur'
25993
+ blur: 0
26056
25994
  };
26057
25995
 
26058
25996
  /**
@@ -26147,18 +26085,6 @@ class Blur extends BaseFilter {
26147
26085
  return newImageData;
26148
26086
  }
26149
26087
 
26150
- /**
26151
- * Return WebGL uniform locations for this filter's shader.
26152
- *
26153
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26154
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26155
- */
26156
- getUniformLocations(gl, program) {
26157
- return {
26158
- delta: gl.getUniformLocation(program, 'uDelta')
26159
- };
26160
- }
26161
-
26162
26088
  /**
26163
26089
  * Send data from this filter to its shader program's uniforms.
26164
26090
  *
@@ -26169,6 +26095,9 @@ class Blur extends BaseFilter {
26169
26095
  const delta = this.chooseRightDelta();
26170
26096
  gl.uniform2fv(uniformLocations.delta, delta);
26171
26097
  }
26098
+ isNeutralState() {
26099
+ return this.blur === 0;
26100
+ }
26172
26101
 
26173
26102
  /**
26174
26103
  * choose right value of image percentage to blur with
@@ -26206,13 +26135,13 @@ class Blur extends BaseFilter {
26206
26135
  */
26207
26136
  _defineProperty(Blur, "type", 'Blur');
26208
26137
  _defineProperty(Blur, "defaults", blurDefaultValues);
26138
+ _defineProperty(Blur, "uniformLocations", ['uDelta']);
26209
26139
  classRegistry.setClass(Blur);
26210
26140
 
26211
26141
  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";
26212
26142
 
26213
26143
  const brightnessDefaultValues = {
26214
- brightness: 0,
26215
- mainParameter: 'brightness'
26144
+ brightness: 0
26216
26145
  };
26217
26146
 
26218
26147
  /**
@@ -26241,9 +26170,6 @@ class Brightness extends BaseFilter {
26241
26170
  data
26242
26171
  }
26243
26172
  } = _ref;
26244
- if (this.brightness === 0) {
26245
- return;
26246
- }
26247
26173
  const brightness = Math.round(this.brightness * 255);
26248
26174
  for (let i = 0; i < data.length; i += 4) {
26249
26175
  data[i] = data[i] + brightness;
@@ -26251,17 +26177,8 @@ class Brightness extends BaseFilter {
26251
26177
  data[i + 2] = data[i + 2] + brightness;
26252
26178
  }
26253
26179
  }
26254
-
26255
- /**
26256
- * Return WebGL uniform locations for this filter's shader.
26257
- *
26258
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26259
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26260
- */
26261
- getUniformLocations(gl, program) {
26262
- return {
26263
- uBrightness: gl.getUniformLocation(program, 'uBrightness')
26264
- };
26180
+ isNeutralState() {
26181
+ return this.brightness === 0;
26265
26182
  }
26266
26183
 
26267
26184
  /**
@@ -26283,14 +26200,13 @@ class Brightness extends BaseFilter {
26283
26200
  */
26284
26201
  _defineProperty(Brightness, "type", 'Brightness');
26285
26202
  _defineProperty(Brightness, "defaults", brightnessDefaultValues);
26203
+ _defineProperty(Brightness, "uniformLocations", ['uBrightness']);
26286
26204
  classRegistry.setClass(Brightness);
26287
26205
 
26288
26206
  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 }";
26289
26207
 
26290
- const _excluded$2 = ["matrix"];
26291
26208
  const colorMatrixDefaultValues = {
26292
26209
  matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
26293
- mainParameter: 'matrix',
26294
26210
  colorsOnly: true
26295
26211
  };
26296
26212
 
@@ -26311,17 +26227,6 @@ const colorMatrixDefaultValues = {
26311
26227
  * object.applyFilters();
26312
26228
  */
26313
26229
  class ColorMatrix extends BaseFilter {
26314
- setOptions(_ref) {
26315
- let {
26316
- matrix
26317
- } = _ref,
26318
- options = _objectWithoutProperties(_ref, _excluded$2);
26319
- if (matrix) {
26320
- // safeguard against mutation
26321
- this.matrix = [...matrix];
26322
- }
26323
- Object.assign(this, options);
26324
- }
26325
26230
  getFragmentSource() {
26326
26231
  return fragmentSource$9;
26327
26232
  }
@@ -26355,19 +26260,6 @@ class ColorMatrix extends BaseFilter {
26355
26260
  }
26356
26261
  }
26357
26262
 
26358
- /**
26359
- * Return WebGL uniform locations for this filter's shader.
26360
- *
26361
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26362
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26363
- */
26364
- getUniformLocations(gl, program) {
26365
- return {
26366
- uColorMatrix: gl.getUniformLocation(program, 'uColorMatrix'),
26367
- uConstants: gl.getUniformLocation(program, 'uConstants')
26368
- };
26369
- }
26370
-
26371
26263
  /**
26372
26264
  * Send data from this filter to its shader program's uniforms.
26373
26265
  *
@@ -26381,6 +26273,11 @@ class ColorMatrix extends BaseFilter {
26381
26273
  gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);
26382
26274
  gl.uniform4fv(uniformLocations.uConstants, constants);
26383
26275
  }
26276
+ toObject() {
26277
+ return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
26278
+ matrix: [...this.matrix]
26279
+ });
26280
+ }
26384
26281
  }
26385
26282
  /**
26386
26283
  * Colormatrix for pixels.
@@ -26398,17 +26295,23 @@ class ColorMatrix extends BaseFilter {
26398
26295
  */
26399
26296
  _defineProperty(ColorMatrix, "type", 'ColorMatrix');
26400
26297
  _defineProperty(ColorMatrix, "defaults", colorMatrixDefaultValues);
26298
+ _defineProperty(ColorMatrix, "uniformLocations", ['uColorMatrix', 'uConstants']);
26401
26299
  classRegistry.setClass(ColorMatrix);
26402
26300
 
26403
26301
  function createColorMatrixFilter(key, matrix) {
26404
26302
  var _class;
26405
- const newClass = (_class = class newClass extends ColorMatrix {}, _defineProperty(_class, "type", key), _defineProperty(_class, "defaults", _objectSpread2(_objectSpread2({}, colorMatrixDefaultValues), {}, {
26406
- /**
26407
- * Lock the matrix export for this kind of static, parameter less filters.
26408
- */
26409
- mainParameter: undefined,
26303
+ const newClass = (_class = class newClass extends ColorMatrix {
26304
+ //@ts-expect-error TS wants matrix to be exported.
26305
+ toObject() {
26306
+ return {
26307
+ type: this.type,
26308
+ colorsOnly: this.colorsOnly
26309
+ };
26310
+ }
26311
+ }, _defineProperty(_class, "type", key), _defineProperty(_class, "defaults", {
26312
+ colorsOnly: false,
26410
26313
  matrix
26411
- })), _class);
26314
+ }), _class);
26412
26315
  classRegistry.setClass(newClass, key);
26413
26316
  return newClass;
26414
26317
  }
@@ -26420,20 +26323,14 @@ const Polaroid = createColorMatrixFilter('Polaroid', [1.438, -0.062, -0.062, 0,
26420
26323
  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]);
26421
26324
  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]);
26422
26325
 
26423
- const _excluded$1 = ["subFilters"];
26424
-
26425
26326
  /**
26426
26327
  * A container class that knows how to apply a sequence of filters to an input image.
26427
26328
  */
26428
26329
  class Composed extends BaseFilter {
26429
26330
  constructor() {
26430
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
26431
- {
26432
- subFilters = []
26433
- } = _ref,
26434
- options = _objectWithoutProperties(_ref, _excluded$1);
26331
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26435
26332
  super(options);
26436
- this.subFilters = subFilters;
26333
+ this.subFilters = options.subFilters || [];
26437
26334
  }
26438
26335
 
26439
26336
  /**
@@ -26453,13 +26350,14 @@ class Composed extends BaseFilter {
26453
26350
 
26454
26351
  /**
26455
26352
  * Serialize this filter into JSON.
26456
- *
26457
26353
  * @returns {Object} A JSON representation of this filter.
26458
26354
  */
26355
+ //@ts-expect-error TS doesn't like this toObject
26459
26356
  toObject() {
26460
- return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
26357
+ return {
26358
+ type: this.type,
26461
26359
  subFilters: this.subFilters.map(filter => filter.toObject())
26462
- });
26360
+ };
26463
26361
  }
26464
26362
  isNeutralState() {
26465
26363
  return !this.subFilters.some(filter => !filter.isNeutralState());
@@ -26488,8 +26386,7 @@ classRegistry.setClass(Composed);
26488
26386
  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 }";
26489
26387
 
26490
26388
  const contrastDefaultValues = {
26491
- contrast: 0,
26492
- mainParameter: 'contrast'
26389
+ contrast: 0
26493
26390
  };
26494
26391
 
26495
26392
  /**
@@ -26505,6 +26402,10 @@ class Contrast extends BaseFilter {
26505
26402
  getFragmentSource() {
26506
26403
  return fragmentSource$8;
26507
26404
  }
26405
+ isNeutralState() {
26406
+ return this.contrast === 0;
26407
+ }
26408
+
26508
26409
  /**
26509
26410
  * Apply the Contrast operation to a Uint8Array representing the pixels of an image.
26510
26411
  *
@@ -26517,9 +26418,6 @@ class Contrast extends BaseFilter {
26517
26418
  data
26518
26419
  }
26519
26420
  } = _ref;
26520
- if (this.contrast === 0) {
26521
- return;
26522
- }
26523
26421
  const contrast = Math.floor(this.contrast * 255),
26524
26422
  contrastF = 259 * (contrast + 255) / (255 * (259 - contrast));
26525
26423
  for (let i = 0; i < data.length; i += 4) {
@@ -26529,18 +26427,6 @@ class Contrast extends BaseFilter {
26529
26427
  }
26530
26428
  }
26531
26429
 
26532
- /**
26533
- * Return WebGL uniform locations for this filter's shader.
26534
- *
26535
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26536
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26537
- */
26538
- getUniformLocations(gl, program) {
26539
- return {
26540
- uContrast: gl.getUniformLocation(program, 'uContrast')
26541
- };
26542
- }
26543
-
26544
26430
  /**
26545
26431
  * Send data from this filter to its shader program's uniforms.
26546
26432
  *
@@ -26558,6 +26444,7 @@ class Contrast extends BaseFilter {
26558
26444
  */
26559
26445
  _defineProperty(Contrast, "type", 'Contrast');
26560
26446
  _defineProperty(Contrast, "defaults", contrastDefaultValues);
26447
+ _defineProperty(Contrast, "uniformLocations", ['uContrast']);
26561
26448
  classRegistry.setClass(Contrast);
26562
26449
 
26563
26450
  const fragmentSource$7 = {
@@ -26685,21 +26572,6 @@ class Convolute extends BaseFilter {
26685
26572
  options.imageData = output;
26686
26573
  }
26687
26574
 
26688
- /**
26689
- * Return WebGL uniform locations for this filter's shader.
26690
- *
26691
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26692
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26693
- */
26694
- getUniformLocations(gl, program) {
26695
- return {
26696
- uMatrix: gl.getUniformLocation(program, 'uMatrix'),
26697
- uOpaque: gl.getUniformLocation(program, 'uOpaque'),
26698
- uHalfSize: gl.getUniformLocation(program, 'uHalfSize'),
26699
- uSize: gl.getUniformLocation(program, 'uSize')
26700
- };
26701
- }
26702
-
26703
26575
  /**
26704
26576
  * Send data from this filter to its shader program's uniforms.
26705
26577
  *
@@ -26729,13 +26601,13 @@ class Convolute extends BaseFilter {
26729
26601
  */
26730
26602
  _defineProperty(Convolute, "type", 'Convolute');
26731
26603
  _defineProperty(Convolute, "defaults", convoluteDefaultValues);
26604
+ _defineProperty(Convolute, "uniformLocations", ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize']);
26732
26605
  classRegistry.setClass(Convolute);
26733
26606
 
26734
26607
  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";
26735
26608
 
26736
- const _excluded = ["gamma"];
26609
+ const GAMMA = 'Gamma';
26737
26610
  const gammaDefaultValues = {
26738
- mainParameter: 'gamma',
26739
26611
  gamma: [1, 1, 1]
26740
26612
  };
26741
26613
 
@@ -26753,13 +26625,9 @@ class Gamma extends BaseFilter {
26753
26625
  return fragmentSource$6;
26754
26626
  }
26755
26627
  constructor() {
26756
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
26757
- {
26758
- gamma = [1, 1, 1]
26759
- } = _ref,
26760
- options = _objectWithoutProperties(_ref, _excluded);
26628
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26761
26629
  super(options);
26762
- this.gamma = gamma;
26630
+ this.gamma = options.gamma || this.constructor.defaults.gamma.concat();
26763
26631
  }
26764
26632
 
26765
26633
  /**
@@ -26768,12 +26636,12 @@ class Gamma extends BaseFilter {
26768
26636
  * @param {Object} options
26769
26637
  * @param {ImageData} options.imageData The Uint8Array to be filtered.
26770
26638
  */
26771
- applyTo2d(_ref2) {
26639
+ applyTo2d(_ref) {
26772
26640
  let {
26773
26641
  imageData: {
26774
26642
  data
26775
26643
  }
26776
- } = _ref2;
26644
+ } = _ref;
26777
26645
  const gamma = this.gamma,
26778
26646
  rInv = 1 / gamma[0],
26779
26647
  gInv = 1 / gamma[1],
@@ -26801,18 +26669,6 @@ class Gamma extends BaseFilter {
26801
26669
  }
26802
26670
  }
26803
26671
 
26804
- /**
26805
- * Return WebGL uniform locations for this filter's shader.
26806
- *
26807
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26808
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26809
- */
26810
- getUniformLocations(gl, program) {
26811
- return {
26812
- uGamma: gl.getUniformLocation(program, 'uGamma')
26813
- };
26814
- }
26815
-
26816
26672
  /**
26817
26673
  * Send data from this filter to its shader program's uniforms.
26818
26674
  *
@@ -26822,14 +26678,27 @@ class Gamma extends BaseFilter {
26822
26678
  sendUniformData(gl, uniformLocations) {
26823
26679
  gl.uniform3fv(uniformLocations.uGamma, this.gamma);
26824
26680
  }
26681
+ isNeutralState() {
26682
+ const {
26683
+ gamma
26684
+ } = this;
26685
+ return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;
26686
+ }
26687
+ toObject() {
26688
+ return {
26689
+ type: GAMMA,
26690
+ gamma: this.gamma.concat()
26691
+ };
26692
+ }
26825
26693
  }
26826
26694
  /**
26827
26695
  * Gamma array value, from 0.01 to 2.2.
26828
26696
  * @param {Array} gamma
26829
26697
  * @default
26830
26698
  */
26831
- _defineProperty(Gamma, "type", 'Gamma');
26699
+ _defineProperty(Gamma, "type", GAMMA);
26832
26700
  _defineProperty(Gamma, "defaults", gammaDefaultValues);
26701
+ _defineProperty(Gamma, "uniformLocations", ['uGamma']);
26833
26702
  classRegistry.setClass(Gamma);
26834
26703
 
26835
26704
  const fragmentSource$5 = {
@@ -26839,8 +26708,7 @@ const fragmentSource$5 = {
26839
26708
  };
26840
26709
 
26841
26710
  const grayscaleDefaultValues = {
26842
- mode: 'average',
26843
- mainParameter: 'mode'
26711
+ mode: 'average'
26844
26712
  };
26845
26713
 
26846
26714
  /**
@@ -26887,18 +26755,6 @@ class Grayscale extends BaseFilter {
26887
26755
  return fragmentSource$5[this.mode];
26888
26756
  }
26889
26757
 
26890
- /**
26891
- * Return WebGL uniform locations for this filter's shader.
26892
- *
26893
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26894
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26895
- */
26896
- getUniformLocations(gl, program) {
26897
- return {
26898
- uMode: gl.getUniformLocation(program, 'uMode')
26899
- };
26900
- }
26901
-
26902
26758
  /**
26903
26759
  * Send data from this filter to its shader program's uniforms.
26904
26760
  *
@@ -26921,11 +26777,11 @@ class Grayscale extends BaseFilter {
26921
26777
  }
26922
26778
  _defineProperty(Grayscale, "type", 'Grayscale');
26923
26779
  _defineProperty(Grayscale, "defaults", grayscaleDefaultValues);
26780
+ _defineProperty(Grayscale, "uniformLocations", ['uMode']);
26924
26781
  classRegistry.setClass(Grayscale);
26925
26782
 
26926
26783
  const hueRotationDefaultValues = {
26927
- rotation: 0,
26928
- mainParameter: 'rotation'
26784
+ rotation: 0
26929
26785
  };
26930
26786
 
26931
26787
  /**
@@ -26937,7 +26793,6 @@ const hueRotationDefaultValues = {
26937
26793
  * object.filters.push(filter);
26938
26794
  * object.applyFilters();
26939
26795
  */
26940
- // @ts-expect-error some babbling about mainParameter
26941
26796
  class HueRotation extends ColorMatrix {
26942
26797
  calculateMatrix() {
26943
26798
  const rad = this.rotation * Math.PI,
@@ -26958,13 +26813,20 @@ class HueRotation extends ColorMatrix {
26958
26813
  this.matrix[12] = cosine + aThird * OneMinusCos;
26959
26814
  }
26960
26815
  isNeutralState() {
26961
- this.calculateMatrix();
26962
- return super.isNeutralState();
26816
+ return this.rotation === 0;
26963
26817
  }
26964
26818
  applyTo(options) {
26965
26819
  this.calculateMatrix();
26966
26820
  super.applyTo(options);
26967
26821
  }
26822
+
26823
+ //@ts-expect-error TS and classes with different methods
26824
+ toObject() {
26825
+ return {
26826
+ type: this.type,
26827
+ rotation: this.rotation
26828
+ };
26829
+ }
26968
26830
  }
26969
26831
  /**
26970
26832
  * HueRotation value, from -1 to 1.
@@ -26977,8 +26839,7 @@ const fragmentSource$4 = "\n precision highp float;\n uniform sampler2D uTextu
26977
26839
 
26978
26840
  const invertDefaultValues = {
26979
26841
  alpha: false,
26980
- invert: true,
26981
- mainParameter: 'invert'
26842
+ invert: true
26982
26843
  };
26983
26844
 
26984
26845
  /**
@@ -27023,19 +26884,6 @@ class Invert extends BaseFilter {
27023
26884
  return !this.invert;
27024
26885
  }
27025
26886
 
27026
- /**
27027
- * Return WebGL uniform locations for this filter's shader.
27028
- *
27029
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27030
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27031
- */
27032
- getUniformLocations(gl, program) {
27033
- return {
27034
- uInvert: gl.getUniformLocation(program, 'uInvert'),
27035
- uAlpha: gl.getUniformLocation(program, 'uAlpha')
27036
- };
27037
- }
27038
-
27039
26887
  /**
27040
26888
  * Send data from this filter to its shader program's uniforms.
27041
26889
  *
@@ -27059,12 +26907,12 @@ class Invert extends BaseFilter {
27059
26907
  */
27060
26908
  _defineProperty(Invert, "type", 'Invert');
27061
26909
  _defineProperty(Invert, "defaults", invertDefaultValues);
26910
+ _defineProperty(Invert, "uniformLocations", ['uInvert', 'uAlpha']);
27062
26911
  classRegistry.setClass(Invert);
27063
26912
 
27064
26913
  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";
27065
26914
 
27066
26915
  const noiseDefaultValues = {
27067
- mainParameter: 'noise',
27068
26916
  noise: 0
27069
26917
  };
27070
26918
 
@@ -27095,9 +26943,6 @@ class Noise extends BaseFilter {
27095
26943
  data
27096
26944
  }
27097
26945
  } = _ref;
27098
- if (this.noise === 0) {
27099
- return;
27100
- }
27101
26946
  const noise = this.noise;
27102
26947
  for (let i = 0; i < data.length; i += 4) {
27103
26948
  const rand = (0.5 - Math.random()) * noise;
@@ -27107,19 +26952,6 @@ class Noise extends BaseFilter {
27107
26952
  }
27108
26953
  }
27109
26954
 
27110
- /**
27111
- * Return WebGL uniform locations for this filter's shader.
27112
- *
27113
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27114
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27115
- */
27116
- getUniformLocations(gl, program) {
27117
- return {
27118
- uNoise: gl.getUniformLocation(program, 'uNoise'),
27119
- uSeed: gl.getUniformLocation(program, 'uSeed')
27120
- };
27121
- }
27122
-
27123
26955
  /**
27124
26956
  * Send data from this filter to its shader program's uniforms.
27125
26957
  *
@@ -27130,15 +26962,8 @@ class Noise extends BaseFilter {
27130
26962
  gl.uniform1f(uniformLocations.uNoise, this.noise / 255);
27131
26963
  gl.uniform1f(uniformLocations.uSeed, Math.random());
27132
26964
  }
27133
-
27134
- /**
27135
- * Returns object representation of an instance
27136
- * @return {Object} Object representation of an instance
27137
- */
27138
- toObject() {
27139
- return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
27140
- noise: this.noise
27141
- });
26965
+ isNeutralState() {
26966
+ return this.noise === 0;
27142
26967
  }
27143
26968
  }
27144
26969
  /**
@@ -27148,13 +26973,13 @@ class Noise extends BaseFilter {
27148
26973
  */
27149
26974
  _defineProperty(Noise, "type", 'Noise');
27150
26975
  _defineProperty(Noise, "defaults", noiseDefaultValues);
26976
+ _defineProperty(Noise, "uniformLocations", ['uNoise', 'uSeed']);
27151
26977
  classRegistry.setClass(Noise);
27152
26978
 
27153
26979
  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";
27154
26980
 
27155
26981
  const pixelateDefaultValues = {
27156
- blocksize: 4,
27157
- mainParameter: 'blocksize'
26982
+ blocksize: 4
27158
26983
  };
27159
26984
 
27160
26985
  /**
@@ -27211,20 +27036,6 @@ class Pixelate extends BaseFilter {
27211
27036
  return fragmentSource$2;
27212
27037
  }
27213
27038
 
27214
- /**
27215
- * Return WebGL uniform locations for this filter's shader.
27216
- *
27217
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27218
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27219
- */
27220
- getUniformLocations(gl, program) {
27221
- return {
27222
- uBlocksize: gl.getUniformLocation(program, 'uBlocksize'),
27223
- uStepW: gl.getUniformLocation(program, 'uStepW'),
27224
- uStepH: gl.getUniformLocation(program, 'uStepH')
27225
- };
27226
- }
27227
-
27228
27039
  /**
27229
27040
  * Send data from this filter to its shader program's uniforms.
27230
27041
  *
@@ -27237,6 +27048,7 @@ class Pixelate extends BaseFilter {
27237
27048
  }
27238
27049
  _defineProperty(Pixelate, "type", 'Pixelate');
27239
27050
  _defineProperty(Pixelate, "defaults", pixelateDefaultValues);
27051
+ _defineProperty(Pixelate, "uniformLocations", ['uBlockSize']);
27240
27052
  classRegistry.setClass(Pixelate);
27241
27053
 
27242
27054
  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";
@@ -27286,19 +27098,6 @@ class RemoveColor extends BaseFilter {
27286
27098
  }
27287
27099
  }
27288
27100
 
27289
- /**
27290
- * Return WebGL uniform locations for this filter's shader.
27291
- *
27292
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27293
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27294
- */
27295
- getUniformLocations(gl, program) {
27296
- return {
27297
- uLow: gl.getUniformLocation(program, 'uLow'),
27298
- uHigh: gl.getUniformLocation(program, 'uHigh')
27299
- };
27300
- }
27301
-
27302
27101
  /**
27303
27102
  * Send data from this filter to its shader program's uniforms.
27304
27103
  *
@@ -27313,17 +27112,6 @@ class RemoveColor extends BaseFilter {
27313
27112
  gl.uniform4fv(uniformLocations.uLow, lowC);
27314
27113
  gl.uniform4fv(uniformLocations.uHigh, highC);
27315
27114
  }
27316
-
27317
- /**
27318
- * Returns object representation of an instance
27319
- * @return {Object} Object representation of an instance
27320
- */
27321
- toObject() {
27322
- return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
27323
- color: this.color,
27324
- distance: this.distance
27325
- });
27326
- }
27327
27115
  }
27328
27116
  /**
27329
27117
  * Color to remove, in any format understood by {@link Color}.
@@ -27340,14 +27128,14 @@ class RemoveColor extends BaseFilter {
27340
27128
  **/
27341
27129
  _defineProperty(RemoveColor, "type", 'RemoveColor');
27342
27130
  _defineProperty(RemoveColor, "defaults", removeColorDefaultValues);
27131
+ _defineProperty(RemoveColor, "uniformLocations", ['uLow', 'uHigh']);
27343
27132
  classRegistry.setClass(RemoveColor);
27344
27133
 
27345
27134
  const resizeDefaultValues = {
27346
27135
  resizeType: 'hermite',
27347
27136
  scaleX: 1,
27348
27137
  scaleY: 1,
27349
- lanczosLobes: 3,
27350
- fragmentSourceTOP: "\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n "
27138
+ lanczosLobes: 3
27351
27139
  };
27352
27140
  /**
27353
27141
  * Resize image filter class
@@ -27357,19 +27145,6 @@ const resizeDefaultValues = {
27357
27145
  * object.applyFilters(canvas.renderAll.bind(canvas));
27358
27146
  */
27359
27147
  class Resize extends BaseFilter {
27360
- /**
27361
- * Return WebGL uniform locations for this filter's shader.
27362
- *
27363
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27364
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27365
- */
27366
- getUniformLocations(gl, program) {
27367
- return {
27368
- uDelta: gl.getUniformLocation(program, 'uDelta'),
27369
- uTaps: gl.getUniformLocation(program, 'uTaps')
27370
- };
27371
- }
27372
-
27373
27148
  /**
27374
27149
  * Send data from this filter to its shader program's uniforms.
27375
27150
  *
@@ -27412,7 +27187,7 @@ class Resize extends BaseFilter {
27412
27187
  for (let i = 1; i <= filterWindow; i++) {
27413
27188
  offsets[i - 1] = "".concat(i, ".0 * uDelta");
27414
27189
  }
27415
- return "\n ".concat(this.fragmentSourceTOP, "\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 ");
27190
+ 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 ");
27416
27191
  }
27417
27192
  applyToForWebgl(options) {
27418
27193
  options.passes++;
@@ -27755,20 +27530,6 @@ class Resize extends BaseFilter {
27755
27530
  }
27756
27531
  return img2;
27757
27532
  }
27758
-
27759
- /**
27760
- * Returns object representation of an instance
27761
- * @return {Object} Object representation of an instance
27762
- */
27763
- toObject() {
27764
- return {
27765
- type: this.type,
27766
- scaleX: this.scaleX,
27767
- scaleY: this.scaleY,
27768
- resizeType: this.resizeType,
27769
- lanczosLobes: this.lanczosLobes
27770
- };
27771
- }
27772
27533
  }
27773
27534
  /**
27774
27535
  * Resize type
@@ -27793,10 +27554,15 @@ class Resize extends BaseFilter {
27793
27554
  */
27794
27555
  _defineProperty(Resize, "type", 'Resize');
27795
27556
  _defineProperty(Resize, "defaults", resizeDefaultValues);
27557
+ _defineProperty(Resize, "uniformLocations", ['uDelta', 'uTaps']);
27796
27558
  classRegistry.setClass(Resize);
27797
27559
 
27798
27560
  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";
27799
27561
 
27562
+ const saturationDefaultValues = {
27563
+ saturation: 0
27564
+ };
27565
+
27800
27566
  /**
27801
27567
  * Saturate filter class
27802
27568
  * @example
@@ -27806,11 +27572,6 @@ const fragmentSource$1 = "\n precision highp float;\n uniform sampler2D uTextu
27806
27572
  * object.filters.push(filter);
27807
27573
  * object.applyFilters();
27808
27574
  */
27809
-
27810
- const saturationDefaultValues = {
27811
- saturation: 0,
27812
- mainParameter: 'saturation'
27813
- };
27814
27575
  class Saturation extends BaseFilter {
27815
27576
  getFragmentSource() {
27816
27577
  return fragmentSource$1;
@@ -27828,9 +27589,6 @@ class Saturation extends BaseFilter {
27828
27589
  data
27829
27590
  }
27830
27591
  } = _ref;
27831
- if (this.saturation === 0) {
27832
- return;
27833
- }
27834
27592
  const adjust = -this.saturation;
27835
27593
  for (let i = 0; i < data.length; i += 4) {
27836
27594
  const max = Math.max(data[i], data[i + 1], data[i + 2]);
@@ -27840,18 +27598,6 @@ class Saturation extends BaseFilter {
27840
27598
  }
27841
27599
  }
27842
27600
 
27843
- /**
27844
- * Return WebGL uniform locations for this filter's shader.
27845
- *
27846
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27847
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27848
- */
27849
- getUniformLocations(gl, program) {
27850
- return {
27851
- uSaturation: gl.getUniformLocation(program, 'uSaturation')
27852
- };
27853
- }
27854
-
27855
27601
  /**
27856
27602
  * Send data from this filter to its shader program's uniforms.
27857
27603
  *
@@ -27861,6 +27607,9 @@ class Saturation extends BaseFilter {
27861
27607
  sendUniformData(gl, uniformLocations) {
27862
27608
  gl.uniform1f(uniformLocations.uSaturation, -this.saturation);
27863
27609
  }
27610
+ isNeutralState() {
27611
+ return this.saturation === 0;
27612
+ }
27864
27613
  }
27865
27614
  /**
27866
27615
  * Saturation value, from -1 to 1.
@@ -27872,13 +27621,13 @@ class Saturation extends BaseFilter {
27872
27621
  */
27873
27622
  _defineProperty(Saturation, "type", 'Saturation');
27874
27623
  _defineProperty(Saturation, "defaults", saturationDefaultValues);
27624
+ _defineProperty(Saturation, "uniformLocations", ['uSaturation']);
27875
27625
  classRegistry.setClass(Saturation);
27876
27626
 
27877
27627
  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";
27878
27628
 
27879
27629
  const vibranceDefaultValues = {
27880
- vibrance: 0,
27881
- mainParameter: 'vibrance'
27630
+ vibrance: 0
27882
27631
  };
27883
27632
 
27884
27633
  /**
@@ -27907,9 +27656,6 @@ class Vibrance extends BaseFilter {
27907
27656
  data
27908
27657
  }
27909
27658
  } = _ref;
27910
- if (this.vibrance === 0) {
27911
- return;
27912
- }
27913
27659
  const adjust = -this.vibrance;
27914
27660
  for (let i = 0; i < data.length; i += 4) {
27915
27661
  const max = Math.max(data[i], data[i + 1], data[i + 2]);
@@ -27921,27 +27667,18 @@ class Vibrance extends BaseFilter {
27921
27667
  }
27922
27668
  }
27923
27669
 
27924
- /**
27925
- * Return WebGL uniform locations for this filter's shader.
27926
- *
27927
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27928
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27929
- */
27930
- getUniformLocations(gl, program) {
27931
- return {
27932
- uVibrance: gl.getUniformLocation(program, 'uVibrance')
27933
- };
27934
- }
27935
-
27936
27670
  /**
27937
27671
  * Send data from this filter to its shader program's uniforms.
27938
27672
  *
27939
27673
  * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27940
- * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects
27674
+ * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects
27941
27675
  */
27942
27676
  sendUniformData(gl, uniformLocations) {
27943
27677
  gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);
27944
27678
  }
27679
+ isNeutralState() {
27680
+ return this.vibrance === 0;
27681
+ }
27945
27682
  }
27946
27683
  /**
27947
27684
  * Vibrance value, from -1 to 1.
@@ -27953,6 +27690,7 @@ class Vibrance extends BaseFilter {
27953
27690
  */
27954
27691
  _defineProperty(Vibrance, "type", 'Vibrance');
27955
27692
  _defineProperty(Vibrance, "defaults", vibranceDefaultValues);
27693
+ _defineProperty(Vibrance, "uniformLocations", ['uVibrance']);
27956
27694
  classRegistry.setClass(Vibrance);
27957
27695
 
27958
27696
  var filters = /*#__PURE__*/Object.freeze({