@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
package/dist/index.js CHANGED
@@ -423,7 +423,7 @@
423
423
  }
424
424
  const cache = new Cache();
425
425
 
426
- var version = "6.0.0-rc2.0";
426
+ var version = "6.0.0";
427
427
 
428
428
  // use this syntax so babel plugin see this import here
429
429
  const VERSION = version;
@@ -2371,6 +2371,7 @@
2371
2371
  * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list
2372
2372
  */
2373
2373
  constructor(color) {
2374
+ _defineProperty(this, "isUnrecognised", false);
2374
2375
  if (!color) {
2375
2376
  // we default to black as canvas does
2376
2377
  this.setSource([0, 0, 0, 1]);
@@ -2396,7 +2397,7 @@
2396
2397
  return color === 'transparent' ? [255, 255, 255, 0] : Color.sourceFromHex(color) || Color.sourceFromRgb(color) || Color.sourceFromHsl(color) ||
2397
2398
  // color is not recognized
2398
2399
  // we default to black as canvas does
2399
- [0, 0, 0, 1];
2400
+ (this.isUnrecognised = true) && [0, 0, 0, 1];
2400
2401
  }
2401
2402
 
2402
2403
  /**
@@ -3323,20 +3324,7 @@
3323
3324
  * @param {Array} vpt a Canvas 2D API transform matrix
3324
3325
  */
3325
3326
  setViewportTransform(vpt) {
3326
- const backgroundObject = this.backgroundImage,
3327
- overlayObject = this.overlayImage,
3328
- len = this._objects.length;
3329
3327
  this.viewportTransform = vpt;
3330
- for (let i = 0; i < len; i++) {
3331
- const object = this._objects[i];
3332
- object.group || object.setCoords();
3333
- }
3334
- if (backgroundObject) {
3335
- backgroundObject.setCoords();
3336
- }
3337
- if (overlayObject) {
3338
- overlayObject.setCoords();
3339
- }
3340
3328
  this.calcViewportBoundaries();
3341
3329
  this.renderOnAddRemove && this.requestRenderAll();
3342
3330
  }
@@ -4388,7 +4376,7 @@
4388
4376
  };
4389
4377
  };
4390
4378
 
4391
- const _excluded$m = ["translateX", "translateY", "scaleX", "scaleY"];
4379
+ const _excluded$i = ["translateX", "translateY", "scaleX", "scaleY"];
4392
4380
 
