@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
@@ -475,7 +475,7 @@ class Cache {
475
475
  }
476
476
  const cache = new Cache();
477
477
 
478
- var version = "6.0.0-rc2.0";
478
+ var version = "6.0.0";
479
479
 
480
480
  // use this syntax so babel plugin see this import here
481
481
  const VERSION = version;
@@ -2423,6 +2423,7 @@ class Color {
2423
2423
  * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list
2424
2424
  */
2425
2425
  constructor(color) {
2426
+ _defineProperty(this, "isUnrecognised", false);
2426
2427
  if (!color) {
2427
2428
  // we default to black as canvas does
2428
2429
  this.setSource([0, 0, 0, 1]);
@@ -2448,7 +2449,7 @@ class Color {
2448
2449
  return color === 'transparent' ? [255, 255, 255, 0] : Color.sourceFromHex(color) || Color.sourceFromRgb(color) || Color.sourceFromHsl(color) ||
2449
2450
  // color is not recognized
2450
2451
  // we default to black as canvas does
2451
- [0, 0, 0, 1];
2452
+ (this.isUnrecognised = true) && [0, 0, 0, 1];
2452
2453
  }
2453
2454
 
2454
2455
  /**
@@ -3375,20 +3376,7 @@ let StaticCanvas$1 = class StaticCanvas extends createCollectionMixin(CommonMeth
3375
3376
  * @param {Array} vpt a Canvas 2D API transform matrix
3376
3377
  */
3377
3378
  setViewportTransform(vpt) {
3378
- const backgroundObject = this.backgroundImage,
3379
- overlayObject = this.overlayImage,
3380
- len = this._objects.length;
3381
3379
  this.viewportTransform = vpt;
3382
- for (let i = 0; i < len; i++) {
3383
- const object = this._objects[i];
3384
- object.group || object.setCoords();
3385
- }
3386
- if (backgroundObject) {
3387
- backgroundObject.setCoords();
3388
- }
3389
- if (overlayObject) {
3390
- overlayObject.setCoords();
3391
- }
3392
3380
  this.calcViewportBoundaries();
3393
3381
  this.renderOnAddRemove && this.requestRenderAll();
3394
3382
  }
@@ -4440,7 +4428,7 @@ const makeBoundingBoxFromPoints = points => {
4440
4428
  };
4441
4429
  };
4442
4430
 
4443
- const _excluded$m = ["translateX", "translateY", "scaleX", "scaleY"];
4431
+ const _excluded$i = ["translateX", "translateY", "scaleX", "scaleY"];
4444
4432
 
4445
4433
  /**
4446
4434
  * given an object and a transform, apply the inverse transform to the object,
@@ -4482,7 +4470,7 @@ const applyTransformToObject = (object, transform) => {
4482
4470
  scaleX,
4483
4471
  scaleY
4484
4472
  } = _qrDecompose,
4485
- otherOptions = _objectWithoutProperties(_qrDecompose, _excluded$m),
4473
+ otherOptions = _objectWithoutProperties(_qrDecompose, _excluded$i),
4486
4474
  center = new Point(translateX, translateY);
4487
4475
  object.flipX = false;
4488
4476
  object.flipY = false;
@@ -5397,14 +5385,14 @@ class AnimationBase {
5397
5385
  }
5398
5386
  }
5399
5387
 
5400
- const _excluded$l = ["startValue", "endValue"];
5388
+ const _excluded$h = ["startValue", "endValue"];
5401
5389
  class ValueAnimation extends AnimationBase {
5402
5390
  constructor(_ref) {
5403
5391
  let {
5404
5392
  startValue = 0,
5405
5393
  endValue = 100
5406
5394
  } = _ref,
5407
- otherOptions = _objectWithoutProperties(_ref, _excluded$l);
5395
+ otherOptions = _objectWithoutProperties(_ref, _excluded$h);
5408
5396
  super(_objectSpread2(_objectSpread2({}, otherOptions), {}, {
5409
5397
  startValue,
5410
5398
  byValue: endValue - startValue
@@ -5419,14 +5407,14 @@ class ValueAnimation extends AnimationBase {
5419
5407
  }
5420
5408
  }
5421
5409
 
5422
- const _excluded$k = ["startValue", "endValue"];
5410
+ const _excluded$g = ["startValue", "endValue"];
5423
5411
  class ArrayAnimation extends AnimationBase {
5424
5412
  constructor(_ref) {
5425
5413
  let {
5426
5414
  startValue = [0],
5427
5415
  endValue = [100]
5428
5416
  } = _ref,
5429
- options = _objectWithoutProperties(_ref, _excluded$k);
5417
+ options = _objectWithoutProperties(_ref, _excluded$g);
5430
5418
  super(_objectSpread2(_objectSpread2({}, options), {}, {
5431
5419
  startValue,
5432
5420
  byValue: endValue.map((value, i) => value - startValue[i])
@@ -5443,7 +5431,7 @@ class ArrayAnimation extends AnimationBase {
5443
5431
 
5444
5432
  const capValue = (min, value, max) => Math.max(min, Math.min(value, max));
5445
5433
 
5446
- const _excluded$j = ["startValue", "endValue", "easing", "onChange", "onComplete", "abort"];
5434
+ const _excluded$f = ["startValue", "endValue", "easing", "onChange", "onComplete", "abort"];
5447
5435
  const defaultColorEasing = (timeElapsed, startValue, byValue, duration) => {
5448
5436
  const durationProgress = 1 - Math.cos(timeElapsed / duration * halfPI);
5449
5437
  return startValue + byValue * durationProgress;
@@ -5459,7 +5447,7 @@ class ColorAnimation extends AnimationBase {
5459
5447
  onComplete,
5460
5448
  abort
5461
5449
  } = _ref,
5462
- options = _objectWithoutProperties(_ref, _excluded$j);
5450
+ options = _objectWithoutProperties(_ref, _excluded$f);
5463
5451
  const startColor = new Color(startValue).getSource();
5464
5452
  const endColor = new Color(endValue).getSource();
5465
5453
  super(_objectSpread2(_objectSpread2({}, options), {}, {
@@ -6500,10 +6488,6 @@ class ObjectGeometry extends ObjectOrigin {
6500
6488
  }
6501
6489
  }
6502
6490
 
6503
- /**
6504
- * Strict: only ancestors that are objects (without canvas)
6505
- */
6506
-
6507
6491
  class StackedObject extends ObjectGeometry {
6508
6492
  /**
6509
6493
  * A reference to the parent of the object
@@ -6527,17 +6511,14 @@ class StackedObject extends ObjectGeometry {
6527
6511
  }
6528
6512
 
6529
6513
  /**
6530
- *
6531
- * @param {boolean} [strict] returns only ancestors that are objects (without canvas)
6532
6514
  * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top
6533
6515
  */
6534
- getAncestors(strict) {
6516
+ getAncestors() {
6535
6517
  const ancestors = [];
6536
6518
  // eslint-disable-next-line @typescript-eslint/no-this-alias
6537
6519
  let parent = this;
6538
6520
  do {
6539
- var _parent$parent;
6540
- parent = parent instanceof StackedObject ? (_parent$parent = parent.parent) !== null && _parent$parent !== void 0 ? _parent$parent : !strict ? parent.canvas : undefined : undefined;
6521
+ parent = parent instanceof StackedObject ? parent.parent : undefined;
6541
6522
  parent && ancestors.push(parent);
6542
6523
  } while (parent);
6543
6524
  return ancestors;
@@ -6547,19 +6528,18 @@ class StackedObject extends ObjectGeometry {
6547
6528
  * Compare ancestors
6548
6529
  *
6549
6530
  * @param {StackedObject} other
6550
- * @param {boolean} [strict] finds only ancestors that are objects (without canvas)
6551
6531
  * @returns {AncestryComparison} an object that represent the ancestry situation.
6552
6532
  */
6553
- findCommonAncestors(other, strict) {
6533
+ findCommonAncestors(other) {
6554
6534
  if (this === other) {
6555
6535
  return {
6556
6536
  fork: [],
6557
6537
  otherFork: [],
6558
- common: [this, ...this.getAncestors(strict)]
6538
+ common: [this, ...this.getAncestors()]
6559
6539
  };
6560
6540
  }
6561
- const ancestors = this.getAncestors(strict);
6562
- const otherAncestors = other.getAncestors(strict);
6541
+ const ancestors = this.getAncestors();
6542
+ const otherAncestors = other.getAncestors();
6563
6543
  // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case
6564
6544
  if (ancestors.length === 0 && otherAncestors.length > 0 && this === otherAncestors[otherAncestors.length - 1]) {
6565
6545
  return {
@@ -6606,11 +6586,10 @@ class StackedObject extends ObjectGeometry {
6606
6586
  /**
6607
6587
  *
6608
6588
  * @param {StackedObject} other
6609
- * @param {boolean} [strict] checks only ancestors that are objects (without canvas)
6610
6589
  * @returns {boolean}
6611
6590
  */
6612
- hasCommonAncestors(other, strict) {
6613
- const commonAncestors = this.findCommonAncestors(other, strict);
6591
+ hasCommonAncestors(other) {
6592
+ const commonAncestors = this.findCommonAncestors(other);
6614
6593
  return commonAncestors && !!commonAncestors.common.length;
6615
6594
  }
6616
6595
 
@@ -6624,16 +6603,15 @@ class StackedObject extends ObjectGeometry {
6624
6603
  return undefined;
6625
6604
  }
6626
6605
  const ancestorData = this.findCommonAncestors(other);
6627
- if (!ancestorData) {
6628
- return undefined;
6629
- }
6630
6606
  if (ancestorData.fork.includes(other)) {
6631
6607
  return true;
6632
6608
  }
6633
6609
  if (ancestorData.otherFork.includes(this)) {
6634
6610
  return false;
6635
6611
  }
6636
- const firstCommonAncestor = ancestorData.common[0];
6612
+ // if there isn't a common ancestor, we take the canvas.
6613
+ // if there is no canvas, there is nothing to compare
6614
+ const firstCommonAncestor = ancestorData.common[0] || this.canvas;
6637
6615
  if (!firstCommonAncestor) {
6638
6616
  return undefined;
6639
6617
  }
@@ -7006,7 +6984,7 @@ const interactiveObjectDefaultValues = {
7006
6984
  moveCursor: null
7007
6985
  };
7008
6986
 
7009
- const _excluded$i = ["type"],
6987
+ const _excluded$e = ["type"],
7010
6988
  _excluded2$4 = ["extraParam"];
7011
6989
  /**
7012
6990
  * Root object class from which all 2d shape classes inherit from
@@ -7194,7 +7172,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7194
7172
  height = dims.height,
7195
7173
  zoomX = dims.zoomX,
7196
7174
  zoomY = dims.zoomY,
7197
- dimensionsChanged = width !== this.cacheWidth || height !== this.cacheHeight,
7175
+ dimensionsChanged = width !== canvas.width || height !== canvas.height,
7198
7176
  zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;
7199
7177
  if (!canvas || !context) {
7200
7178
  return false;
@@ -7235,8 +7213,6 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7235
7213
  drawingHeight = dims.y / 2;
7236
7214
  this.cacheTranslationX = Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;
7237
7215
  this.cacheTranslationY = Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;
7238
- this.cacheWidth = width;
7239
- this.cacheHeight = height;
7240
7216
  context.translate(this.cacheTranslationX, this.cacheTranslationY);
7241
7217
  context.scale(zoomX, zoomY);
7242
7218
  this.zoomX = zoomX;
@@ -7511,8 +7487,6 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7511
7487
  _removeCacheCanvas() {
7512
7488
  this._cacheCanvas = undefined;
7513
7489
  this._cacheContext = null;
7514
- this.cacheWidth = 0;
7515
- this.cacheHeight = 0;
7516
7490
  }
7517
7491
 
7518
7492
  /**
@@ -7671,15 +7645,18 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7671
7645
  if (this.isNotVisible()) {
7672
7646
  return false;
7673
7647
  }
7674
- if (this._cacheCanvas && this._cacheContext && !skipCanvas && this._updateCacheCanvas()) {
7648
+ const canvas = this._cacheCanvas;
7649
+ const ctx = this._cacheContext;
7650
+ if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {
7675
7651
  // in this case the context is already cleared.
7676
7652
  return true;
7677
7653
  } else {
7678
7654
  if (this.dirty || this.clipPath && this.clipPath.absolutePositioned) {
7679
- if (this._cacheCanvas && this._cacheContext && !skipCanvas) {
7680
- const width = this.cacheWidth / this.zoomX;
7681
- const height = this.cacheHeight / this.zoomY;
7682
- this._cacheContext.clearRect(-width / 2, -height / 2, width, height);
7655
+ if (canvas && ctx && !skipCanvas) {
7656
+ ctx.save();
7657
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
7658
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
7659
+ ctx.restore();
7683
7660
  }
7684
7661
  return true;
7685
7662
  }
@@ -8203,7 +8180,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
8203
8180
  * @returns {Promise<FabricObject>}
8204
8181
  */
8205
8182
  static _fromObject(_ref2) {
8206
- let object = _objectWithoutProperties(_ref2, _excluded$i);
8183
+ let object = _objectWithoutProperties(_ref2, _excluded$e);
8207
8184
  let _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
8208
8185
  {
8209
8186
  extraParam
@@ -8954,7 +8931,7 @@ const scalingEqually = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObj
8954
8931
  const scalingX = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectX));
8955
8932
  const scalingY = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectY));
8956
8933
 
8957
- const _excluded$h = ["target", "ex", "ey", "skewingSide"];
8934
+ const _excluded$d = ["target", "ex", "ey", "skewingSide"];
8958
8935
  const AXIS_KEYS = {
8959
8936
  x: {
8960
8937
  counterAxis: 'y',
@@ -9004,7 +8981,7 @@ function skewObject(axis, _ref, pointer) {
9004
8981
  ey,
9005
8982
  skewingSide
9006
8983
  } = _ref,
9007
- transform = _objectWithoutProperties(_ref, _excluded$h);
8984
+ transform = _objectWithoutProperties(_ref, _excluded$d);
9008
8985
  const {
9009
8986
  skew: skewKey
9010
8987
  } = AXIS_KEYS[axis],
@@ -9590,6 +9567,9 @@ class InteractiveFabricObject extends FabricObject$1 {
9590
9567
  * Draws corners of an object's bounding box.
9591
9568
  * Requires public properties: width, height
9592
9569
  * Requires public options: cornerSize, padding
9570
+ * Be aware that since fabric 6.0 this function does not call setCoords anymore.
9571
+ * setCoords needs to be called manually if the object of which we are rendering controls
9572
+ * is outside the standard selection and transform process.
9593
9573
  * @param {CanvasRenderingContext2D} ctx Context to draw on
9594
9574
  * @param {ControlRenderingStyleOverride} styleOverride object to override the object style
9595
9575
  */
@@ -9613,7 +9593,6 @@ class InteractiveFabricObject extends FabricObject$1 {
9613
9593
  ctx.strokeStyle = options.cornerStrokeColor;
9614
9594
  }
9615
9595
  this._setLineDash(ctx, options.cornerDashArray);
9616
- this.setCoords();
9617
9596
  this.forEachControl((control, key) => {
9618
9597
  if (control.getVisibility(this, key)) {
9619
9598
  const p = this.oCoords[key];
@@ -10846,7 +10825,7 @@ function parseAttributes(element, attributes, cssRules) {
10846
10825
  return svgValidParentsRegEx.test(element.nodeName) ? mergedAttrs : setStrokeFillOpacity(mergedAttrs);
10847
10826
  }
10848
10827
 
10849
- const _excluded$g = ["left", "top", "width", "height", "visible"];
10828
+ const _excluded$c = ["left", "top", "width", "height", "visible"];
10850
10829
  const rectDefaultValues = {
10851
10830
  rx: 0,
10852
10831
  ry: 0
@@ -10960,7 +10939,7 @@ class Rect extends FabricObject {
10960
10939
  height = 0,
10961
10940
  visible = true
10962
10941
  } = _parseAttributes,
10963
- restOfparsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$g);
10942
+ restOfparsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$c);
10964
10943
  return new this(_objectSpread2(_objectSpread2(_objectSpread2({}, options), restOfparsedAttributes), {}, {
10965
10944
  left,
10966
10945
  top,
@@ -11116,7 +11095,7 @@ class FitContentLayout extends LayoutStrategy {
11116
11095
  _defineProperty(FitContentLayout, "type", 'fit-content');
11117
11096
  classRegistry.setClass(FitContentLayout);
11118
11097
 
11119
- const _excluded$f = ["strategy"],
11098
+ const _excluded$b = ["strategy"],
11120
11099
  _excluded2$3 = ["target", "strategy", "bubbles", "prevStrategy"];
11121
11100
  const LAYOUT_MANAGER = 'layoutManager';
11122
11101
  class LayoutManager {
@@ -11219,7 +11198,7 @@ class LayoutManager {
11219
11198
  context
11220
11199
  });
11221
11200
  if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {
11222
- const tricklingContext = _objectWithoutProperties(context, _excluded$f);
11201
+ const tricklingContext = _objectWithoutProperties(context, _excluded$b);
11223
11202
  // traverse the tree
11224
11203
  target.forEachObject(object => object.layoutManager && object.layoutManager.performLayout(_objectSpread2(_objectSpread2({}, tricklingContext), {}, {
11225
11204
  bubbles: false,
@@ -11363,7 +11342,7 @@ class LayoutManager {
11363
11342
  }
11364
11343
  classRegistry.setClass(LayoutManager, LAYOUT_MANAGER);
11365
11344
 
11366
- const _excluded$e = ["type", "objects", "layoutManager"];
11345
+ const _excluded$a = ["type", "objects", "layoutManager"];
11367
11346
  /**
11368
11347
  * 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.
11369
11348
  * We could have used a boolean in the constructor, as we did previously, but we think the boolean
@@ -11430,6 +11409,15 @@ class Group extends createCollectionMixin(FabricObject) {
11430
11409
  _defineProperty(this, "__objectSelectionDisposer", void 0);
11431
11410
  Object.assign(this, Group.ownDefaults);
11432
11411
  this.setOptions(options);
11412
+ this.groupInit(objects, options);
11413
+ }
11414
+
11415
+ /**
11416
+ * Shared code between group and active selection
11417
+ * Meant to be used by the constructor.
11418
+ */
11419
+ groupInit(objects, options) {
11420
+ var _options$layoutManage;
11433
11421
  this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller
11434
11422
 
11435
11423
  this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(this, true);
@@ -11439,7 +11427,7 @@ class Group extends createCollectionMixin(FabricObject) {
11439
11427
  });
11440
11428
 
11441
11429
  // perform initial layout
11442
- this.layoutManager = options.layoutManager || new LayoutManager();
11430
+ this.layoutManager = (_options$layoutManage = options.layoutManager) !== null && _options$layoutManage !== void 0 ? _options$layoutManage : new LayoutManager();
11443
11431
  this.layoutManager.performLayout({
11444
11432
  type: LAYOUT_TYPE_INITIALIZATION,
11445
11433
  target: this,
@@ -11911,7 +11899,7 @@ class Group extends createCollectionMixin(FabricObject) {
11911
11899
  objects = [],
11912
11900
  layoutManager
11913
11901
  } = _ref2,
11914
- options = _objectWithoutProperties(_ref2, _excluded$e);
11902
+ options = _objectWithoutProperties(_ref2, _excluded$a);
11915
11903
  return Promise.all([enlivenObjects(objects, abortable), enlivenObjectEnlivables(options, abortable)]).then(_ref3 => {
11916
11904
  let [objects, hydratedOptions] = _ref3;
11917
11905
  const group = new this(objects, _objectSpread2(_objectSpread2(_objectSpread2({}, options), hydratedOptions), {}, {
@@ -14067,8 +14055,8 @@ class SelectableCanvas extends StaticCanvas$1 {
14067
14055
  this._activeObject = object;
14068
14056
  if (isActiveSelection(object) && prevActiveObject !== object) {
14069
14057
  object.set('canvas', this);
14070
- object.setCoords();
14071
14058
  }
14059
+ object.setCoords();
14072
14060
  return true;
14073
14061
  }
14074
14062
 
@@ -14321,7 +14309,7 @@ class TextEditingManager {
14321
14309
  }
14322
14310
  }
14323
14311
 
14324
- const _excluded$d = ["target", "oldTarget", "fireCanvas", "e"];
14312
+ const _excluded$9 = ["target", "oldTarget", "fireCanvas", "e"];
14325
14313
  const addEventOptions = {
14326
14314
  passive: false
14327
14315
  };
@@ -15335,7 +15323,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15335
15323
  fireCanvas,
15336
15324
  e
15337
15325
  } = _ref,
15338
- data = _objectWithoutProperties(_ref, _excluded$d);
15326
+ data = _objectWithoutProperties(_ref, _excluded$9);
15339
15327
  const {
15340
15328
  targetIn,
15341
15329
  targetOut,
@@ -15394,16 +15382,15 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15394
15382
  * @private
15395
15383
  */
15396
15384
  _performTransformAction(e, transform, pointer) {
15397
- const x = pointer.x,
15398
- y = pointer.y,
15399
- action = transform.action,
15400
- actionHandler = transform.actionHandler;
15401
- let actionPerformed = false;
15402
- // this object could be created from the function in the control handlers
15385
+ const {
15386
+ action,
15387
+ actionHandler,
15388
+ target
15389
+ } = transform;
15390
+ const actionPerformed = !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);
15391
+ actionPerformed && target.setCoords();
15403
15392
 
15404
- if (actionHandler) {
15405
- actionPerformed = actionHandler(e, transform, x, y);
15406
- }
15393
+ // this object could be created from the function in the control handlers
15407
15394
  if (action === 'drag' && actionPerformed) {
15408
15395
  transform.target.isMoving = true;
15409
15396
  this.setCursor(transform.target.moveCursor || this.moveCursor);
@@ -16030,7 +16017,7 @@ classRegistry.setClass(Gradient, 'gradient');
16030
16017
  classRegistry.setClass(Gradient, 'linear');
16031
16018
  classRegistry.setClass(Gradient, 'radial');
16032
16019
 
16033
- const _excluded$c = ["type", "source"];
16020
+ const _excluded$8 = ["type", "source"];
16034
16021
 
16035
16022
  /**
16036
16023
  * @see {@link http://fabricjs.com/patterns demo}
@@ -16188,7 +16175,7 @@ class Pattern {
16188
16175
  type,
16189
16176
  source
16190
16177
  } = _ref2,
16191
- serialized = _objectWithoutProperties(_ref2, _excluded$c);
16178
+ serialized = _objectWithoutProperties(_ref2, _excluded$8);
16192
16179
  const img = await loadImage(source, _objectSpread2(_objectSpread2({}, options), {}, {
16193
16180
  crossOrigin: serialized.crossOrigin
16194
16181
  }));
@@ -16335,7 +16322,7 @@ class BaseBrush {
16335
16322
  }
16336
16323
  }
16337
16324
 
16338
- const _excluded$b = ["path", "left", "top"],
16325
+ const _excluded$7 = ["path", "left", "top"],
16339
16326
  _excluded2$2 = ["d"];
16340
16327
  class Path extends FabricObject {
16341
16328
  /**
@@ -16351,7 +16338,7 @@ class Path extends FabricObject {
16351
16338
  left,
16352
16339
  top
16353
16340
  } = _ref,
16354
- options = _objectWithoutProperties(_ref, _excluded$b);
16341
+ options = _objectWithoutProperties(_ref, _excluded$7);
16355
16342
  super();
16356
16343
  Object.assign(this, Path.ownDefaults);
16357
16344
  this.setOptions(options);
@@ -16487,7 +16474,7 @@ class Path extends FabricObject {
16487
16474
  toClipPathSVG(reviver) {
16488
16475
  const additionalTransform = this._getOffsetTransform();
16489
16476
  return '\t' + this._createBaseClipPathSVGMarkup(this._toSVG(), {
16490
- reviver: reviver,
16477
+ reviver,
16491
16478
  additionalTransform: additionalTransform
16492
16479
  });
16493
16480
  }
@@ -16500,7 +16487,7 @@ class Path extends FabricObject {
16500
16487
  toSVG(reviver) {
16501
16488
  const additionalTransform = this._getOffsetTransform();
16502
16489
  return this._createBaseSVGMarkup(this._toSVG(), {
16503
- reviver: reviver,
16490
+ reviver,
16504
16491
  additionalTransform: additionalTransform
16505
16492
  });
16506
16493
  }
@@ -16923,7 +16910,7 @@ class PencilBrush extends BaseBrush {
16923
16910
  }
16924
16911
  }
16925
16912
 
16926
- const _excluded$a = ["left", "top", "radius"];
16913
+ const _excluded$6 = ["left", "top", "radius"];
16927
16914
  const CIRCLE_PROPS = ['radius', 'startAngle', 'endAngle', 'counterClockwise'];
16928
16915
  const circleDefaultValues = {
16929
16916
  radius: 0,
@@ -17057,7 +17044,7 @@ class Circle extends FabricObject {
17057
17044
  top = 0,
17058
17045
  radius = 0
17059
17046
  } = _ref,
17060
- otherParsedAttributes = _objectWithoutProperties(_ref, _excluded$a);
17047
+ otherParsedAttributes = _objectWithoutProperties(_ref, _excluded$6);
17061
17048
 
17062
17049
  // this probably requires to be fixed for default origins not being top/left.
17063
17050
 
@@ -17440,7 +17427,7 @@ class PatternBrush extends PencilBrush {
17440
17427
  }
17441
17428
  }
17442
17429
 
17443
- const _excluded$9 = ["x1", "y1", "x2", "y2"],
17430
+ const _excluded$5 = ["x1", "y1", "x2", "y2"],
17444
17431
  _excluded2$1 = ["x1", "y1", "x2", "y2"];
17445
17432
  // @TODO this code is terrible and Line should be a special case of polyline.
17446
17433
 
@@ -17652,7 +17639,7 @@ class Line extends FabricObject {
17652
17639
  x2 = 0,
17653
17640
  y2 = 0
17654
17641
  } = _parseAttributes,
17655
- parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$9);
17642
+ parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$5);
17656
17643
  return new this([x1, y1, x2, y2], parsedAttributes);
17657
17644
  }
17658
17645
 
@@ -17918,7 +17905,7 @@ function parsePointsAttribute(points) {
17918
17905
  return parsedPoints;
17919
17906
  }
17920
17907
 
17921
- const _excluded$8 = ["left", "top"];
17908
+ const _excluded$4 = ["left", "top"];
17922
17909
  const polylineDefaultValues = {
17923
17910
  /**
17924
17911
  * @deprecated transient option soon to be removed in favor of a different design
@@ -18201,7 +18188,7 @@ class Polyline extends FabricObject {
18201
18188
  static async fromElement(element, options, cssRules) {
18202
18189
  const points = parsePointsAttribute(element.getAttribute('points')),
18203
18190
  _parseAttributes = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules),
18204
- parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$8);
18191
+ parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$4);
18205
18192
  return new this(points, _objectSpread2(_objectSpread2({}, parsedAttributes), options));
18206
18193
  }
18207
18194
 
@@ -18793,7 +18780,7 @@ class TextSVGExportMixin extends FabricObjectSVGExportMixin {
18793
18780
  }
18794
18781
  }
18795
18782
 
18796
- const _excluded$7 = ["textAnchor", "textDecoration", "dx", "dy", "top", "left", "fontSize", "strokeWidth"];
18783
+ const _excluded$3 = ["textAnchor", "textDecoration", "dx", "dy", "top", "left", "fontSize", "strokeWidth"];
18797
18784
  let measuringContext;
18798
18785
 
18799
18786
  /**
@@ -19997,7 +19984,7 @@ class FabricText extends StyledText {
19997
19984
  fontSize = DEFAULT_SVG_FONT_SIZE,
19998
19985
  strokeWidth = 1
19999
19986
  } = _options$parsedAttrib,
20000
- restOfOptions = _objectWithoutProperties(_options$parsedAttrib, _excluded$7);
19987
+ restOfOptions = _objectWithoutProperties(_options$parsedAttrib, _excluded$3);
20001
19988
  const textContent = (element.textContent || '').replace(/^\s+|\s+$|\n+/g, '').replace(/\s+/g, ' ');
20002
19989
 
20003
19990
  // this code here is probably the usual issue for SVG center find
@@ -23364,7 +23351,6 @@ class ActiveSelectionLayoutManager extends LayoutManager {
23364
23351
  }
23365
23352
  }
23366
23353
 
23367
- const _excluded$6 = ["layoutManager"];
23368
23354
  const activeSelectionDefaultValues = {
23369
23355
  multiSelectionStacking: 'canvas-stacking'
23370
23356
  };
@@ -23400,16 +23386,20 @@ class ActiveSelection extends Group {
23400
23386
 
23401
23387
  constructor() {
23402
23388
  let objects = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
23403
- let _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
23404
- {
23405
- layoutManager
23406
- } = _ref,
23407
- options = _objectWithoutProperties(_ref, _excluded$6);
23408
- super(objects, {
23409
- layoutManager: layoutManager !== null && layoutManager !== void 0 ? layoutManager : new ActiveSelectionLayoutManager()
23410
- });
23389
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
23390
+ super();
23411
23391
  Object.assign(this, ActiveSelection.ownDefaults);
23412
23392
  this.setOptions(options);
23393
+ const {
23394
+ left,
23395
+ top,
23396
+ layoutManager
23397
+ } = options;
23398
+ this.groupInit(objects, {
23399
+ left,
23400
+ top,
23401
+ layoutManager: layoutManager !== null && layoutManager !== void 0 ? layoutManager : new ActiveSelectionLayoutManager()
23402
+ });
23413
23403
  }
23414
23404
 
23415
23405
  /**
@@ -23989,7 +23979,7 @@ function setFilterBackend(backend) {
23989
23979
  filterBackend = backend;
23990
23980
  }
23991
23981
 
23992
- const _excluded$5 = ["filters", "resizeFilter", "src", "crossOrigin", "type"];
23982
+ const _excluded$2 = ["filters", "resizeFilter", "src", "crossOrigin", "type"];
23993
23983
 
23994
23984
  // @todo Would be nice to have filtering code not imported directly.
23995
23985
 
@@ -24572,7 +24562,7 @@ class FabricImage extends FabricObject {
24572
24562
  crossOrigin,
24573
24563
  type
24574
24564
  } = _ref,
24575
- object = _objectWithoutProperties(_ref, _excluded$5);
24565
+ object = _objectWithoutProperties(_ref, _excluded$2);
24576
24566
  return Promise.all([loadImage(src, _objectSpread2(_objectSpread2({}, options), {}, {
24577
24567
  crossOrigin
24578
24568
  })), f && enlivenObjects(f, options),
@@ -25342,9 +25332,9 @@ const isPutImageFaster = (width, height) => {
25342
25332
 
25343
25333
  const highPsourceCode = "precision highp float";
25344
25334
  const identityFragmentShader = "\n ".concat(highPsourceCode, ";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }");
25345
- 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 }";
25335
+ 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 }";
25346
25336
 
25347
- const _excluded$4 = ["type"],
25337
+ const _excluded$1 = ["type"],
25348
25338
  _excluded2 = ["type"];
25349
25339
  const regex = new RegExp(highPsourceCode, 'g');
25350
25340
  class BaseFilter {
@@ -25365,30 +25355,21 @@ class BaseFilter {
25365
25355
  * to avoid doing that.
25366
25356
  */
25367
25357
 
25368
- /**
25369
- * Name of the parameter that can be changed in the filter.
25370
- * Some filters have more than one parameter and there is no
25371
- * mainParameter
25372
- * @private
25373
- */
25374
-
25375
25358
  /**
25376
25359
  * Constructor
25377
25360
  * @param {Object} [options] Options object
25378
25361
  */
25379
25362
  constructor() {
25380
25363
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
25381
- options = _objectWithoutProperties(_ref, _excluded$4);
25382
- /**
25383
- * Array of attributes to send with buffers. do not modify
25384
- * @private
25385
- */
25386
- _defineProperty(this, "vertexSource", vertexSource);
25364
+ options = _objectWithoutProperties(_ref, _excluded$1);
25387
25365
  Object.assign(this, this.constructor.defaults, options);
25388
25366
  }
25389
25367
  getFragmentSource() {
25390
25368
  return identityFragmentShader;
25391
25369
  }
25370
+ getVertexSource() {
25371
+ return vertexSource$1;
25372
+ }
25392
25373
 
25393
25374
  /**
25394
25375
  * Compile this filter's shader program.
@@ -25399,7 +25380,7 @@ class BaseFilter {
25399
25380
  */
25400
25381
  createProgram(gl) {
25401
25382
  let fragmentSource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFragmentSource();
25402
- let vertexSource = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.vertexSource;
25383
+ let vertexSource = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getVertexSource();
25403
25384
  const {
25404
25385
  WebGLProbe: {
25405
25386
  GLPrecision = 'highp'
@@ -25456,14 +25437,17 @@ class BaseFilter {
25456
25437
  /**
25457
25438
  * Return a map of uniform names to WebGLUniformLocation objects.
25458
25439
  *
25459
- * Intended to be overridden by subclasses.
25460
- *
25461
25440
  * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.
25462
25441
  * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.
25463
25442
  * @returns {Object} A map of uniform names to uniform locations.
25464
25443
  */
25465
25444
  getUniformLocations(gl, program) {
25466
- return {};
25445
+ const locations = this.constructor.uniformLocations;
25446
+ const uniformLocations = {};
25447
+ for (let i = 0; i < locations.length; i++) {
25448
+ uniformLocations[locations[i]] = gl.getUniformLocation(program, locations[i]);
25449
+ }
25450
+ return uniformLocations;
25467
25451
  }
25468
25452
 
25469
25453
  /**
@@ -25513,18 +25497,7 @@ class BaseFilter {
25513
25497
  **/
25514
25498
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
25515
25499
  isNeutralState(options) {
25516
- const main = this.mainParameter,
25517
- defaultValue = this.constructor.defaults[main];
25518
- if (main) {
25519
- const thisValue = this[main];
25520
- if (Array.isArray(defaultValue) && Array.isArray(thisValue)) {
25521
- return defaultValue.every((value, i) => value === thisValue[i]);
25522
- } else {
25523
- return defaultValue === thisValue;
25524
- }
25525
- } else {
25526
- return false;
25527
- }
25500
+ return false;
25528
25501
  }
25529
25502
 
25530
25503
  /**
@@ -25616,14 +25589,6 @@ class BaseFilter {
25616
25589
  gl.bindTexture(gl.TEXTURE_2D, null);
25617
25590
  gl.activeTexture(gl.TEXTURE0);
25618
25591
  }
25619
- getMainParameter() {
25620
- return this.mainParameter ? this[this.mainParameter] : undefined;
25621
- }
25622
- setMainParameter(value) {
25623
- if (this.mainParameter) {
25624
- this[this.mainParameter] = value;
25625
- }
25626
- }
25627
25592
 
25628
25593
  /**
25629
25594
  * Send uniform data from this filter to its shader program on the GPU.
@@ -25655,12 +25620,14 @@ class BaseFilter {
25655
25620
  * @return {Object} Object representation of an instance
25656
25621
  */
25657
25622
  toObject() {
25658
- const mainP = this.mainParameter;
25623
+ const defaultKeys = Object.keys(this.constructor.defaults);
25659
25624
  return _objectSpread2({
25660
25625
  type: this.type
25661
- }, mainP ? {
25662
- [mainP]: this[mainP]
25663
- } : {});
25626
+ }, defaultKeys.reduce((acc, key) => {
25627
+ //@ts-expect-error TS doesn't get i want an object that looks like this
25628
+ acc[key] = this[key];
25629
+ return acc;
25630
+ }, {}));
25664
25631
  }
25665
25632
 
25666
25633
  /**
@@ -25677,6 +25644,12 @@ class BaseFilter {
25677
25644
  }
25678
25645
  }
25679
25646
  _defineProperty(BaseFilter, "type", 'BaseFilter');
25647
+ /**
25648
+ * Contains the uniform locations for the fragment shader.
25649
+ * uStepW and uStepH are handled by the BaseFilter, each filter class
25650
+ * needs to specify all the one that are needed
25651
+ */
25652
+ _defineProperty(BaseFilter, "uniformLocations", []);
25680
25653
 
25681
25654
  const blendColorFragmentSource = {
25682
25655
  multiply: 'gl_FragColor.rgb *= uColor.rgb;\n',
@@ -25796,18 +25769,6 @@ class BlendColor extends BaseFilter {
25796
25769
  }
25797
25770
  }
25798
25771
 
25799
- /**
25800
- * Return WebGL uniform locations for this filter's shader.
25801
- *
25802
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
25803
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
25804
- */
25805
- getUniformLocations(gl, program) {
25806
- return {
25807
- uColor: gl.getUniformLocation(program, 'uColor')
25808
- };
25809
- }
25810
-
25811
25772
  /**
25812
25773
  * Send data from this filter to its shader program's uniforms.
25813
25774
  *
@@ -25822,19 +25783,6 @@ class BlendColor extends BaseFilter {
25822
25783
  source[3] = this.alpha;
25823
25784
  gl.uniform4fv(uniformLocations.uColor, source);
25824
25785
  }
25825
-
25826
- /**
25827
- * Returns object representation of an instance
25828
- * @return {Object} Object representation of an instance
25829
- */
25830
- toObject() {
25831
- return {
25832
- type: this.type,
25833
- color: this.color,
25834
- mode: this.mode,
25835
- alpha: this.alpha
25836
- };
25837
- }
25838
25786
  }
25839
25787
  /**
25840
25788
  * Color to make the blend operation with. default to a reddish color since black or white
@@ -25855,18 +25803,19 @@ class BlendColor extends BaseFilter {
25855
25803
  **/
25856
25804
  _defineProperty(BlendColor, "defaults", blendColorDefaultValues);
25857
25805
  _defineProperty(BlendColor, "type", 'BlendColor');
25806
+ _defineProperty(BlendColor, "uniformLocations", ['uColor']);
25858
25807
  classRegistry.setClass(BlendColor);
25859
25808
 
25860
25809
  const fragmentSource$c = {
25861
25810
  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 ",
25862
25811
  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 "
25863
25812
  };
25813
+ 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 ";
25864
25814
 
25865
- const _excluded$3 = ["type", "image"];
25815
+ const _excluded = ["type", "image"];
25866
25816
  const blendImageDefaultValues = {
25867
25817
  mode: 'multiply',
25868
- alpha: 1,
25869
- 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 "
25818
+ alpha: 1
25870
25819
  };
25871
25820
 
25872
25821
  /**
@@ -25892,6 +25841,9 @@ class BlendImage extends BaseFilter {
25892
25841
  getFragmentSource() {
25893
25842
  return fragmentSource$c[this.mode];
25894
25843
  }
25844
+ getVertexSource() {
25845
+ return vertexSource;
25846
+ }
25895
25847
  applyToWebGL(options) {
25896
25848
  const gl = options.context,
25897
25849
  texture = this.createTexture(options.filterBackend, this.image);
@@ -25973,19 +25925,6 @@ class BlendImage extends BaseFilter {
25973
25925
  }
25974
25926
  }
25975
25927
 
25976
- /**
25977
- * Return WebGL uniform locations for this filter's shader.
25978
- *
25979
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
25980
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
25981
- */
25982
- getUniformLocations(gl, program) {
25983
- return {
25984
- uTransformMatrix: gl.getUniformLocation(program, 'uTransformMatrix'),
25985
- uImage: gl.getUniformLocation(program, 'uImage')
25986
- };
25987
- }
25988
-
25989
25928
  /**
25990
25929
  * Send data from this filter to its shader program's uniforms.
25991
25930
  *
@@ -26000,15 +25939,14 @@ class BlendImage extends BaseFilter {
26000
25939
 
26001
25940
  /**
26002
25941
  * Returns object representation of an instance
25942
+ * TODO: Handle the possibility of missing image better.
25943
+ * As of now a BlendImage filter without image can't be used with fromObject
26003
25944
  * @return {Object} Object representation of an instance
26004
25945
  */
26005
25946
  toObject() {
26006
- return {
26007
- type: this.type,
26008
- image: this.image && this.image.toObject(),
26009
- mode: this.mode,
26010
- alpha: this.alpha
26011
- };
25947
+ return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
25948
+ image: this.image && this.image.toObject()
25949
+ });
26012
25950
  }
26013
25951
 
26014
25952
  /**
@@ -26019,12 +25957,12 @@ class BlendImage extends BaseFilter {
26019
25957
  * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
26020
25958
  * @returns {Promise<BlendImage>}
26021
25959
  */
26022
- static fromObject(_ref2, options) {
25960
+ static async fromObject(_ref2, options) {
26023
25961
  let {
26024
25962
  type,
26025
25963
  image
26026
25964
  } = _ref2,
26027
- filterOptions = _objectWithoutProperties(_ref2, _excluded$3);
25965
+ filterOptions = _objectWithoutProperties(_ref2, _excluded);
26028
25966
  return FabricImage.fromObject(image, options).then(enlivedImage => new this(_objectSpread2(_objectSpread2({}, filterOptions), {}, {
26029
25967
  image: enlivedImage
26030
25968
  })));
@@ -26048,13 +25986,13 @@ class BlendImage extends BaseFilter {
26048
25986
  **/
26049
25987
  _defineProperty(BlendImage, "type", 'BlendImage');
26050
25988
  _defineProperty(BlendImage, "defaults", blendImageDefaultValues);
25989
+ _defineProperty(BlendImage, "uniformLocations", ['uTransformMatrix', 'uImage']);
26051
25990
  classRegistry.setClass(BlendImage);
26052
25991
 
26053
25992
  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 ";
26054
25993
 
26055
25994
  const blurDefaultValues = {
26056
- blur: 0,
26057
- mainParameter: 'blur'
25995
+ blur: 0
26058
25996
  };
26059
25997
 
26060
25998
  /**
@@ -26149,18 +26087,6 @@ class Blur extends BaseFilter {
26149
26087
  return newImageData;
26150
26088
  }
26151
26089
 
26152
- /**
26153
- * Return WebGL uniform locations for this filter's shader.
26154
- *
26155
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26156
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26157
- */
26158
- getUniformLocations(gl, program) {
26159
- return {
26160
- delta: gl.getUniformLocation(program, 'uDelta')
26161
- };
26162
- }
26163
-
26164
26090
  /**
26165
26091
  * Send data from this filter to its shader program's uniforms.
26166
26092
  *
@@ -26171,6 +26097,9 @@ class Blur extends BaseFilter {
26171
26097
  const delta = this.chooseRightDelta();
26172
26098
  gl.uniform2fv(uniformLocations.delta, delta);
26173
26099
  }
26100
+ isNeutralState() {
26101
+ return this.blur === 0;
26102
+ }
26174
26103
 
26175
26104
  /**
26176
26105
  * choose right value of image percentage to blur with
@@ -26208,13 +26137,13 @@ class Blur extends BaseFilter {
26208
26137
  */
26209
26138
  _defineProperty(Blur, "type", 'Blur');
26210
26139
  _defineProperty(Blur, "defaults", blurDefaultValues);
26140
+ _defineProperty(Blur, "uniformLocations", ['uDelta']);
26211
26141
  classRegistry.setClass(Blur);
26212
26142
 
26213
26143
  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";
26214
26144
 
26215
26145
  const brightnessDefaultValues = {
26216
- brightness: 0,
26217
- mainParameter: 'brightness'
26146
+ brightness: 0
26218
26147
  };
26219
26148
 
26220
26149
  /**
@@ -26243,9 +26172,6 @@ class Brightness extends BaseFilter {
26243
26172
  data
26244
26173
  }
26245
26174
  } = _ref;
26246
- if (this.brightness === 0) {
26247
- return;
26248
- }
26249
26175
  const brightness = Math.round(this.brightness * 255);
26250
26176
  for (let i = 0; i < data.length; i += 4) {
26251
26177
  data[i] = data[i] + brightness;
@@ -26253,17 +26179,8 @@ class Brightness extends BaseFilter {
26253
26179
  data[i + 2] = data[i + 2] + brightness;
26254
26180
  }
26255
26181
  }
26256
-
26257
- /**
26258
- * Return WebGL uniform locations for this filter's shader.
26259
- *
26260
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26261
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26262
- */
26263
- getUniformLocations(gl, program) {
26264
- return {
26265
- uBrightness: gl.getUniformLocation(program, 'uBrightness')
26266
- };
26182
+ isNeutralState() {
26183
+ return this.brightness === 0;
26267
26184
  }
26268
26185
 
26269
26186
  /**
@@ -26285,14 +26202,13 @@ class Brightness extends BaseFilter {
26285
26202
  */
26286
26203
  _defineProperty(Brightness, "type", 'Brightness');
26287
26204
  _defineProperty(Brightness, "defaults", brightnessDefaultValues);
26205
+ _defineProperty(Brightness, "uniformLocations", ['uBrightness']);
26288
26206
  classRegistry.setClass(Brightness);
26289
26207
 
26290
26208
  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 }";
26291
26209
 
26292
- const _excluded$2 = ["matrix"];
26293
26210
  const colorMatrixDefaultValues = {
26294
26211
  matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
26295
- mainParameter: 'matrix',
26296
26212
  colorsOnly: true
26297
26213
  };
26298
26214
 
@@ -26313,17 +26229,6 @@ const colorMatrixDefaultValues = {
26313
26229
  * object.applyFilters();
26314
26230
  */
26315
26231
  class ColorMatrix extends BaseFilter {
26316
- setOptions(_ref) {
26317
- let {
26318
- matrix
26319
- } = _ref,
26320
- options = _objectWithoutProperties(_ref, _excluded$2);
26321
- if (matrix) {
26322
- // safeguard against mutation
26323
- this.matrix = [...matrix];
26324
- }
26325
- Object.assign(this, options);
26326
- }
26327
26232
  getFragmentSource() {
26328
26233
  return fragmentSource$9;
26329
26234
  }
@@ -26357,19 +26262,6 @@ class ColorMatrix extends BaseFilter {
26357
26262
  }
26358
26263
  }
26359
26264
 
26360
- /**
26361
- * Return WebGL uniform locations for this filter's shader.
26362
- *
26363
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26364
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26365
- */
26366
- getUniformLocations(gl, program) {
26367
- return {
26368
- uColorMatrix: gl.getUniformLocation(program, 'uColorMatrix'),
26369
- uConstants: gl.getUniformLocation(program, 'uConstants')
26370
- };
26371
- }
26372
-
26373
26265
  /**
26374
26266
  * Send data from this filter to its shader program's uniforms.
26375
26267
  *
@@ -26383,6 +26275,11 @@ class ColorMatrix extends BaseFilter {
26383
26275
  gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);
26384
26276
  gl.uniform4fv(uniformLocations.uConstants, constants);
26385
26277
  }
26278
+ toObject() {
26279
+ return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
26280
+ matrix: [...this.matrix]
26281
+ });
26282
+ }
26386
26283
  }
26387
26284
  /**
26388
26285
  * Colormatrix for pixels.
@@ -26400,17 +26297,23 @@ class ColorMatrix extends BaseFilter {
26400
26297
  */
26401
26298
  _defineProperty(ColorMatrix, "type", 'ColorMatrix');
26402
26299
  _defineProperty(ColorMatrix, "defaults", colorMatrixDefaultValues);
26300
+ _defineProperty(ColorMatrix, "uniformLocations", ['uColorMatrix', 'uConstants']);
26403
26301
  classRegistry.setClass(ColorMatrix);
26404
26302
 
26405
26303
  function createColorMatrixFilter(key, matrix) {
26406
26304
  var _class;
26407
- const newClass = (_class = class newClass extends ColorMatrix {}, _defineProperty(_class, "type", key), _defineProperty(_class, "defaults", _objectSpread2(_objectSpread2({}, colorMatrixDefaultValues), {}, {
26408
- /**
26409
- * Lock the matrix export for this kind of static, parameter less filters.
26410
- */
26411
- mainParameter: undefined,
26305
+ const newClass = (_class = class newClass extends ColorMatrix {
26306
+ //@ts-expect-error TS wants matrix to be exported.
26307
+ toObject() {
26308
+ return {
26309
+ type: this.type,
26310
+ colorsOnly: this.colorsOnly
26311
+ };
26312
+ }
26313
+ }, _defineProperty(_class, "type", key), _defineProperty(_class, "defaults", {
26314
+ colorsOnly: false,
26412
26315
  matrix
26413
- })), _class);
26316
+ }), _class);
26414
26317
  classRegistry.setClass(newClass, key);
26415
26318
  return newClass;
26416
26319
  }
@@ -26422,20 +26325,14 @@ const Polaroid = createColorMatrixFilter('Polaroid', [1.438, -0.062, -0.062, 0,
26422
26325
  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]);
26423
26326
  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]);
26424
26327
 
26425
- const _excluded$1 = ["subFilters"];
26426
-
26427
26328
  /**
26428
26329
  * A container class that knows how to apply a sequence of filters to an input image.
26429
26330
  */
26430
26331
  class Composed extends BaseFilter {
26431
26332
  constructor() {
26432
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
26433
- {
26434
- subFilters = []
26435
- } = _ref,
26436
- options = _objectWithoutProperties(_ref, _excluded$1);
26333
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26437
26334
  super(options);
26438
- this.subFilters = subFilters;
26335
+ this.subFilters = options.subFilters || [];
26439
26336
  }
26440
26337
 
26441
26338
  /**
@@ -26455,13 +26352,14 @@ class Composed extends BaseFilter {
26455
26352
 
26456
26353
  /**
26457
26354
  * Serialize this filter into JSON.
26458
- *
26459
26355
  * @returns {Object} A JSON representation of this filter.
26460
26356
  */
26357
+ //@ts-expect-error TS doesn't like this toObject
26461
26358
  toObject() {
26462
- return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
26359
+ return {
26360
+ type: this.type,
26463
26361
  subFilters: this.subFilters.map(filter => filter.toObject())
26464
- });
26362
+ };
26465
26363
  }
26466
26364
  isNeutralState() {
26467
26365
  return !this.subFilters.some(filter => !filter.isNeutralState());
@@ -26490,8 +26388,7 @@ classRegistry.setClass(Composed);
26490
26388
  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 }";
26491
26389
 
26492
26390
  const contrastDefaultValues = {
26493
- contrast: 0,
26494
- mainParameter: 'contrast'
26391
+ contrast: 0
26495
26392
  };
26496
26393
 
26497
26394
  /**
@@ -26507,6 +26404,10 @@ class Contrast extends BaseFilter {
26507
26404
  getFragmentSource() {
26508
26405
  return fragmentSource$8;
26509
26406
  }
26407
+ isNeutralState() {
26408
+ return this.contrast === 0;
26409
+ }
26410
+
26510
26411
  /**
26511
26412
  * Apply the Contrast operation to a Uint8Array representing the pixels of an image.
26512
26413
  *
@@ -26519,9 +26420,6 @@ class Contrast extends BaseFilter {
26519
26420
  data
26520
26421
  }
26521
26422
  } = _ref;
26522
- if (this.contrast === 0) {
26523
- return;
26524
- }
26525
26423
  const contrast = Math.floor(this.contrast * 255),
26526
26424
  contrastF = 259 * (contrast + 255) / (255 * (259 - contrast));
26527
26425
  for (let i = 0; i < data.length; i += 4) {
@@ -26531,18 +26429,6 @@ class Contrast extends BaseFilter {
26531
26429
  }
26532
26430
  }
26533
26431
 
26534
- /**
26535
- * Return WebGL uniform locations for this filter's shader.
26536
- *
26537
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26538
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26539
- */
26540
- getUniformLocations(gl, program) {
26541
- return {
26542
- uContrast: gl.getUniformLocation(program, 'uContrast')
26543
- };
26544
- }
26545
-
26546
26432
  /**
26547
26433
  * Send data from this filter to its shader program's uniforms.
26548
26434
  *
@@ -26560,6 +26446,7 @@ class Contrast extends BaseFilter {
26560
26446
  */
26561
26447
  _defineProperty(Contrast, "type", 'Contrast');
26562
26448
  _defineProperty(Contrast, "defaults", contrastDefaultValues);
26449
+ _defineProperty(Contrast, "uniformLocations", ['uContrast']);
26563
26450
  classRegistry.setClass(Contrast);
26564
26451
 
26565
26452
  const fragmentSource$7 = {
@@ -26687,21 +26574,6 @@ class Convolute extends BaseFilter {
26687
26574
  options.imageData = output;
26688
26575
  }
26689
26576
 
26690
- /**
26691
- * Return WebGL uniform locations for this filter's shader.
26692
- *
26693
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26694
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26695
- */
26696
- getUniformLocations(gl, program) {
26697
- return {
26698
- uMatrix: gl.getUniformLocation(program, 'uMatrix'),
26699
- uOpaque: gl.getUniformLocation(program, 'uOpaque'),
26700
- uHalfSize: gl.getUniformLocation(program, 'uHalfSize'),
26701
- uSize: gl.getUniformLocation(program, 'uSize')
26702
- };
26703
- }
26704
-
26705
26577
  /**
26706
26578
  * Send data from this filter to its shader program's uniforms.
26707
26579
  *
@@ -26731,13 +26603,13 @@ class Convolute extends BaseFilter {
26731
26603
  */
26732
26604
  _defineProperty(Convolute, "type", 'Convolute');
26733
26605
  _defineProperty(Convolute, "defaults", convoluteDefaultValues);
26606
+ _defineProperty(Convolute, "uniformLocations", ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize']);
26734
26607
  classRegistry.setClass(Convolute);
26735
26608
 
26736
26609
  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";
26737
26610
 
26738
- const _excluded = ["gamma"];
26611
+ const GAMMA = 'Gamma';
26739
26612
  const gammaDefaultValues = {
26740
- mainParameter: 'gamma',
26741
26613
  gamma: [1, 1, 1]
26742
26614
  };
26743
26615
 
@@ -26755,13 +26627,9 @@ class Gamma extends BaseFilter {
26755
26627
  return fragmentSource$6;
26756
26628
  }
26757
26629
  constructor() {
26758
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
26759
- {
26760
- gamma = [1, 1, 1]
26761
- } = _ref,
26762
- options = _objectWithoutProperties(_ref, _excluded);
26630
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26763
26631
  super(options);
26764
- this.gamma = gamma;
26632
+ this.gamma = options.gamma || this.constructor.defaults.gamma.concat();
26765
26633
  }
26766
26634
 
26767
26635
  /**
@@ -26770,12 +26638,12 @@ class Gamma extends BaseFilter {
26770
26638
  * @param {Object} options
26771
26639
  * @param {ImageData} options.imageData The Uint8Array to be filtered.
26772
26640
  */
26773
- applyTo2d(_ref2) {
26641
+ applyTo2d(_ref) {
26774
26642
  let {
26775
26643
  imageData: {
26776
26644
  data
26777
26645
  }
26778
- } = _ref2;
26646
+ } = _ref;
26779
26647
  const gamma = this.gamma,
26780
26648
  rInv = 1 / gamma[0],
26781
26649
  gInv = 1 / gamma[1],
@@ -26803,18 +26671,6 @@ class Gamma extends BaseFilter {
26803
26671
  }
26804
26672
  }
26805
26673
 
26806
- /**
26807
- * Return WebGL uniform locations for this filter's shader.
26808
- *
26809
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26810
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26811
- */
26812
- getUniformLocations(gl, program) {
26813
- return {
26814
- uGamma: gl.getUniformLocation(program, 'uGamma')
26815
- };
26816
- }
26817
-
26818
26674
  /**
26819
26675
  * Send data from this filter to its shader program's uniforms.
26820
26676
  *
@@ -26824,14 +26680,27 @@ class Gamma extends BaseFilter {
26824
26680
  sendUniformData(gl, uniformLocations) {
26825
26681
  gl.uniform3fv(uniformLocations.uGamma, this.gamma);
26826
26682
  }
26683
+ isNeutralState() {
26684
+ const {
26685
+ gamma
26686
+ } = this;
26687
+ return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;
26688
+ }
26689
+ toObject() {
26690
+ return {
26691
+ type: GAMMA,
26692
+ gamma: this.gamma.concat()
26693
+ };
26694
+ }
26827
26695
  }
26828
26696
  /**
26829
26697
  * Gamma array value, from 0.01 to 2.2.
26830
26698
  * @param {Array} gamma
26831
26699
  * @default
26832
26700
  */
26833
- _defineProperty(Gamma, "type", 'Gamma');
26701
+ _defineProperty(Gamma, "type", GAMMA);
26834
26702
  _defineProperty(Gamma, "defaults", gammaDefaultValues);
26703
+ _defineProperty(Gamma, "uniformLocations", ['uGamma']);
26835
26704
  classRegistry.setClass(Gamma);
26836
26705
 
26837
26706
  const fragmentSource$5 = {
@@ -26841,8 +26710,7 @@ const fragmentSource$5 = {
26841
26710
  };
26842
26711
 
26843
26712
  const grayscaleDefaultValues = {
26844
- mode: 'average',
26845
- mainParameter: 'mode'
26713
+ mode: 'average'
26846
26714
  };
26847
26715
 
26848
26716
  /**
@@ -26889,18 +26757,6 @@ class Grayscale extends BaseFilter {
26889
26757
  return fragmentSource$5[this.mode];
26890
26758
  }
26891
26759
 
26892
- /**
26893
- * Return WebGL uniform locations for this filter's shader.
26894
- *
26895
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26896
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26897
- */
26898
- getUniformLocations(gl, program) {
26899
- return {
26900
- uMode: gl.getUniformLocation(program, 'uMode')
26901
- };
26902
- }
26903
-
26904
26760
  /**
26905
26761
  * Send data from this filter to its shader program's uniforms.
26906
26762
  *
@@ -26923,11 +26779,11 @@ class Grayscale extends BaseFilter {
26923
26779
  }
26924
26780
  _defineProperty(Grayscale, "type", 'Grayscale');
26925
26781
  _defineProperty(Grayscale, "defaults", grayscaleDefaultValues);
26782
+ _defineProperty(Grayscale, "uniformLocations", ['uMode']);
26926
26783
  classRegistry.setClass(Grayscale);
26927
26784
 
26928
26785
  const hueRotationDefaultValues = {
26929
- rotation: 0,
26930
- mainParameter: 'rotation'
26786
+ rotation: 0
26931
26787
  };
26932
26788
 
26933
26789
  /**
@@ -26939,7 +26795,6 @@ const hueRotationDefaultValues = {
26939
26795
  * object.filters.push(filter);
26940
26796
  * object.applyFilters();
26941
26797
  */
26942
- // @ts-expect-error some babbling about mainParameter
26943
26798
  class HueRotation extends ColorMatrix {
26944
26799
  calculateMatrix() {
26945
26800
  const rad = this.rotation * Math.PI,
@@ -26960,13 +26815,20 @@ class HueRotation extends ColorMatrix {
26960
26815
  this.matrix[12] = cosine + aThird * OneMinusCos;
26961
26816
  }
26962
26817
  isNeutralState() {
26963
- this.calculateMatrix();
26964
- return super.isNeutralState();
26818
+ return this.rotation === 0;
26965
26819
  }
26966
26820
  applyTo(options) {
26967
26821
  this.calculateMatrix();
26968
26822
  super.applyTo(options);
26969
26823
  }
26824
+
26825
+ //@ts-expect-error TS and classes with different methods
26826
+ toObject() {
26827
+ return {
26828
+ type: this.type,
26829
+ rotation: this.rotation
26830
+ };
26831
+ }
26970
26832
  }
26971
26833
  /**
26972
26834
  * HueRotation value, from -1 to 1.
@@ -26979,8 +26841,7 @@ const fragmentSource$4 = "\n precision highp float;\n uniform sampler2D uTextu
26979
26841
 
26980
26842
  const invertDefaultValues = {
26981
26843
  alpha: false,
26982
- invert: true,
26983
- mainParameter: 'invert'
26844
+ invert: true
26984
26845
  };
26985
26846
 
26986
26847
  /**
@@ -27025,19 +26886,6 @@ class Invert extends BaseFilter {
27025
26886
  return !this.invert;
27026
26887
  }
27027
26888
 
27028
- /**
27029
- * Return WebGL uniform locations for this filter's shader.
27030
- *
27031
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27032
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27033
- */
27034
- getUniformLocations(gl, program) {
27035
- return {
27036
- uInvert: gl.getUniformLocation(program, 'uInvert'),
27037
- uAlpha: gl.getUniformLocation(program, 'uAlpha')
27038
- };
27039
- }
27040
-
27041
26889
  /**
27042
26890
  * Send data from this filter to its shader program's uniforms.
27043
26891
  *
@@ -27061,12 +26909,12 @@ class Invert extends BaseFilter {
27061
26909
  */
27062
26910
  _defineProperty(Invert, "type", 'Invert');
27063
26911
  _defineProperty(Invert, "defaults", invertDefaultValues);
26912
+ _defineProperty(Invert, "uniformLocations", ['uInvert', 'uAlpha']);
27064
26913
  classRegistry.setClass(Invert);
27065
26914
 
27066
26915
  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";
27067
26916
 
27068
26917
  const noiseDefaultValues = {
27069
- mainParameter: 'noise',
27070
26918
  noise: 0
27071
26919
  };
27072
26920
 
@@ -27097,9 +26945,6 @@ class Noise extends BaseFilter {
27097
26945
  data
27098
26946
  }
27099
26947
  } = _ref;
27100
- if (this.noise === 0) {
27101
- return;
27102
- }
27103
26948
  const noise = this.noise;
27104
26949
  for (let i = 0; i < data.length; i += 4) {
27105
26950
  const rand = (0.5 - Math.random()) * noise;
@@ -27109,19 +26954,6 @@ class Noise extends BaseFilter {
27109
26954
  }
27110
26955
  }
27111
26956
 
27112
- /**
27113
- * Return WebGL uniform locations for this filter's shader.
27114
- *
27115
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27116
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27117
- */
27118
- getUniformLocations(gl, program) {
27119
- return {
27120
- uNoise: gl.getUniformLocation(program, 'uNoise'),
27121
- uSeed: gl.getUniformLocation(program, 'uSeed')
27122
- };
27123
- }
27124
-
27125
26957
  /**
27126
26958
  * Send data from this filter to its shader program's uniforms.
27127
26959
  *
@@ -27132,15 +26964,8 @@ class Noise extends BaseFilter {
27132
26964
  gl.uniform1f(uniformLocations.uNoise, this.noise / 255);
27133
26965
  gl.uniform1f(uniformLocations.uSeed, Math.random());
27134
26966
  }
27135
-
27136
- /**
27137
- * Returns object representation of an instance
27138
- * @return {Object} Object representation of an instance
27139
- */
27140
- toObject() {
27141
- return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
27142
- noise: this.noise
27143
- });
26967
+ isNeutralState() {
26968
+ return this.noise === 0;
27144
26969
  }
27145
26970
  }
27146
26971
  /**
@@ -27150,13 +26975,13 @@ class Noise extends BaseFilter {
27150
26975
  */
27151
26976
  _defineProperty(Noise, "type", 'Noise');
27152
26977
  _defineProperty(Noise, "defaults", noiseDefaultValues);
26978
+ _defineProperty(Noise, "uniformLocations", ['uNoise', 'uSeed']);
27153
26979
  classRegistry.setClass(Noise);
27154
26980
 
27155
26981
  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";
27156
26982
 
27157
26983
  const pixelateDefaultValues = {
27158
- blocksize: 4,
27159
- mainParameter: 'blocksize'
26984
+ blocksize: 4
27160
26985
  };
27161
26986
 
27162
26987
  /**
@@ -27213,20 +27038,6 @@ class Pixelate extends BaseFilter {
27213
27038
  return fragmentSource$2;
27214
27039
  }
27215
27040
 
27216
- /**
27217
- * Return WebGL uniform locations for this filter's shader.
27218
- *
27219
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27220
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27221
- */
27222
- getUniformLocations(gl, program) {
27223
- return {
27224
- uBlocksize: gl.getUniformLocation(program, 'uBlocksize'),
27225
- uStepW: gl.getUniformLocation(program, 'uStepW'),
27226
- uStepH: gl.getUniformLocation(program, 'uStepH')
27227
- };
27228
- }
27229
-
27230
27041
  /**
27231
27042
  * Send data from this filter to its shader program's uniforms.
27232
27043
  *
@@ -27239,6 +27050,7 @@ class Pixelate extends BaseFilter {
27239
27050
  }
27240
27051
  _defineProperty(Pixelate, "type", 'Pixelate');
27241
27052
  _defineProperty(Pixelate, "defaults", pixelateDefaultValues);
27053
+ _defineProperty(Pixelate, "uniformLocations", ['uBlockSize']);
27242
27054
  classRegistry.setClass(Pixelate);
27243
27055
 
27244
27056
  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";
@@ -27288,19 +27100,6 @@ class RemoveColor extends BaseFilter {
27288
27100
  }
27289
27101
  }
27290
27102
 
27291
- /**
27292
- * Return WebGL uniform locations for this filter's shader.
27293
- *
27294
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27295
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27296
- */
27297
- getUniformLocations(gl, program) {
27298
- return {
27299
- uLow: gl.getUniformLocation(program, 'uLow'),
27300
- uHigh: gl.getUniformLocation(program, 'uHigh')
27301
- };
27302
- }
27303
-
27304
27103
  /**
27305
27104
  * Send data from this filter to its shader program's uniforms.
27306
27105
  *
@@ -27315,17 +27114,6 @@ class RemoveColor extends BaseFilter {
27315
27114
  gl.uniform4fv(uniformLocations.uLow, lowC);
27316
27115
  gl.uniform4fv(uniformLocations.uHigh, highC);
27317
27116
  }
27318
-
27319
- /**
27320
- * Returns object representation of an instance
27321
- * @return {Object} Object representation of an instance
27322
- */
27323
- toObject() {
27324
- return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
27325
- color: this.color,
27326
- distance: this.distance
27327
- });
27328
- }
27329
27117
  }
27330
27118
  /**
27331
27119
  * Color to remove, in any format understood by {@link Color}.
@@ -27342,14 +27130,14 @@ class RemoveColor extends BaseFilter {
27342
27130
  **/
27343
27131
  _defineProperty(RemoveColor, "type", 'RemoveColor');
27344
27132
  _defineProperty(RemoveColor, "defaults", removeColorDefaultValues);
27133
+ _defineProperty(RemoveColor, "uniformLocations", ['uLow', 'uHigh']);
27345
27134
  classRegistry.setClass(RemoveColor);
27346
27135
 
27347
27136
  const resizeDefaultValues = {
27348
27137
  resizeType: 'hermite',
27349
27138
  scaleX: 1,
27350
27139
  scaleY: 1,
27351
- lanczosLobes: 3,
27352
- fragmentSourceTOP: "\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n "
27140
+ lanczosLobes: 3
27353
27141
  };
27354
27142
  /**
27355
27143
  * Resize image filter class
@@ -27359,19 +27147,6 @@ const resizeDefaultValues = {
27359
27147
  * object.applyFilters(canvas.renderAll.bind(canvas));
27360
27148
  */
27361
27149
  class Resize extends BaseFilter {
27362
- /**
27363
- * Return WebGL uniform locations for this filter's shader.
27364
- *
27365
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27366
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27367
- */
27368
- getUniformLocations(gl, program) {
27369
- return {
27370
- uDelta: gl.getUniformLocation(program, 'uDelta'),
27371
- uTaps: gl.getUniformLocation(program, 'uTaps')
27372
- };
27373
- }
27374
-
27375
27150
  /**
27376
27151
  * Send data from this filter to its shader program's uniforms.
27377
27152
  *
@@ -27414,7 +27189,7 @@ class Resize extends BaseFilter {
27414
27189
  for (let i = 1; i <= filterWindow; i++) {
27415
27190
  offsets[i - 1] = "".concat(i, ".0 * uDelta");
27416
27191
  }
27417
- 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 ");
27192
+ 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 ");
27418
27193
  }
27419
27194
  applyToForWebgl(options) {
27420
27195
  options.passes++;
@@ -27757,20 +27532,6 @@ class Resize extends BaseFilter {
27757
27532
  }
27758
27533
  return img2;
27759
27534
  }
27760
-
27761
- /**
27762
- * Returns object representation of an instance
27763
- * @return {Object} Object representation of an instance
27764
- */
27765
- toObject() {
27766
- return {
27767
- type: this.type,
27768
- scaleX: this.scaleX,
27769
- scaleY: this.scaleY,
27770
- resizeType: this.resizeType,
27771
- lanczosLobes: this.lanczosLobes
27772
- };
27773
- }
27774
27535
  }
27775
27536
  /**
27776
27537
  * Resize type
@@ -27795,10 +27556,15 @@ class Resize extends BaseFilter {
27795
27556
  */
27796
27557
  _defineProperty(Resize, "type", 'Resize');
27797
27558
  _defineProperty(Resize, "defaults", resizeDefaultValues);
27559
+ _defineProperty(Resize, "uniformLocations", ['uDelta', 'uTaps']);
27798
27560
  classRegistry.setClass(Resize);
27799
27561
 
27800
27562
  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";
27801
27563
 
27564
+ const saturationDefaultValues = {
27565
+ saturation: 0
27566
+ };
27567
+
27802
27568
  /**
27803
27569
  * Saturate filter class
27804
27570
  * @example
@@ -27808,11 +27574,6 @@ const fragmentSource$1 = "\n precision highp float;\n uniform sampler2D uTextu
27808
27574
  * object.filters.push(filter);
27809
27575
  * object.applyFilters();
27810
27576
  */
27811
-
27812
- const saturationDefaultValues = {
27813
- saturation: 0,
27814
- mainParameter: 'saturation'
27815
- };
27816
27577
  class Saturation extends BaseFilter {
27817
27578
  getFragmentSource() {
27818
27579
  return fragmentSource$1;
@@ -27830,9 +27591,6 @@ class Saturation extends BaseFilter {
27830
27591
  data
27831
27592
  }
27832
27593
  } = _ref;
27833
- if (this.saturation === 0) {
27834
- return;
27835
- }
27836
27594
  const adjust = -this.saturation;
27837
27595
  for (let i = 0; i < data.length; i += 4) {
27838
27596
  const max = Math.max(data[i], data[i + 1], data[i + 2]);
@@ -27842,18 +27600,6 @@ class Saturation extends BaseFilter {
27842
27600
  }
27843
27601
  }
27844
27602
 
27845
- /**
27846
- * Return WebGL uniform locations for this filter's shader.
27847
- *
27848
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27849
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27850
- */
27851
- getUniformLocations(gl, program) {
27852
- return {
27853
- uSaturation: gl.getUniformLocation(program, 'uSaturation')
27854
- };
27855
- }
27856
-
27857
27603
  /**
27858
27604
  * Send data from this filter to its shader program's uniforms.
27859
27605
  *
@@ -27863,6 +27609,9 @@ class Saturation extends BaseFilter {
27863
27609
  sendUniformData(gl, uniformLocations) {
27864
27610
  gl.uniform1f(uniformLocations.uSaturation, -this.saturation);
27865
27611
  }
27612
+ isNeutralState() {
27613
+ return this.saturation === 0;
27614
+ }
27866
27615
  }
27867
27616
  /**
27868
27617
  * Saturation value, from -1 to 1.
@@ -27874,13 +27623,13 @@ class Saturation extends BaseFilter {
27874
27623
  */
27875
27624
  _defineProperty(Saturation, "type", 'Saturation');
27876
27625
  _defineProperty(Saturation, "defaults", saturationDefaultValues);
27626
+ _defineProperty(Saturation, "uniformLocations", ['uSaturation']);
27877
27627
  classRegistry.setClass(Saturation);
27878
27628
 
27879
27629
  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";
27880
27630
 
27881
27631
  const vibranceDefaultValues = {
27882
- vibrance: 0,
27883
- mainParameter: 'vibrance'
27632
+ vibrance: 0
27884
27633
  };
27885
27634
 
27886
27635
  /**
@@ -27909,9 +27658,6 @@ class Vibrance extends BaseFilter {
27909
27658
  data
27910
27659
  }
27911
27660
  } = _ref;
27912
- if (this.vibrance === 0) {
27913
- return;
27914
- }
27915
27661
  const adjust = -this.vibrance;
27916
27662
  for (let i = 0; i < data.length; i += 4) {
27917
27663
  const max = Math.max(data[i], data[i + 1], data[i + 2]);
@@ -27923,27 +27669,18 @@ class Vibrance extends BaseFilter {
27923
27669
  }
27924
27670
  }
27925
27671
 
27926
- /**
27927
- * Return WebGL uniform locations for this filter's shader.
27928
- *
27929
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27930
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27931
- */
27932
- getUniformLocations(gl, program) {
27933
- return {
27934
- uVibrance: gl.getUniformLocation(program, 'uVibrance')
27935
- };
27936
- }
27937
-
27938
27672
  /**
27939
27673
  * Send data from this filter to its shader program's uniforms.
27940
27674
  *
27941
27675
  * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27942
- * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects
27676
+ * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects
27943
27677
  */
27944
27678
  sendUniformData(gl, uniformLocations) {
27945
27679
  gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);
27946
27680
  }
27681
+ isNeutralState() {
27682
+ return this.vibrance === 0;
27683
+ }
27947
27684
  }
27948
27685
  /**
27949
27686
  * Vibrance value, from -1 to 1.
@@ -27955,6 +27692,7 @@ class Vibrance extends BaseFilter {
27955
27692
  */
27956
27693
  _defineProperty(Vibrance, "type", 'Vibrance');
27957
27694
  _defineProperty(Vibrance, "defaults", vibranceDefaultValues);
27695
+ _defineProperty(Vibrance, "uniformLocations", ['uVibrance']);
27958
27696
  classRegistry.setClass(Vibrance);
27959
27697
 
27960
27698
  var filters = /*#__PURE__*/Object.freeze({