4393
4381
  /**
4394
4382
  * given an object and a transform, apply the inverse transform to the object,
@@ -4430,7 +4418,7 @@
4430
4418
  scaleX,
4431
4419
  scaleY
4432
4420
  } = _qrDecompose,
4433
- otherOptions = _objectWithoutProperties(_qrDecompose, _excluded$m),
4421
+ otherOptions = _objectWithoutProperties(_qrDecompose, _excluded$i),
4434
4422
  center = new Point(translateX, translateY);
4435
4423
  object.flipX = false;
4436
4424
  object.flipY = false;
@@ -5345,14 +5333,14 @@
5345
5333
  }
5346
5334
  }
5347
5335
 
5348
- const _excluded$l = ["startValue", "endValue"];
5336
+ const _excluded$h = ["startValue", "endValue"];
5349
5337
  class ValueAnimation extends AnimationBase {
5350
5338
  constructor(_ref) {
5351
5339
  let {
5352
5340
  startValue = 0,
5353
5341
  endValue = 100
5354
5342
  } = _ref,
5355
- otherOptions = _objectWithoutProperties(_ref, _excluded$l);
5343
+ otherOptions = _objectWithoutProperties(_ref, _excluded$h);
5356
5344
  super(_objectSpread2(_objectSpread2({}, otherOptions), {}, {
5357
5345
  startValue,
5358
5346
  byValue: endValue - startValue
@@ -5367,14 +5355,14 @@
5367
5355
  }
5368
5356
  }
5369
5357
 
5370
- const _excluded$k = ["startValue", "endValue"];
5358
+ const _excluded$g = ["startValue", "endValue"];
5371
5359
  class ArrayAnimation extends AnimationBase {
5372
5360
  constructor(_ref) {
5373
5361
  let {
5374
5362
  startValue = [0],
5375
5363
  endValue = [100]
5376
5364
  } = _ref,
5377
- options = _objectWithoutProperties(_ref, _excluded$k);
5365
+ options = _objectWithoutProperties(_ref, _excluded$g);
5378
5366
  super(_objectSpread2(_objectSpread2({}, options), {}, {
5379
5367
  startValue,
5380
5368
  byValue: endValue.map((value, i) => value - startValue[i])
@@ -5391,7 +5379,7 @@
5391
5379
 
5392
5380
  const capValue = (min, value, max) => Math.max(min, Math.min(value, max));
5393
5381
 
5394
- const _excluded$j = ["startValue", "endValue", "easing", "onChange", "onComplete", "abort"];
5382
+ const _excluded$f = ["startValue", "endValue", "easing", "onChange", "onComplete", "abort"];
5395
5383
  const defaultColorEasing = (timeElapsed, startValue, byValue, duration) => {
5396
5384
  const durationProgress = 1 - Math.cos(timeElapsed / duration * halfPI);
5397
5385
  return startValue + byValue * durationProgress;
@@ -5407,7 +5395,7 @@
5407
5395
  onComplete,
5408
5396
  abort
5409
5397
  } = _ref,
5410
- options = _objectWithoutProperties(_ref, _excluded$j);
5398
+ options = _objectWithoutProperties(_ref, _excluded$f);
5411
5399
  const startColor = new Color(startValue).getSource();
5412
5400
  const endColor = new Color(endValue).getSource();
5413
5401
  super(_objectSpread2(_objectSpread2({}, options), {}, {
@@ -6448,10 +6436,6 @@
6448
6436
  }
6449
6437
  }
6450
6438
 
6451
- /**
6452
- * Strict: only ancestors that are objects (without canvas)
6453
- */
6454
-
6455
6439
  class StackedObject extends ObjectGeometry {
6456
6440
  /**
6457
6441
  * A reference to the parent of the object
@@ -6475,17 +6459,14 @@
6475
6459
  }
6476
6460
 
6477
6461
  /**
6478
- *
6479
- * @param {boolean} [strict] returns only ancestors that are objects (without canvas)
6480
6462
  * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top
6481
6463
  */
6482
- getAncestors(strict) {
6464
+ getAncestors() {
6483
6465
  const ancestors = [];
6484
6466
  // eslint-disable-next-line @typescript-eslint/no-this-alias
6485
6467
  let parent = this;
6486
6468
  do {
6487
- var _parent$parent;
6488
- parent = parent instanceof StackedObject ? (_parent$parent = parent.parent) !== null && _parent$parent !== void 0 ? _parent$parent : !strict ? parent.canvas : undefined : undefined;
6469
+ parent = parent instanceof StackedObject ? parent.parent : undefined;
6489
6470
  parent && ancestors.push(parent);
6490
6471
  } while (parent);
6491
6472
  return ancestors;
@@ -6495,19 +6476,18 @@
6495
6476
  * Compare ancestors
6496
6477
  *
6497
6478
  * @param {StackedObject} other
6498
- * @param {boolean} [strict] finds only ancestors that are objects (without canvas)
6499
6479
  * @returns {AncestryComparison} an object that represent the ancestry situation.
6500
6480
  */
6501
- findCommonAncestors(other, strict) {
6481
+ findCommonAncestors(other) {
6502
6482
  if (this === other) {
6503
6483
  return {
6504
6484
  fork: [],
6505
6485
  otherFork: [],
6506
- common: [this, ...this.getAncestors(strict)]
6486
+ common: [this, ...this.getAncestors()]
6507
6487
  };
6508
6488
  }
6509
- const ancestors = this.getAncestors(strict);
6510
- const otherAncestors = other.getAncestors(strict);
6489
+ const ancestors = this.getAncestors();
6490
+ const otherAncestors = other.getAncestors();
6511
6491
  // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case
6512
6492
  if (ancestors.length === 0 && otherAncestors.length > 0 && this === otherAncestors[otherAncestors.length - 1]) {
6513
6493
  return {
@@ -6554,11 +6534,10 @@
6554
6534
  /**
6555
6535
  *
6556
6536
  * @param {StackedObject} other
6557
- * @param {boolean} [strict] checks only ancestors that are objects (without canvas)
6558
6537
  * @returns {boolean}
6559
6538
  */
6560
- hasCommonAncestors(other, strict) {
6561
- const commonAncestors = this.findCommonAncestors(other, strict);
6539
+ hasCommonAncestors(other) {
6540
+ const commonAncestors = this.findCommonAncestors(other);
6562
6541
  return commonAncestors && !!commonAncestors.common.length;
6563
6542
  }
6564
6543
 
@@ -6572,16 +6551,15 @@
6572
6551
  return undefined;
6573
6552
  }
6574
6553
  const ancestorData = this.findCommonAncestors(other);
6575
- if (!ancestorData) {
6576
- return undefined;
6577
- }
6578
6554
  if (ancestorData.fork.includes(other)) {
6579
6555
  return true;
6580
6556
  }
6581
6557
  if (ancestorData.otherFork.includes(this)) {
6582
6558
  return false;
6583
6559
  }
6584
- const firstCommonAncestor = ancestorData.common[0];
6560
+ // if there isn't a common ancestor, we take the canvas.
6561
+ // if there is no canvas, there is nothing to compare
6562
+ const firstCommonAncestor = ancestorData.common[0] || this.canvas;
6585
6563
  if (!firstCommonAncestor) {
6586
6564
  return undefined;
6587
6565
  }
@@ -6954,7 +6932,7 @@
6954
6932
  moveCursor: null
6955
6933
  };
6956
6934
 
6957
- const _excluded$i = ["type"],
6935
+ const _excluded$e = ["type"],
6958
6936
  _excluded2$4 = ["extraParam"];
6959
6937
  /**
6960
6938
  * Root object class from which all 2d shape classes inherit from
@@ -7142,7 +7120,7 @@
7142
7120
  height = dims.height,
7143
7121
  zoomX = dims.zoomX,
7144
7122
  zoomY = dims.zoomY,
7145
- dimensionsChanged = width !== this.cacheWidth || height !== this.cacheHeight,
7123
+ dimensionsChanged = width !== canvas.width || height !== canvas.height,
7146
7124
  zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;
7147
7125
  if (!canvas || !context) {
7148
7126
  return false;
@@ -7183,8 +7161,6 @@
7183
7161
  drawingHeight = dims.y / 2;
7184
7162
  this.cacheTranslationX = Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;
7185
7163
  this.cacheTranslationY = Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;
7186
- this.cacheWidth = width;
7187
- this.cacheHeight = height;
7188
7164
  context.translate(this.cacheTranslationX, this.cacheTranslationY);
7189
7165
  context.scale(zoomX, zoomY);
7190
7166
  this.zoomX = zoomX;
@@ -7459,8 +7435,6 @@
7459
7435
  _removeCacheCanvas() {
7460
7436
  this._cacheCanvas = undefined;
7461
7437
  this._cacheContext = null;
7462
- this.cacheWidth = 0;
7463
- this.cacheHeight = 0;
7464
7438
  }
7465
7439
 
7466
7440
  /**
@@ -7619,15 +7593,18 @@
7619
7593
  if (this.isNotVisible()) {
7620
7594
  return false;
7621
7595
  }
7622
- if (this._cacheCanvas && this._cacheContext && !skipCanvas && this._updateCacheCanvas()) {
7596
+ const canvas = this._cacheCanvas;
7597
+ const ctx = this._cacheContext;
7598
+ if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {
7623
7599
  // in this case the context is already cleared.
7624
7600
  return true;
7625
7601
  } else {
7626
7602
  if (this.dirty || this.clipPath && this.clipPath.absolutePositioned) {
7627
- if (this._cacheCanvas && this._cacheContext && !skipCanvas) {
7628
- const width = this.cacheWidth / this.zoomX;
7629
- const height = this.cacheHeight / this.zoomY;
7630
- this._cacheContext.clearRect(-width / 2, -height / 2, width, height);
7603
+ if (canvas && ctx && !skipCanvas) {
7604
+ ctx.save();
7605
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
7606
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
7607
+ ctx.restore();
7631
7608
  }
7632
7609
  return true;
7633
7610
  }
@@ -8151,7 +8128,7 @@
8151
8128
  * @returns {Promise<FabricObject>}
8152
8129
  */
8153
8130
  static _fromObject(_ref2) {
8154
- let object = _objectWithoutProperties(_ref2, _excluded$i);
8131
+ let object = _objectWithoutProperties(_ref2, _excluded$e);
8155
8132
  let _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
8156
8133
  {
8157
8134
  extraParam
@@ -8902,7 +8879,7 @@
8902
8879
  const scalingX = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectX));
8903
8880
  const scalingY = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectY));
8904
8881
 
8905
- const _excluded$h = ["target", "ex", "ey", "skewingSide"];
8882
+ const _excluded$d = ["target", "ex", "ey", "skewingSide"];
8906
8883
  const AXIS_KEYS = {
8907
8884
  x: {
8908
8885
  counterAxis: 'y',
@@ -8952,7 +8929,7 @@
8952
8929
  ey,
8953
8930
  skewingSide
8954
8931
  } = _ref,
8955
- transform = _objectWithoutProperties(_ref, _excluded$h);
8932
+ transform = _objectWithoutProperties(_ref, _excluded$d);
8956
8933
  const {
8957
8934
  skew: skewKey
8958
8935
  } = AXIS_KEYS[axis],
@@ -9538,6 +9515,9 @@
9538
9515
  * Draws corners of an object's bounding box.
9539
9516
  * Requires public properties: width, height
9540
9517
  * Requires public options: cornerSize, padding
9518
+ * Be aware that since fabric 6.0 this function does not call setCoords anymore.
9519
+ * setCoords needs to be called manually if the object of which we are rendering controls
9520
+ * is outside the standard selection and transform process.
9541
9521
  * @param {CanvasRenderingContext2D} ctx Context to draw on
9542
9522
  * @param {ControlRenderingStyleOverride} styleOverride object to override the object style
9543
9523
  */
@@ -9561,7 +9541,6 @@
9561
9541
  ctx.strokeStyle = options.cornerStrokeColor;
9562
9542
  }
9563
9543
  this._setLineDash(ctx, options.cornerDashArray);
9564
- this.setCoords();
9565
9544
  this.forEachControl((control, key) => {
9566
9545
  if (control.getVisibility(this, key)) {
9567
9546
  const p = this.oCoords[key];
@@ -10794,7 +10773,7 @@
10794
10773
  return svgValidParentsRegEx.test(element.nodeName) ? mergedAttrs : setStrokeFillOpacity(mergedAttrs);
10795
10774
  }
10796
10775
 
10797
- const _excluded$g = ["left", "top", "width", "height", "visible"];
10776
+ const _excluded$c = ["left", "top", "width", "height", "visible"];
10798
10777
  const rectDefaultValues = {
10799
10778
  rx: 0,
10800
10779
  ry: 0
@@ -10908,7 +10887,7 @@
10908
10887
  height = 0,
10909
10888
  visible = true
10910
10889
  } = _parseAttributes,
10911
- restOfparsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$g);
10890
+ restOfparsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$c);
10912
10891
  return new this(_objectSpread2(_objectSpread2(_objectSpread2({}, options), restOfparsedAttributes), {}, {
10913
10892
  left,
10914
10893
  top,
@@ -11064,7 +11043,7 @@
11064
11043
  _defineProperty(FitContentLayout, "type", 'fit-content');
11065
11044
  classRegistry.setClass(FitContentLayout);
11066
11045
 
11067
- const _excluded$f = ["strategy"],
11046
+ const _excluded$b = ["strategy"],
11068
11047
  _excluded2$3 = ["target", "strategy", "bubbles", "prevStrategy"];
11069
11048
  const LAYOUT_MANAGER = 'layoutManager';
11070
11049
  class LayoutManager {
@@ -11167,7 +11146,7 @@
11167
11146
  context
11168
11147
  });
11169
11148
  if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {
11170
- const tricklingContext = _objectWithoutProperties(context, _excluded$f);
11149
+ const tricklingContext = _objectWithoutProperties(context, _excluded$b);
11171
11150
  // traverse the tree
11172
11151
  target.forEachObject(object => object.layoutManager && object.layoutManager.performLayout(_objectSpread2(_objectSpread2({}, tricklingContext), {}, {
11173
11152
  bubbles: false,
@@ -11311,7 +11290,7 @@
11311
11290
  }
11312
11291
  classRegistry.setClass(LayoutManager, LAYOUT_MANAGER);
11313
11292
 
11314
- const _excluded$e = ["type", "objects", "layoutManager"];
11293
+ const _excluded$a = ["type", "objects", "layoutManager"];
11315
11294
  /**
11316
11295
  * 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.
11317
11296
  * We could have used a boolean in the constructor, as we did previously, but we think the boolean
@@ -11378,6 +11357,15 @@
11378
11357
  _defineProperty(this, "__objectSelectionDisposer", void 0);
11379
11358
  Object.assign(this, Group.ownDefaults);
11380
11359
  this.setOptions(options);
11360
+ this.groupInit(objects, options);
11361
+ }
11362
+
11363
+ /**
11364
+ * Shared code between group and active selection
11365
+ * Meant to be used by the constructor.
11366
+ */
11367
+ groupInit(objects, options) {
11368
+ var _options$layoutManage;
11381
11369
  this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller
11382
11370
 
11383
11371
  this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(this, true);
@@ -11387,7 +11375,7 @@
11387
11375
  });
11388
11376
 
11389
11377
  // perform initial layout
11390
- this.layoutManager = options.layoutManager || new LayoutManager();
11378
+ this.layoutManager = (_options$layoutManage = options.layoutManager) !== null && _options$layoutManage !== void 0 ? _options$layoutManage : new LayoutManager();
11391
11379
  this.layoutManager.performLayout({
11392
11380
  type: LAYOUT_TYPE_INITIALIZATION,
11393
11381
  target: this,
@@ -11859,7 +11847,7 @@
11859
11847
  objects = [],
11860
11848
  layoutManager
11861
11849
  } = _ref2,
11862
- options = _objectWithoutProperties(_ref2, _excluded$e);
11850
+ options = _objectWithoutProperties(_ref2, _excluded$a);
11863
11851
  return Promise.all([enlivenObjects(objects, abortable), enlivenObjectEnlivables(options, abortable)]).then(_ref3 => {
11864
11852
  let [objects, hydratedOptions] = _ref3;
11865
11853
  const group = new this(objects, _objectSpread2(_objectSpread2(_objectSpread2({}, options), hydratedOptions), {}, {
@@ -14015,8 +14003,8 @@
14015
14003
  this._activeObject = object;
14016
14004
  if (isActiveSelection(object) && prevActiveObject !== object) {
14017
14005
  object.set('canvas', this);
14018
- object.setCoords();
14019
14006
  }
14007
+ object.setCoords();
14020
14008
  return true;
14021
14009
  }
14022
14010
 
@@ -14269,7 +14257,7 @@
14269
14257
  }
14270
14258
  }
14271
14259
 
14272
- const _excluded$d = ["target", "oldTarget", "fireCanvas", "e"];
14260
+ const _excluded$9 = ["target", "oldTarget", "fireCanvas", "e"];
14273
14261
  const addEventOptions = {
14274
14262
  passive: false
14275
14263
  };
@@ -15283,7 +15271,7 @@
15283
15271
  fireCanvas,
15284
15272
  e
15285
15273
  } = _ref,
15286
- data = _objectWithoutProperties(_ref, _excluded$d);
15274
+ data = _objectWithoutProperties(_ref, _excluded$9);
15287
15275
  const {
15288
15276
  targetIn,
15289
15277
  targetOut,
@@ -15342,16 +15330,15 @@
15342
15330
  * @private
15343
15331
  */
15344
15332
  _performTransformAction(e, transform, pointer) {
15345
- const x = pointer.x,
15346
- y = pointer.y,
15347
- action = transform.action,
15348
- actionHandler = transform.actionHandler;
15349
- let actionPerformed = false;
15350
- // this object could be created from the function in the control handlers
15333
+ const {
15334
+ action,
15335
+ actionHandler,
15336
+ target
15337
+ } = transform;
15338
+ const actionPerformed = !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);
15339
+ actionPerformed && target.setCoords();
15351
15340
 
15352
- if (actionHandler) {
15353
- actionPerformed = actionHandler(e, transform, x, y);
15354
- }
15341
+ // this object could be created from the function in the control handlers
15355
15342
  if (action === 'drag' && actionPerformed) {
15356
15343
  transform.target.isMoving = true;
15357
15344
  this.setCursor(transform.target.moveCursor || this.moveCursor);
@@ -15978,7 +15965,7 @@
15978
15965
  classRegistry.setClass(Gradient, 'linear');
15979
15966
  classRegistry.setClass(Gradient, 'radial');
15980
15967
 
15981
- const _excluded$c = ["type", "source"];
15968
+ const _excluded$8 = ["type", "source"];
15982
15969
 
15983
15970
  /**
15984
15971
  * @see {@link http://fabricjs.com/patterns demo}
@@ -16136,7 +16123,7 @@
16136
16123
  type,
16137
16124
  source
16138
16125
  } = _ref2,
16139
- serialized = _objectWithoutProperties(_ref2, _excluded$c);
16126
+ serialized = _objectWithoutProperties(_ref2, _excluded$8);
16140
16127
  const img = await loadImage(source, _objectSpread2(_objectSpread2({}, options), {}, {
16141
16128
  crossOrigin: serialized.crossOrigin
16142
16129
  }));
@@ -16283,7 +16270,7 @@
16283
16270
  }
16284
16271
  }
16285
16272
 
16286
- const _excluded$b = ["path", "left", "top"],
16273
+ const _excluded$7 = ["path", "left", "top"],
16287
16274
  _excluded2$2 = ["d"];
16288
16275
  class Path extends FabricObject {
16289
16276
  /**
@@ -16299,7 +16286,7 @@
16299
16286
  left,
16300
16287
  top
16301
16288
  } = _ref,
16302
- options = _objectWithoutProperties(_ref, _excluded$b);
16289
+ options = _objectWithoutProperties(_ref, _excluded$7);
16303
16290
  super();
16304
16291
  Object.assign(this, Path.ownDefaults);
16305
16292
  this.setOptions(options);
@@ -16435,7 +16422,7 @@
16435
16422
  toClipPathSVG(reviver) {
16436
16423
  const additionalTransform = this._getOffsetTransform();
16437
16424
  return '\t' + this._createBaseClipPathSVGMarkup(this._toSVG(), {
16438
- reviver: reviver,
16425
+ reviver,
16439
16426
  additionalTransform: additionalTransform
16440
16427
  });
16441
16428
  }
@@ -16448,7 +16435,7 @@
16448
16435
  toSVG(reviver) {
16449
16436
  const additionalTransform = this._getOffsetTransform();
16450
16437
  return this._createBaseSVGMarkup(this._toSVG(), {
16451
- reviver: reviver,
16438
+ reviver,
16452
16439
  additionalTransform: additionalTransform
16453
16440
  });
16454
16441
  }
@@ -16871,7 +16858,7 @@
16871
16858
  }
16872
16859
  }
16873
16860
 
16874
- const _excluded$a = ["left", "top", "radius"];
16861
+ const _excluded$6 = ["left", "top", "radius"];
16875
16862
  const CIRCLE_PROPS = ['radius', 'startAngle', 'endAngle', 'counterClockwise'];
16876
16863
  const circleDefaultValues = {
16877
16864
  radius: 0,
@@ -17005,7 +16992,7 @@
17005
16992
  top = 0,
17006
16993
  radius = 0
17007
16994
  } = _ref,
17008
- otherParsedAttributes = _objectWithoutProperties(_ref, _excluded$a);
16995
+ otherParsedAttributes = _objectWithoutProperties(_ref, _excluded$6);
17009
16996
 
17010
16997
  // this probably requires to be fixed for default origins not being top/left.
17011
16998
 
@@ -17388,7 +17375,7 @@
17388
17375
  }
17389
17376
  }
17390
17377
 
17391
- const _excluded$9 = ["x1", "y1", "x2", "y2"],
17378
+ const _excluded$5 = ["x1", "y1", "x2", "y2"],
17392
17379
  _excluded2$1 = ["x1", "y1", "x2", "y2"];
17393
17380
  // @TODO this code is terrible and Line should be a special case of polyline.
17394
17381
 
@@ -17600,7 +17587,7 @@
17600
17587
  x2 = 0,
17601
17588
  y2 = 0
17602
17589
  } = _parseAttributes,
17603
- parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$9);
17590
+ parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$5);
17604
17591
  return new this([x1, y1, x2, y2], parsedAttributes);
17605
17592
  }
17606
17593
 
@@ -17866,7 +17853,7 @@
17866
17853
  return parsedPoints;
17867
17854
  }
17868
17855
 
17869
- const _excluded$8 = ["left", "top"];
17856
+ const _excluded$4 = ["left", "top"];
17870
17857
  const polylineDefaultValues = {
17871
17858
  /**
17872
17859
  * @deprecated transient option soon to be removed in favor of a different design
@@ -18149,7 +18136,7 @@
18149
18136
  static async fromElement(element, options, cssRules) {
18150
18137
  const points = parsePointsAttribute(element.getAttribute('points')),
18151
18138
  _parseAttributes = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules),
18152
- parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$8);
18139
+ parsedAttributes = _objectWithoutProperties(_parseAttributes, _excluded$4);
18153
18140
  return new this(points, _objectSpread2(_objectSpread2({}, parsedAttributes), options));
18154
18141
  }
18155
18142
 
@@ -18741,7 +18728,7 @@
18741
18728
  }
18742
18729
  }
18743
18730
 
18744
- const _excluded$7 = ["textAnchor", "textDecoration", "dx", "dy", "top", "left", "fontSize", "strokeWidth"];
18731
+ const _excluded$3 = ["textAnchor", "textDecoration", "dx", "dy", "top", "left", "fontSize", "strokeWidth"];
18745
18732
  let measuringContext;
18746
18733
 
18747
18734
  /**
@@ -19945,7 +19932,7 @@
19945
19932
  fontSize = DEFAULT_SVG_FONT_SIZE,
19946
19933
  strokeWidth = 1
19947
19934
  } = _options$parsedAttrib,
19948
- restOfOptions = _objectWithoutProperties(_options$parsedAttrib, _excluded$7);
19935
+ restOfOptions = _objectWithoutProperties(_options$parsedAttrib, _excluded$3);
19949
19936
  const textContent = (element.textContent || '').replace(/^\s+|\s+$|\n+/g, '').replace(/\s+/g, ' ');
19950
19937
 
19951
19938
  // this code here is probably the usual issue for SVG center find
@@ -23312,7 +23299,6 @@
23312
23299
  }
23313
23300
  }
23314
23301
 
23315
- const _excluded$6 = ["layoutManager"];
23316
23302
  const activeSelectionDefaultValues = {
23317
23303
  multiSelectionStacking: 'canvas-stacking'
23318
23304
  };
@@ -23348,16 +23334,20 @@
23348
23334
 
23349
23335
  constructor() {
23350
23336
  let objects = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
23351
- let _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
23352
- {
23353
- layoutManager
23354
- } = _ref,
23355
- options = _objectWithoutProperties(_ref, _excluded$6);
23356
- super(objects, {
23357
- layoutManager: layoutManager !== null && layoutManager !== void 0 ? layoutManager : new ActiveSelectionLayoutManager()
23358
- });
23337
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
23338
+ super();
23359
23339
  Object.assign(this, ActiveSelection.ownDefaults);
23360
23340
  this.setOptions(options);
23341
+ const {
23342
+ left,
23343
+ top,
23344
+ layoutManager
23345
+ } = options;
23346
+ this.groupInit(objects, {
23347
+ left,
23348
+ top,
23349
+ layoutManager: layoutManager !== null && layoutManager !== void 0 ? layoutManager : new ActiveSelectionLayoutManager()
23350
+ });
23361
23351
  }
23362
23352
 
23363
23353
  /**
@@ -23937,7 +23927,7 @@
23937
23927
  filterBackend = backend;
23938
23928
  }
23939
23929
 
23940
- const _excluded$5 = ["filters", "resizeFilter", "src", "crossOrigin", "type"];
23930
+ const _excluded$2 = ["filters", "resizeFilter", "src", "crossOrigin", "type"];
23941
23931
 
23942
23932
  // @todo Would be nice to have filtering code not imported directly.
23943
23933
 
@@ -24520,7 +24510,7 @@
24520
24510
  crossOrigin,
24521
24511
  type
24522
24512
  } = _ref,
24523
- object = _objectWithoutProperties(_ref, _excluded$5);
24513
+ object = _objectWithoutProperties(_ref, _excluded$2);
24524
24514
  return Promise.all([loadImage(src, _objectSpread2(_objectSpread2({}, options), {}, {
24525
24515
  crossOrigin
24526
24516
  })), f && enlivenObjects(f, options),
@@ -25290,9 +25280,9 @@
25290
25280
 
25291
25281
  const highPsourceCode = "precision highp float";
25292
25282
  const identityFragmentShader = "\n ".concat(highPsourceCode, ";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }");
25293
- 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 }";
25283
+ 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 }";
25294
25284
 
25295
- const _excluded$4 = ["type"],
25285
+ const _excluded$1 = ["type"],
25296
25286
  _excluded2 = ["type"];
25297
25287
  const regex = new RegExp(highPsourceCode, 'g');
25298
25288
  class BaseFilter {
@@ -25313,30 +25303,21 @@
25313
25303
  * to avoid doing that.
25314
25304
  */
25315
25305
 
25316
- /**
25317
- * Name of the parameter that can be changed in the filter.
25318
- * Some filters have more than one parameter and there is no
25319
- * mainParameter
25320
- * @private
25321
- */
25322
-
25323
25306
  /**
25324
25307
  * Constructor
25325
25308
  * @param {Object} [options] Options object
25326
25309
  */
25327
25310
  constructor() {
25328
25311
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
25329
- options = _objectWithoutProperties(_ref, _excluded$4);
25330
- /**
25331
- * Array of attributes to send with buffers. do not modify
25332
- * @private
25333
- */
25334
- _defineProperty(this, "vertexSource", vertexSource);
25312
+ options = _objectWithoutProperties(_ref, _excluded$1);
25335
25313
  Object.assign(this, this.constructor.defaults, options);
25336
25314
  }
25337
25315
  getFragmentSource() {
25338
25316
  return identityFragmentShader;
25339
25317
  }
25318
+ getVertexSource() {
25319
+ return vertexSource$1;
25320
+ }
25340
25321
 
25341
25322
  /**
25342
25323
  * Compile this filter's shader program.
@@ -25347,7 +25328,7 @@
25347
25328
  */
25348
25329
  createProgram(gl) {
25349
25330
  let fragmentSource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFragmentSource();
25350
- let vertexSource = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.vertexSource;
25331
+ let vertexSource = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getVertexSource();
25351
25332
  const {
25352
25333
  WebGLProbe: {
25353
25334
  GLPrecision = 'highp'
@@ -25404,14 +25385,17 @@
25404
25385
  /**
25405
25386
  * Return a map of uniform names to WebGLUniformLocation objects.
25406
25387
  *
25407
- * Intended to be overridden by subclasses.
25408
- *
25409
25388
  * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.
25410
25389
  * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.
25411
25390
  * @returns {Object} A map of uniform names to uniform locations.
25412
25391
  */
25413
25392
  getUniformLocations(gl, program) {
25414
- return {};
25393
+ const locations = this.constructor.uniformLocations;
25394
+ const uniformLocations = {};
25395
+ for (let i = 0; i < locations.length; i++) {
25396
+ uniformLocations[locations[i]] = gl.getUniformLocation(program, locations[i]);
25397
+ }
25398
+ return uniformLocations;
25415
25399
  }
25416
25400
 
25417
25401
  /**
@@ -25461,18 +25445,7 @@
25461
25445
  **/
25462
25446
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
25463
25447
  isNeutralState(options) {
25464
- const main = this.mainParameter,
25465
- defaultValue = this.constructor.defaults[main];
25466
- if (main) {
25467
- const thisValue = this[main];
25468
- if (Array.isArray(defaultValue) && Array.isArray(thisValue)) {
25469
- return defaultValue.every((value, i) => value === thisValue[i]);
25470
- } else {
25471
- return defaultValue === thisValue;
25472
- }
25473
- } else {
25474
- return false;
25475
- }
25448
+ return false;
25476
25449
  }
25477
25450
 
25478
25451
  /**
@@ -25564,14 +25537,6 @@
25564
25537
  gl.bindTexture(gl.TEXTURE_2D, null);
25565
25538
  gl.activeTexture(gl.TEXTURE0);
25566
25539
  }
25567
- getMainParameter() {
25568
- return this.mainParameter ? this[this.mainParameter] : undefined;
25569
- }
25570
- setMainParameter(value) {
25571
- if (this.mainParameter) {
25572
- this[this.mainParameter] = value;
25573
- }
25574
- }
25575
25540
 
25576
25541
  /**
25577
25542
  * Send uniform data from this filter to its shader program on the GPU.
@@ -25603,12 +25568,14 @@
25603
25568
  * @return {Object} Object representation of an instance
25604
25569
  */
25605
25570
  toObject() {
25606
- const mainP = this.mainParameter;
25571
+ const defaultKeys = Object.keys(this.constructor.defaults);
25607
25572
  return _objectSpread2({
25608
25573
  type: this.type
25609
- }, mainP ? {
25610
- [mainP]: this[mainP]
25611
- } : {});
25574
+ }, defaultKeys.reduce((acc, key) => {
25575
+ //@ts-expect-error TS doesn't get i want an object that looks like this
25576
+ acc[key] = this[key];
25577
+ return acc;
25578
+ }, {}));
25612
25579
  }
25613
25580
 
25614
25581
  /**
@@ -25625,6 +25592,12 @@
25625
25592
  }
25626
25593
  }
25627
25594
  _defineProperty(BaseFilter, "type", 'BaseFilter');
25595
+ /**
25596
+ * Contains the uniform locations for the fragment shader.
25597
+ * uStepW and uStepH are handled by the BaseFilter, each filter class
25598
+ * needs to specify all the one that are needed
25599
+ */
25600
+ _defineProperty(BaseFilter, "uniformLocations", []);
25628
25601
 
25629
25602
  const blendColorFragmentSource = {
25630
25603
  multiply: 'gl_FragColor.rgb *= uColor.rgb;\n',
@@ -25744,18 +25717,6 @@
25744
25717
  }
25745
25718
  }
25746
25719
 
25747
- /**
25748
- * Return WebGL uniform locations for this filter's shader.
25749
- *
25750
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
25751
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
25752
- */
25753
- getUniformLocations(gl, program) {
25754
- return {
25755
- uColor: gl.getUniformLocation(program, 'uColor')
25756
- };
25757
- }
25758
-
25759
25720
  /**
25760
25721
  * Send data from this filter to its shader program's uniforms.
25761
25722
  *
@@ -25770,19 +25731,6 @@
25770
25731
  source[3] = this.alpha;
25771
25732
  gl.uniform4fv(uniformLocations.uColor, source);
25772
25733
  }
25773
-
25774
- /**
25775
- * Returns object representation of an instance
25776
- * @return {Object} Object representation of an instance
25777
- */
25778
- toObject() {
25779
- return {
25780
- type: this.type,
25781
- color: this.color,
25782
- mode: this.mode,
25783
- alpha: this.alpha
25784
- };
25785
- }
25786
25734
  }
25787
25735
  /**
25788
25736
  * Color to make the blend operation with. default to a reddish color since black or white
@@ -25803,18 +25751,19 @@
25803
25751
  **/
25804
25752
  _defineProperty(BlendColor, "defaults", blendColorDefaultValues);
25805
25753
  _defineProperty(BlendColor, "type", 'BlendColor');
25754
+ _defineProperty(BlendColor, "uniformLocations", ['uColor']);
25806
25755
  classRegistry.setClass(BlendColor);
25807
25756
 
25808
25757
  const fragmentSource$c = {
25809
25758
  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 ",
25810
25759
  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 "
25811
25760
  };
25761
+ 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 ";
25812
25762
 
25813
- const _excluded$3 = ["type", "image"];
25763
+ const _excluded = ["type", "image"];
25814
25764
  const blendImageDefaultValues = {
25815
25765
  mode: 'multiply',
25816
- alpha: 1,
25817
- 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 "
25766
+ alpha: 1
25818
25767
  };
25819
25768
 
25820
25769
  /**
@@ -25840,6 +25789,9 @@
25840
25789
  getFragmentSource() {
25841
25790
  return fragmentSource$c[this.mode];
25842
25791
  }
25792
+ getVertexSource() {
25793
+ return vertexSource;
25794
+ }
25843
25795
  applyToWebGL(options) {
25844
25796
  const gl = options.context,
25845
25797
  texture = this.createTexture(options.filterBackend, this.image);
@@ -25921,19 +25873,6 @@
25921
25873
  }
25922
25874
  }
25923
25875
 
25924
- /**
25925
- * Return WebGL uniform locations for this filter's shader.
25926
- *
25927
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
25928
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
25929
- */
25930
- getUniformLocations(gl, program) {
25931
- return {
25932
- uTransformMatrix: gl.getUniformLocation(program, 'uTransformMatrix'),
25933
- uImage: gl.getUniformLocation(program, 'uImage')
25934
- };
25935
- }
25936
-
25937
25876
  /**
25938
25877
  * Send data from this filter to its shader program's uniforms.
25939
25878
  *
@@ -25948,15 +25887,14 @@
25948
25887
 
25949
25888
  /**
25950
25889
  * Returns object representation of an instance
25890
+ * TODO: Handle the possibility of missing image better.
25891
+ * As of now a BlendImage filter without image can't be used with fromObject
25951
25892
  * @return {Object} Object representation of an instance
25952
25893
  */
25953
25894
  toObject() {
25954
- return {
25955
- type: this.type,
25956
- image: this.image && this.image.toObject(),
25957
- mode: this.mode,
25958
- alpha: this.alpha
25959
- };
25895
+ return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
25896
+ image: this.image && this.image.toObject()
25897
+ });
25960
25898
  }
25961
25899
 
25962
25900
  /**
@@ -25967,12 +25905,12 @@
25967
25905
  * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
25968
25906
  * @returns {Promise<BlendImage>}
25969
25907
  */
25970
- static fromObject(_ref2, options) {
25908
+ static async fromObject(_ref2, options) {
25971
25909
  let {
25972
25910
  type,
25973
25911
  image
25974
25912
  } = _ref2,
25975
- filterOptions = _objectWithoutProperties(_ref2, _excluded$3);
25913
+ filterOptions = _objectWithoutProperties(_ref2, _excluded);
25976
25914
  return FabricImage.fromObject(image, options).then(enlivedImage => new this(_objectSpread2(_objectSpread2({}, filterOptions), {}, {
25977
25915
  image: enlivedImage
25978
25916
  })));
@@ -25996,13 +25934,13 @@
25996
25934
  **/
25997
25935
  _defineProperty(BlendImage, "type", 'BlendImage');
25998
25936
  _defineProperty(BlendImage, "defaults", blendImageDefaultValues);
25937
+ _defineProperty(BlendImage, "uniformLocations", ['uTransformMatrix', 'uImage']);
25999
25938
  classRegistry.setClass(BlendImage);
26000
25939
 
26001
25940
  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 ";
26002
25941
 
26003
25942
  const blurDefaultValues = {
26004
- blur: 0,
26005
- mainParameter: 'blur'
25943
+ blur: 0
26006
25944
  };
26007
25945
 
26008
25946
  /**
@@ -26097,18 +26035,6 @@
26097
26035
  return newImageData;
26098
26036
  }
26099
26037
 
26100
- /**
26101
- * Return WebGL uniform locations for this filter's shader.
26102
- *
26103
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26104
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26105
- */
26106
- getUniformLocations(gl, program) {
26107
- return {
26108
- delta: gl.getUniformLocation(program, 'uDelta')
26109
- };
26110
- }
26111
-
26112
26038
  /**
26113
26039
  * Send data from this filter to its shader program's uniforms.
26114
26040
  *
@@ -26119,6 +26045,9 @@
26119
26045
  const delta = this.chooseRightDelta();
26120
26046
  gl.uniform2fv(uniformLocations.delta, delta);
26121
26047
  }
26048
+ isNeutralState() {
26049
+ return this.blur === 0;
26050
+ }
26122
26051
 
26123
26052
  /**
26124
26053
  * choose right value of image percentage to blur with
@@ -26156,13 +26085,13 @@
26156
26085
  */
26157
26086
  _defineProperty(Blur, "type", 'Blur');
26158
26087
  _defineProperty(Blur, "defaults", blurDefaultValues);
26088
+ _defineProperty(Blur, "uniformLocations", ['uDelta']);
26159
26089
  classRegistry.setClass(Blur);
26160
26090
 
26161
26091
  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";
26162
26092
 
26163
26093
  const brightnessDefaultValues = {
26164
- brightness: 0,
26165
- mainParameter: 'brightness'
26094
+ brightness: 0
26166
26095
  };
26167
26096
 
26168
26097
  /**
@@ -26191,9 +26120,6 @@
26191
26120
  data
26192
26121
  }
26193
26122
  } = _ref;
26194
- if (this.brightness === 0) {
26195
- return;
26196
- }
26197
26123
  const brightness = Math.round(this.brightness * 255);
26198
26124
  for (let i = 0; i < data.length; i += 4) {
26199
26125
  data[i] = data[i] + brightness;
@@ -26201,17 +26127,8 @@
26201
26127
  data[i + 2] = data[i + 2] + brightness;
26202
26128
  }
26203
26129
  }
26204
-
26205
- /**
26206
- * Return WebGL uniform locations for this filter's shader.
26207
- *
26208
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26209
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26210
- */
26211
- getUniformLocations(gl, program) {
26212
- return {
26213
- uBrightness: gl.getUniformLocation(program, 'uBrightness')
26214
- };
26130
+ isNeutralState() {
26131
+ return this.brightness === 0;
26215
26132
  }
26216
26133
 
26217
26134
  /**
@@ -26233,14 +26150,13 @@
26233
26150
  */
26234
26151
  _defineProperty(Brightness, "type", 'Brightness');
26235
26152
  _defineProperty(Brightness, "defaults", brightnessDefaultValues);
26153
+ _defineProperty(Brightness, "uniformLocations", ['uBrightness']);
26236
26154
  classRegistry.setClass(Brightness);
26237
26155
 
26238
26156
  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 }";
26239
26157
 
26240
- const _excluded$2 = ["matrix"];
26241
26158
  const colorMatrixDefaultValues = {
26242
26159
  matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
26243
- mainParameter: 'matrix',
26244
26160
  colorsOnly: true
26245
26161
  };
26246
26162
 
@@ -26261,17 +26177,6 @@
26261
26177
  * object.applyFilters();
26262
26178
  */
26263
26179
  class ColorMatrix extends BaseFilter {
26264
- setOptions(_ref) {
26265
- let {
26266
- matrix
26267
- } = _ref,
26268
- options = _objectWithoutProperties(_ref, _excluded$2);
26269
- if (matrix) {
26270
- // safeguard against mutation
26271
- this.matrix = [...matrix];
26272
- }
26273
- Object.assign(this, options);
26274
- }
26275
26180
  getFragmentSource() {
26276
26181
  return fragmentSource$9;
26277
26182
  }
@@ -26305,19 +26210,6 @@
26305
26210
  }
26306
26211
  }
26307
26212
 
26308
- /**
26309
- * Return WebGL uniform locations for this filter's shader.
26310
- *
26311
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26312
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26313
- */
26314
- getUniformLocations(gl, program) {
26315
- return {
26316
- uColorMatrix: gl.getUniformLocation(program, 'uColorMatrix'),
26317
- uConstants: gl.getUniformLocation(program, 'uConstants')
26318
- };
26319
- }
26320
-
26321
26213
  /**
26322
26214
  * Send data from this filter to its shader program's uniforms.
26323
26215
  *
@@ -26331,6 +26223,11 @@
26331
26223
  gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);
26332
26224
  gl.uniform4fv(uniformLocations.uConstants, constants);
26333
26225
  }
26226
+ toObject() {
26227
+ return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
26228
+ matrix: [...this.matrix]
26229
+ });
26230
+ }
26334
26231
  }
26335
26232
  /**
26336
26233
  * Colormatrix for pixels.
@@ -26348,17 +26245,23 @@
26348
26245
  */
26349
26246
  _defineProperty(ColorMatrix, "type", 'ColorMatrix');
26350
26247
  _defineProperty(ColorMatrix, "defaults", colorMatrixDefaultValues);
26248
+ _defineProperty(ColorMatrix, "uniformLocations", ['uColorMatrix', 'uConstants']);
26351
26249
  classRegistry.setClass(ColorMatrix);
26352
26250
 
26353
26251
  function createColorMatrixFilter(key, matrix) {
26354
26252
  var _class;
26355
- const newClass = (_class = class newClass extends ColorMatrix {}, _defineProperty(_class, "type", key), _defineProperty(_class, "defaults", _objectSpread2(_objectSpread2({}, colorMatrixDefaultValues), {}, {
26356
- /**
26357
- * Lock the matrix export for this kind of static, parameter less filters.
26358
- */
26359
- mainParameter: undefined,
26253
+ const newClass = (_class = class newClass extends ColorMatrix {
26254
+ //@ts-expect-error TS wants matrix to be exported.
26255
+ toObject() {
26256
+ return {
26257
+ type: this.type,
26258
+ colorsOnly: this.colorsOnly
26259
+ };
26260
+ }
26261
+ }, _defineProperty(_class, "type", key), _defineProperty(_class, "defaults", {
26262
+ colorsOnly: false,
26360
26263
  matrix
26361
- })), _class);
26264
+ }), _class);
26362
26265
  classRegistry.setClass(newClass, key);
26363
26266
  return newClass;
26364
26267
  }
@@ -26370,20 +26273,14 @@
26370
26273
  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]);
26371
26274
  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]);
26372
26275
 
26373
- const _excluded$1 = ["subFilters"];
26374
-
26375
26276
  /**
26376
26277
  * A container class that knows how to apply a sequence of filters to an input image.
26377
26278
  */
26378
26279
  class Composed extends BaseFilter {
26379
26280
  constructor() {
26380
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
26381
- {
26382
- subFilters = []
26383
- } = _ref,
26384
- options = _objectWithoutProperties(_ref, _excluded$1);
26281
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26385
26282
  super(options);
26386
- this.subFilters = subFilters;
26283
+ this.subFilters = options.subFilters || [];
26387
26284
  }
26388
26285
 
26389
26286
  /**
@@ -26403,13 +26300,14 @@
26403
26300
 
26404
26301
  /**
26405
26302
  * Serialize this filter into JSON.
26406
- *
26407
26303
  * @returns {Object} A JSON representation of this filter.
26408
26304
  */
26305
+ //@ts-expect-error TS doesn't like this toObject
26409
26306
  toObject() {
26410
- return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
26307
+ return {
26308
+ type: this.type,
26411
26309
  subFilters: this.subFilters.map(filter => filter.toObject())
26412
- });
26310
+ };
26413
26311
  }
26414
26312
  isNeutralState() {
26415
26313
  return !this.subFilters.some(filter => !filter.isNeutralState());
@@ -26438,8 +26336,7 @@
26438
26336
  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 }";
26439
26337
 
26440
26338
  const contrastDefaultValues = {
26441
- contrast: 0,
26442
- mainParameter: 'contrast'
26339
+ contrast: 0
26443
26340
  };
26444
26341
 
26445
26342
  /**
@@ -26455,6 +26352,10 @@
26455
26352
  getFragmentSource() {
26456
26353
  return fragmentSource$8;
26457
26354
  }
26355
+ isNeutralState() {
26356
+ return this.contrast === 0;
26357
+ }
26358
+
26458
26359
  /**
26459
26360
  * Apply the Contrast operation to a Uint8Array representing the pixels of an image.
26460
26361
  *
@@ -26467,9 +26368,6 @@
26467
26368
  data
26468
26369
  }
26469
26370
  } = _ref;
26470
- if (this.contrast === 0) {
26471
- return;
26472
- }
26473
26371
  const contrast = Math.floor(this.contrast * 255),
26474
26372
  contrastF = 259 * (contrast + 255) / (255 * (259 - contrast));
26475
26373
  for (let i = 0; i < data.length; i += 4) {
@@ -26479,18 +26377,6 @@
26479
26377
  }
26480
26378
  }
26481
26379
 
26482
- /**
26483
- * Return WebGL uniform locations for this filter's shader.
26484
- *
26485
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26486
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26487
- */
26488
- getUniformLocations(gl, program) {
26489
- return {
26490
- uContrast: gl.getUniformLocation(program, 'uContrast')
26491
- };
26492
- }
26493
-
26494
26380
  /**
26495
26381
  * Send data from this filter to its shader program's uniforms.
26496
26382
  *
@@ -26508,6 +26394,7 @@
26508
26394
  */
26509
26395
  _defineProperty(Contrast, "type", 'Contrast');
26510
26396
  _defineProperty(Contrast, "defaults", contrastDefaultValues);
26397
+ _defineProperty(Contrast, "uniformLocations", ['uContrast']);
26511
26398
  classRegistry.setClass(Contrast);
26512
26399
 
26513
26400
  const fragmentSource$7 = {
@@ -26635,21 +26522,6 @@
26635
26522
  options.imageData = output;
26636
26523
  }
26637
26524
 
26638
- /**
26639
- * Return WebGL uniform locations for this filter's shader.
26640
- *
26641
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26642
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26643
- */
26644
- getUniformLocations(gl, program) {
26645
- return {
26646
- uMatrix: gl.getUniformLocation(program, 'uMatrix'),
26647
- uOpaque: gl.getUniformLocation(program, 'uOpaque'),
26648
- uHalfSize: gl.getUniformLocation(program, 'uHalfSize'),
26649
- uSize: gl.getUniformLocation(program, 'uSize')
26650
- };
26651
- }
26652
-
26653
26525
  /**
26654
26526
  * Send data from this filter to its shader program's uniforms.
26655
26527
  *
@@ -26679,13 +26551,13 @@
26679
26551
  */
26680
26552
  _defineProperty(Convolute, "type", 'Convolute');
26681
26553
  _defineProperty(Convolute, "defaults", convoluteDefaultValues);
26554
+ _defineProperty(Convolute, "uniformLocations", ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize']);
26682
26555
  classRegistry.setClass(Convolute);
26683
26556
 
26684
26557
  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";
26685
26558
 
26686
- const _excluded = ["gamma"];
26559
+ const GAMMA = 'Gamma';
26687
26560
  const gammaDefaultValues = {
26688
- mainParameter: 'gamma',
26689
26561
  gamma: [1, 1, 1]
26690
26562
  };
26691
26563
 
@@ -26703,13 +26575,9 @@
26703
26575
  return fragmentSource$6;
26704
26576
  }
26705
26577
  constructor() {
26706
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
26707
- {
26708
- gamma = [1, 1, 1]
26709
- } = _ref,
26710
- options = _objectWithoutProperties(_ref, _excluded);
26578
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26711
26579
  super(options);
26712
- this.gamma = gamma;
26580
+ this.gamma = options.gamma || this.constructor.defaults.gamma.concat();
26713
26581
  }
26714
26582
 
26715
26583
  /**
@@ -26718,12 +26586,12 @@
26718
26586
  * @param {Object} options
26719
26587
  * @param {ImageData} options.imageData The Uint8Array to be filtered.
26720
26588
  */
26721
- applyTo2d(_ref2) {
26589
+ applyTo2d(_ref) {
26722
26590
  let {
26723
26591
  imageData: {
26724
26592
  data
26725
26593
  }
26726
- } = _ref2;
26594
+ } = _ref;
26727
26595
  const gamma = this.gamma,
26728
26596
  rInv = 1 / gamma[0],
26729
26597
  gInv = 1 / gamma[1],
@@ -26751,18 +26619,6 @@
26751
26619
  }
26752
26620
  }
26753
26621
 
26754
- /**
26755
- * Return WebGL uniform locations for this filter's shader.
26756
- *
26757
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26758
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26759
- */
26760
- getUniformLocations(gl, program) {
26761
- return {
26762
- uGamma: gl.getUniformLocation(program, 'uGamma')
26763
- };
26764
- }
26765
-
26766
26622
  /**
26767
26623
  * Send data from this filter to its shader program's uniforms.
26768
26624
  *
@@ -26772,14 +26628,27 @@
26772
26628
  sendUniformData(gl, uniformLocations) {
26773
26629
  gl.uniform3fv(uniformLocations.uGamma, this.gamma);
26774
26630
  }
26631
+ isNeutralState() {
26632
+ const {
26633
+ gamma
26634
+ } = this;
26635
+ return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;
26636
+ }
26637
+ toObject() {
26638
+ return {
26639
+ type: GAMMA,
26640
+ gamma: this.gamma.concat()
26641
+ };
26642
+ }
26775
26643
  }
26776
26644
  /**
26777
26645
  * Gamma array value, from 0.01 to 2.2.
26778
26646
  * @param {Array} gamma
26779
26647
  * @default
26780
26648
  */
26781
- _defineProperty(Gamma, "type", 'Gamma');
26649
+ _defineProperty(Gamma, "type", GAMMA);
26782
26650
  _defineProperty(Gamma, "defaults", gammaDefaultValues);
26651
+ _defineProperty(Gamma, "uniformLocations", ['uGamma']);
26783
26652
  classRegistry.setClass(Gamma);
26784
26653
 
26785
26654
  const fragmentSource$5 = {
@@ -26789,8 +26658,7 @@
26789
26658
  };
26790
26659
 
26791
26660
  const grayscaleDefaultValues = {
26792
- mode: 'average',
26793
- mainParameter: 'mode'
26661
+ mode: 'average'
26794
26662
  };
26795
26663
 
26796
26664
  /**
@@ -26837,18 +26705,6 @@
26837
26705
  return fragmentSource$5[this.mode];
26838
26706
  }
26839
26707
 
26840
- /**
26841
- * Return WebGL uniform locations for this filter's shader.
26842
- *
26843
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26844
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26845
- */
26846
- getUniformLocations(gl, program) {
26847
- return {
26848
- uMode: gl.getUniformLocation(program, 'uMode')
26849
- };
26850
- }
26851
-
26852
26708
  /**
26853
26709
  * Send data from this filter to its shader program's uniforms.
26854
26710
  *
@@ -26871,11 +26727,11 @@
26871
26727
  }
26872
26728
  _defineProperty(Grayscale, "type", 'Grayscale');
26873
26729
  _defineProperty(Grayscale, "defaults", grayscaleDefaultValues);
26730
+ _defineProperty(Grayscale, "uniformLocations", ['uMode']);
26874
26731
  classRegistry.setClass(Grayscale);
26875
26732
 
26876
26733
  const hueRotationDefaultValues = {
26877
- rotation: 0,
26878
- mainParameter: 'rotation'
26734
+ rotation: 0
26879
26735
  };
26880
26736
 
26881
26737
  /**
@@ -26887,7 +26743,6 @@
26887
26743
  * object.filters.push(filter);
26888
26744
  * object.applyFilters();
26889
26745
  */
26890
- // @ts-expect-error some babbling about mainParameter
26891
26746
  class HueRotation extends ColorMatrix {
26892
26747
  calculateMatrix() {
26893
26748
  const rad = this.rotation * Math.PI,
@@ -26908,13 +26763,20 @@
26908
26763
  this.matrix[12] = cosine + aThird * OneMinusCos;
26909
26764
  }
26910
26765
  isNeutralState() {
26911
- this.calculateMatrix();
26912
- return super.isNeutralState();
26766
+ return this.rotation === 0;
26913
26767
  }
26914
26768
  applyTo(options) {
26915
26769
  this.calculateMatrix();
26916
26770
  super.applyTo(options);
26917
26771
  }
26772
+
26773
+ //@ts-expect-error TS and classes with different methods
26774
+ toObject() {
26775
+ return {
26776
+ type: this.type,
26777
+ rotation: this.rotation
26778
+ };
26779
+ }
26918
26780
  }
26919
26781
  /**
26920
26782
  * HueRotation value, from -1 to 1.
@@ -26927,8 +26789,7 @@
26927
26789
 
26928
26790
  const invertDefaultValues = {
26929
26791
  alpha: false,
26930
- invert: true,
26931
- mainParameter: 'invert'
26792
+ invert: true
26932
26793
  };
26933
26794
 
26934
26795
  /**
@@ -26973,19 +26834,6 @@
26973
26834
  return !this.invert;
26974
26835
  }
26975
26836
 
26976
- /**
26977
- * Return WebGL uniform locations for this filter's shader.
26978
- *
26979
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
26980
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
26981
- */
26982
- getUniformLocations(gl, program) {
26983
- return {
26984
- uInvert: gl.getUniformLocation(program, 'uInvert'),
26985
- uAlpha: gl.getUniformLocation(program, 'uAlpha')
26986
- };
26987
- }
26988
-
26989
26837
  /**
26990
26838
  * Send data from this filter to its shader program's uniforms.
26991
26839
  *
@@ -27009,12 +26857,12 @@
27009
26857
  */
27010
26858
  _defineProperty(Invert, "type", 'Invert');
27011
26859
  _defineProperty(Invert, "defaults", invertDefaultValues);
26860
+ _defineProperty(Invert, "uniformLocations", ['uInvert', 'uAlpha']);
27012
26861
  classRegistry.setClass(Invert);
27013
26862
 
27014
26863
  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";
27015
26864
 
27016
26865
  const noiseDefaultValues = {
27017
- mainParameter: 'noise',
27018
26866
  noise: 0
27019
26867
  };
27020
26868
 
@@ -27045,9 +26893,6 @@
27045
26893
  data
27046
26894
  }
27047
26895
  } = _ref;
27048
- if (this.noise === 0) {
27049
- return;
27050
- }
27051
26896
  const noise = this.noise;
27052
26897
  for (let i = 0; i < data.length; i += 4) {
27053
26898
  const rand = (0.5 - Math.random()) * noise;
@@ -27057,19 +26902,6 @@
27057
26902
  }
27058
26903
  }
27059
26904
 
27060
- /**
27061
- * Return WebGL uniform locations for this filter's shader.
27062
- *
27063
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27064
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27065
- */
27066
- getUniformLocations(gl, program) {
27067
- return {
27068
- uNoise: gl.getUniformLocation(program, 'uNoise'),
27069
- uSeed: gl.getUniformLocation(program, 'uSeed')
27070
- };
27071
- }
27072
-
27073
26905
  /**
27074
26906
  * Send data from this filter to its shader program's uniforms.
27075
26907
  *
@@ -27080,15 +26912,8 @@
27080
26912
  gl.uniform1f(uniformLocations.uNoise, this.noise / 255);
27081
26913
  gl.uniform1f(uniformLocations.uSeed, Math.random());
27082
26914
  }
27083
-
27084
- /**
27085
- * Returns object representation of an instance
27086
- * @return {Object} Object representation of an instance
27087
- */
27088
- toObject() {
27089
- return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
27090
- noise: this.noise
27091
- });
26915
+ isNeutralState() {
26916
+ return this.noise === 0;
27092
26917
  }
27093
26918
  }
27094
26919
  /**
@@ -27098,13 +26923,13 @@
27098
26923
  */
27099
26924
  _defineProperty(Noise, "type", 'Noise');
27100
26925
  _defineProperty(Noise, "defaults", noiseDefaultValues);
26926
+ _defineProperty(Noise, "uniformLocations", ['uNoise', 'uSeed']);
27101
26927
  classRegistry.setClass(Noise);
27102
26928
 
27103
26929
  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";
27104
26930
 
27105
26931
  const pixelateDefaultValues = {
27106
- blocksize: 4,
27107
- mainParameter: 'blocksize'
26932
+ blocksize: 4
27108
26933
  };
27109
26934
 
27110
26935
  /**
@@ -27161,20 +26986,6 @@
27161
26986
  return fragmentSource$2;
27162
26987
  }
27163
26988
 
27164
- /**
27165
- * Return WebGL uniform locations for this filter's shader.
27166
- *
27167
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27168
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27169
- */
27170
- getUniformLocations(gl, program) {
27171
- return {
27172
- uBlocksize: gl.getUniformLocation(program, 'uBlocksize'),
27173
- uStepW: gl.getUniformLocation(program, 'uStepW'),
27174
- uStepH: gl.getUniformLocation(program, 'uStepH')
27175
- };
27176
- }
27177
-
27178
26989
  /**
27179
26990
  * Send data from this filter to its shader program's uniforms.
27180
26991
  *
@@ -27187,6 +26998,7 @@
27187
26998
  }
27188
26999
  _defineProperty(Pixelate, "type", 'Pixelate');
27189
27000
  _defineProperty(Pixelate, "defaults", pixelateDefaultValues);
27001
+ _defineProperty(Pixelate, "uniformLocations", ['uBlockSize']);
27190
27002
  classRegistry.setClass(Pixelate);
27191
27003
 
27192
27004
  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";
@@ -27236,19 +27048,6 @@
27236
27048
  }
27237
27049
  }
27238
27050
 
27239
- /**
27240
- * Return WebGL uniform locations for this filter's shader.
27241
- *
27242
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27243
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27244
- */
27245
- getUniformLocations(gl, program) {
27246
- return {
27247
- uLow: gl.getUniformLocation(program, 'uLow'),
27248
- uHigh: gl.getUniformLocation(program, 'uHigh')
27249
- };
27250
- }
27251
-
27252
27051
  /**
27253
27052
  * Send data from this filter to its shader program's uniforms.
27254
27053
  *
@@ -27263,17 +27062,6 @@
27263
27062
  gl.uniform4fv(uniformLocations.uLow, lowC);
27264
27063
  gl.uniform4fv(uniformLocations.uHigh, highC);
27265
27064
  }
27266
-
27267
- /**
27268
- * Returns object representation of an instance
27269
- * @return {Object} Object representation of an instance
27270
- */
27271
- toObject() {
27272
- return _objectSpread2(_objectSpread2({}, super.toObject()), {}, {
27273
- color: this.color,
27274
- distance: this.distance
27275
- });
27276
- }
27277
27065
  }
27278
27066
  /**
27279
27067
  * Color to remove, in any format understood by {@link Color}.
@@ -27290,14 +27078,14 @@
27290
27078
  **/
27291
27079
  _defineProperty(RemoveColor, "type", 'RemoveColor');
27292
27080
  _defineProperty(RemoveColor, "defaults", removeColorDefaultValues);
27081
+ _defineProperty(RemoveColor, "uniformLocations", ['uLow', 'uHigh']);
27293
27082
  classRegistry.setClass(RemoveColor);
27294
27083
 
27295
27084
  const resizeDefaultValues = {
27296
27085
  resizeType: 'hermite',
27297
27086
  scaleX: 1,
27298
27087
  scaleY: 1,
27299
- lanczosLobes: 3,
27300
- fragmentSourceTOP: "\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n "
27088
+ lanczosLobes: 3
27301
27089
  };
27302
27090
  /**
27303
27091
  * Resize image filter class
@@ -27307,19 +27095,6 @@
27307
27095
  * object.applyFilters(canvas.renderAll.bind(canvas));
27308
27096
  */
27309
27097
  class Resize extends BaseFilter {
27310
- /**
27311
- * Return WebGL uniform locations for this filter's shader.
27312
- *
27313
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27314
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27315
- */
27316
- getUniformLocations(gl, program) {
27317
- return {
27318
- uDelta: gl.getUniformLocation(program, 'uDelta'),
27319
- uTaps: gl.getUniformLocation(program, 'uTaps')
27320
- };
27321
- }
27322
-
27323
27098
  /**
27324
27099
  * Send data from this filter to its shader program's uniforms.
27325
27100
  *
@@ -27362,7 +27137,7 @@
27362
27137
  for (let i = 1; i <= filterWindow; i++) {
27363
27138
  offsets[i - 1] = "".concat(i, ".0 * uDelta");
27364
27139
  }
27365
- 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 ");
27140
+ 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 ");
27366
27141
  }
27367
27142
  applyToForWebgl(options) {
27368
27143
  options.passes++;
@@ -27705,20 +27480,6 @@
27705
27480
  }
27706
27481
  return img2;
27707
27482
  }
27708
-
27709
- /**
27710
- * Returns object representation of an instance
27711
- * @return {Object} Object representation of an instance
27712
- */
27713
- toObject() {
27714
- return {
27715
- type: this.type,
27716
- scaleX: this.scaleX,
27717
- scaleY: this.scaleY,
27718
- resizeType: this.resizeType,
27719
- lanczosLobes: this.lanczosLobes
27720
- };
27721
- }
27722
27483
  }
27723
27484
  /**
27724
27485
  * Resize type
@@ -27743,10 +27504,15 @@
27743
27504
  */
27744
27505
  _defineProperty(Resize, "type", 'Resize');
27745
27506
  _defineProperty(Resize, "defaults", resizeDefaultValues);
27507
+ _defineProperty(Resize, "uniformLocations", ['uDelta', 'uTaps']);
27746
27508
  classRegistry.setClass(Resize);
27747
27509
 
27748
27510
  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";
27749
27511
 
27512
+ const saturationDefaultValues = {
27513
+ saturation: 0
27514
+ };
27515
+
27750
27516
  /**
27751
27517
  * Saturate filter class
27752
27518
  * @example
@@ -27756,11 +27522,6 @@
27756
27522
  * object.filters.push(filter);
27757
27523
  * object.applyFilters();
27758
27524
  */
27759
-
27760
- const saturationDefaultValues = {
27761
- saturation: 0,
27762
- mainParameter: 'saturation'
27763
- };
27764
27525
  class Saturation extends BaseFilter {
27765
27526
  getFragmentSource() {
27766
27527
  return fragmentSource$1;
@@ -27778,9 +27539,6 @@
27778
27539
  data
27779
27540
  }
27780
27541
  } = _ref;
27781
- if (this.saturation === 0) {
27782
- return;
27783
- }
27784
27542
  const adjust = -this.saturation;
27785
27543
  for (let i = 0; i < data.length; i += 4) {
27786
27544
  const max = Math.max(data[i], data[i + 1], data[i + 2]);
@@ -27790,18 +27548,6 @@
27790
27548
  }
27791
27549
  }
27792
27550
 
27793
- /**
27794
- * Return WebGL uniform locations for this filter's shader.
27795
- *
27796
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27797
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27798
- */
27799
- getUniformLocations(gl, program) {
27800
- return {
27801
- uSaturation: gl.getUniformLocation(program, 'uSaturation')
27802
- };
27803
- }
27804
-
27805
27551
  /**
27806
27552
  * Send data from this filter to its shader program's uniforms.
27807
27553
  *
@@ -27811,6 +27557,9 @@
27811
27557
  sendUniformData(gl, uniformLocations) {
27812
27558
  gl.uniform1f(uniformLocations.uSaturation, -this.saturation);
27813
27559
  }
27560
+ isNeutralState() {
27561
+ return this.saturation === 0;
27562
+ }
27814
27563
  }
27815
27564
  /**
27816
27565
  * Saturation value, from -1 to 1.
@@ -27822,13 +27571,13 @@
27822
27571
  */
27823
27572
  _defineProperty(Saturation, "type", 'Saturation');
27824
27573
  _defineProperty(Saturation, "defaults", saturationDefaultValues);
27574
+ _defineProperty(Saturation, "uniformLocations", ['uSaturation']);
27825
27575
  classRegistry.setClass(Saturation);
27826
27576
 
27827
27577
  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";
27828
27578
 
27829
27579
  const vibranceDefaultValues = {
27830
- vibrance: 0,
27831
- mainParameter: 'vibrance'
27580
+ vibrance: 0
27832
27581
  };
27833
27582
 
27834
27583
  /**
@@ -27857,9 +27606,6 @@
27857
27606
  data
27858
27607
  }
27859
27608
  } = _ref;
27860
- if (this.vibrance === 0) {
27861
- return;
27862
- }
27863
27609
  const adjust = -this.vibrance;
27864
27610
  for (let i = 0; i < data.length; i += 4) {
27865
27611
  const max = Math.max(data[i], data[i + 1], data[i + 2]);
@@ -27871,27 +27617,18 @@
27871
27617
  }
27872
27618
  }
27873
27619
 
27874
- /**
27875
- * Return WebGL uniform locations for this filter's shader.
27876
- *
27877
- * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27878
- * @param {WebGLShaderProgram} program This filter's compiled shader program.
27879
- */
27880
- getUniformLocations(gl, program) {
27881
- return {
27882
- uVibrance: gl.getUniformLocation(program, 'uVibrance')
27883
- };
27884
- }
27885
-
27886
27620
  /**
27887
27621
  * Send data from this filter to its shader program's uniforms.
27888
27622
  *
27889
27623
  * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
27890
- * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects
27624
+ * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects
27891
27625
  */
27892
27626
  sendUniformData(gl, uniformLocations) {
27893
27627
  gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);
27894
27628
  }
27629
+ isNeutralState() {
27630
+ return this.vibrance === 0;
27631
+ }
27895
27632
  }
27896
27633
  /**
27897
27634
  * Vibrance value, from -1 to 1.
@@ -27903,6 +27640,7 @@
27903
27640
  */
27904
27641
  _defineProperty(Vibrance, "type", 'Vibrance');
27905
27642
  _defineProperty(Vibrance, "defaults", vibranceDefaultValues);
27643
+ _defineProperty(Vibrance, "uniformLocations", ['uVibrance']);
27906
27644
  classRegistry.setClass(Vibrance);
27907
27645
 
27908
27646
  var filters = /*#__PURE__*/Object.freeze({