konva 9.3.15 → 9.3.16

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 (65) hide show
  1. package/konva.js +726 -724
  2. package/konva.min.js +3 -3
  3. package/lib/Animation.js +1 -1
  4. package/lib/BezierFunctions.js +1 -2
  5. package/lib/Canvas.js +9 -9
  6. package/lib/Container.d.ts +1 -1
  7. package/lib/Container.js +29 -29
  8. package/lib/Context.d.ts +2 -2
  9. package/lib/Context.js +26 -26
  10. package/lib/DragAndDrop.d.ts +2 -2
  11. package/lib/DragAndDrop.js +6 -4
  12. package/lib/Factory.js +16 -16
  13. package/lib/Global.js +1 -1
  14. package/lib/Group.js +1 -1
  15. package/lib/Layer.js +17 -17
  16. package/lib/Node.d.ts +1 -1
  17. package/lib/Node.js +87 -87
  18. package/lib/PointerEvents.js +5 -6
  19. package/lib/Shape.js +31 -31
  20. package/lib/Stage.d.ts +2 -2
  21. package/lib/Stage.js +28 -28
  22. package/lib/Tween.js +21 -21
  23. package/lib/Util.d.ts +4 -4
  24. package/lib/Util.js +62 -62
  25. package/lib/Validators.js +16 -17
  26. package/lib/_CoreInternals.d.ts +8 -8
  27. package/lib/_FullInternals.d.ts +8 -8
  28. package/lib/filters/Blur.js +6 -6
  29. package/lib/filters/Brighten.js +1 -1
  30. package/lib/filters/Contrast.js +2 -2
  31. package/lib/filters/Emboss.js +19 -19
  32. package/lib/filters/Enhance.js +4 -4
  33. package/lib/filters/Grayscale.js +1 -1
  34. package/lib/filters/HSL.js +6 -6
  35. package/lib/filters/HSV.js +7 -7
  36. package/lib/filters/Invert.js +1 -1
  37. package/lib/filters/Kaleidoscope.js +20 -20
  38. package/lib/filters/Mask.js +57 -57
  39. package/lib/filters/Noise.js +2 -2
  40. package/lib/filters/Pixelate.js +1 -1
  41. package/lib/filters/Posterize.js +1 -1
  42. package/lib/filters/RGB.js +1 -1
  43. package/lib/filters/RGBA.js +3 -3
  44. package/lib/filters/Sepia.js +1 -1
  45. package/lib/filters/Solarize.js +8 -7
  46. package/lib/filters/Threshold.js +2 -2
  47. package/lib/shapes/Arc.js +1 -1
  48. package/lib/shapes/Arrow.js +10 -10
  49. package/lib/shapes/Ellipse.js +1 -1
  50. package/lib/shapes/Image.js +3 -3
  51. package/lib/shapes/Label.d.ts +1 -1
  52. package/lib/shapes/Label.js +6 -6
  53. package/lib/shapes/Line.d.ts +1 -1
  54. package/lib/shapes/Line.js +14 -14
  55. package/lib/shapes/Path.js +62 -62
  56. package/lib/shapes/Rect.js +1 -1
  57. package/lib/shapes/RegularPolygon.js +6 -6
  58. package/lib/shapes/Ring.js +1 -1
  59. package/lib/shapes/Sprite.js +9 -9
  60. package/lib/shapes/Star.js +5 -5
  61. package/lib/shapes/Text.js +37 -37
  62. package/lib/shapes/TextPath.js +23 -23
  63. package/lib/shapes/Transformer.d.ts +1 -1
  64. package/lib/shapes/Transformer.js +63 -63
  65. package/package.json +2 -5
package/konva.js CHANGED
@@ -5,10 +5,10 @@
5
5
  })(this, (function () { 'use strict';
6
6
 
7
7
  /*
8
- * Konva JavaScript Framework v9.3.15
8
+ * Konva JavaScript Framework v9.3.16
9
9
  * http://konvajs.org/
10
10
  * Licensed under the MIT
11
- * Date: Mon Sep 09 2024
11
+ * Date: Mon Oct 21 2024
12
12
  *
13
13
  * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
14
14
  * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@@ -35,7 +35,7 @@
35
35
  : {};
36
36
  const Konva$2 = {
37
37
  _global: glob,
38
- version: '9.3.15',
38
+ version: '9.3.16',
39
39
  isBrowser: detectBrowser(),
40
40
  isUnminified: /param/.test(function (param) { }.toString()),
41
41
  dblClickWindow: 400,
@@ -249,7 +249,7 @@
249
249
  * @returns {Object} 2D point(x, y)
250
250
  */
251
251
  point(point) {
252
- var m = this.m;
252
+ const m = this.m;
253
253
  return {
254
254
  x: m[0] * point.x + m[2] * point.y + m[4],
255
255
  y: m[1] * point.x + m[3] * point.y + m[5],
@@ -291,12 +291,12 @@
291
291
  * @returns {Konva.Transform}
292
292
  */
293
293
  rotate(rad) {
294
- var c = Math.cos(rad);
295
- var s = Math.sin(rad);
296
- var m11 = this.m[0] * c + this.m[2] * s;
297
- var m12 = this.m[1] * c + this.m[3] * s;
298
- var m21 = this.m[0] * -s + this.m[2] * c;
299
- var m22 = this.m[1] * -s + this.m[3] * c;
294
+ const c = Math.cos(rad);
295
+ const s = Math.sin(rad);
296
+ const m11 = this.m[0] * c + this.m[2] * s;
297
+ const m12 = this.m[1] * c + this.m[3] * s;
298
+ const m21 = this.m[0] * -s + this.m[2] * c;
299
+ const m22 = this.m[1] * -s + this.m[3] * c;
300
300
  this.m[0] = m11;
301
301
  this.m[1] = m12;
302
302
  this.m[2] = m21;
@@ -324,10 +324,10 @@
324
324
  * @returns {Konva.Transform}
325
325
  */
326
326
  skew(sx, sy) {
327
- var m11 = this.m[0] + this.m[2] * sy;
328
- var m12 = this.m[1] + this.m[3] * sy;
329
- var m21 = this.m[2] + this.m[0] * sx;
330
- var m22 = this.m[3] + this.m[1] * sx;
327
+ const m11 = this.m[0] + this.m[2] * sy;
328
+ const m12 = this.m[1] + this.m[3] * sy;
329
+ const m21 = this.m[2] + this.m[0] * sx;
330
+ const m22 = this.m[3] + this.m[1] * sx;
331
331
  this.m[0] = m11;
332
332
  this.m[1] = m12;
333
333
  this.m[2] = m21;
@@ -342,12 +342,12 @@
342
342
  * @returns {Konva.Transform}
343
343
  */
344
344
  multiply(matrix) {
345
- var m11 = this.m[0] * matrix.m[0] + this.m[2] * matrix.m[1];
346
- var m12 = this.m[1] * matrix.m[0] + this.m[3] * matrix.m[1];
347
- var m21 = this.m[0] * matrix.m[2] + this.m[2] * matrix.m[3];
348
- var m22 = this.m[1] * matrix.m[2] + this.m[3] * matrix.m[3];
349
- var dx = this.m[0] * matrix.m[4] + this.m[2] * matrix.m[5] + this.m[4];
350
- var dy = this.m[1] * matrix.m[4] + this.m[3] * matrix.m[5] + this.m[5];
345
+ const m11 = this.m[0] * matrix.m[0] + this.m[2] * matrix.m[1];
346
+ const m12 = this.m[1] * matrix.m[0] + this.m[3] * matrix.m[1];
347
+ const m21 = this.m[0] * matrix.m[2] + this.m[2] * matrix.m[3];
348
+ const m22 = this.m[1] * matrix.m[2] + this.m[3] * matrix.m[3];
349
+ const dx = this.m[0] * matrix.m[4] + this.m[2] * matrix.m[5] + this.m[4];
350
+ const dy = this.m[1] * matrix.m[4] + this.m[3] * matrix.m[5] + this.m[5];
351
351
  this.m[0] = m11;
352
352
  this.m[1] = m12;
353
353
  this.m[2] = m21;
@@ -363,13 +363,13 @@
363
363
  * @returns {Konva.Transform}
364
364
  */
365
365
  invert() {
366
- var d = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]);
367
- var m0 = this.m[3] * d;
368
- var m1 = -this.m[1] * d;
369
- var m2 = -this.m[2] * d;
370
- var m3 = this.m[0] * d;
371
- var m4 = d * (this.m[2] * this.m[5] - this.m[3] * this.m[4]);
372
- var m5 = d * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);
366
+ const d = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]);
367
+ const m0 = this.m[3] * d;
368
+ const m1 = -this.m[1] * d;
369
+ const m2 = -this.m[2] * d;
370
+ const m3 = this.m[0] * d;
371
+ const m4 = d * (this.m[2] * this.m[5] - this.m[3] * this.m[4]);
372
+ const m5 = d * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);
373
373
  this.m[0] = m0;
374
374
  this.m[1] = m1;
375
375
  this.m[2] = m2;
@@ -393,14 +393,14 @@
393
393
  * @returns {Konva.Transform}
394
394
  */
395
395
  decompose() {
396
- var a = this.m[0];
397
- var b = this.m[1];
398
- var c = this.m[2];
399
- var d = this.m[3];
400
- var e = this.m[4];
401
- var f = this.m[5];
402
- var delta = a * d - b * c;
403
- let result = {
396
+ const a = this.m[0];
397
+ const b = this.m[1];
398
+ const c = this.m[2];
399
+ const d = this.m[3];
400
+ const e = this.m[4];
401
+ const f = this.m[5];
402
+ const delta = a * d - b * c;
403
+ const result = {
404
404
  x: e,
405
405
  y: f,
406
406
  rotation: 0,
@@ -411,7 +411,7 @@
411
411
  };
412
412
  // Apply the QR-like decomposition.
413
413
  if (a != 0 || b != 0) {
414
- var r = Math.sqrt(a * a + b * b);
414
+ const r = Math.sqrt(a * a + b * b);
415
415
  result.rotation = b > 0 ? Math.acos(a / r) : -Math.acos(a / r);
416
416
  result.scaleX = r;
417
417
  result.scaleY = delta / r;
@@ -419,7 +419,7 @@
419
419
  result.skewY = 0;
420
420
  }
421
421
  else if (c != 0 || d != 0) {
422
- var s = Math.sqrt(c * c + d * d);
422
+ const s = Math.sqrt(c * c + d * d);
423
423
  result.rotation =
424
424
  Math.PI / 2 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s));
425
425
  result.scaleX = delta / s;
@@ -433,7 +433,7 @@
433
433
  }
434
434
  }
435
435
  // CONSTANTS
436
- var OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH$1 = '#', EMPTY_STRING$1 = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
436
+ let OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH$1 = '#', EMPTY_STRING$1 = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
437
437
  aliceblue: [240, 248, 255],
438
438
  antiquewhite: [250, 235, 215],
439
439
  aqua: [0, 255, 255],
@@ -627,7 +627,7 @@
627
627
  if (typeof selector !== 'string') {
628
628
  return false;
629
629
  }
630
- var firstChar = selector[0];
630
+ const firstChar = selector[0];
631
631
  return (firstChar === '#' ||
632
632
  firstChar === '.' ||
633
633
  firstChar === firstChar.toUpperCase());
@@ -658,7 +658,7 @@
658
658
  }
659
659
  },
660
660
  createCanvasElement() {
661
- var canvas = document.createElement('canvas');
661
+ const canvas = document.createElement('canvas');
662
662
  // on some environments canvas.style is readonly
663
663
  try {
664
664
  canvas.style = canvas.style || {};
@@ -682,7 +682,7 @@
682
682
  */
683
683
  _urlToImage(url, callback) {
684
684
  // if arg is a string, then it's a data url
685
- var imageObj = Util.createImageElement();
685
+ const imageObj = Util.createImageElement();
686
686
  imageObj.onload = function () {
687
687
  callback(imageObj);
688
688
  };
@@ -693,7 +693,7 @@
693
693
  },
694
694
  _hexToRgb(hex) {
695
695
  hex = hex.replace(HASH$1, EMPTY_STRING$1);
696
- var bigint = parseInt(hex, 16);
696
+ const bigint = parseInt(hex, 16);
697
697
  return {
698
698
  r: (bigint >> 16) & 255,
699
699
  g: (bigint >> 8) & 255,
@@ -708,7 +708,7 @@
708
708
  * shape.fill(Konva.Util.getRandomColor());
709
709
  */
710
710
  getRandomColor() {
711
- var randColor = ((Math.random() * 0xffffff) << 0).toString(16);
711
+ let randColor = ((Math.random() * 0xffffff) << 0).toString(16);
712
712
  while (randColor.length < 6) {
713
713
  randColor = ZERO + randColor;
714
714
  }
@@ -726,7 +726,7 @@
726
726
  * var rgb = Konva.Util.getRGB('rgb(0,0,255)');
727
727
  */
728
728
  getRGB(color) {
729
- var rgb;
729
+ let rgb;
730
730
  // color string
731
731
  if (color in COLORS) {
732
732
  rgb = COLORS[color];
@@ -773,7 +773,7 @@
773
773
  },
774
774
  // Parse named css color. Like "green"
775
775
  _namedColorToRBA(str) {
776
- var c = COLORS[str.toLowerCase()];
776
+ const c = COLORS[str.toLowerCase()];
777
777
  if (!c) {
778
778
  return null;
779
779
  }
@@ -788,7 +788,7 @@
788
788
  _rgbColorToRGBA(str) {
789
789
  if (str.indexOf('rgb(') === 0) {
790
790
  str = str.match(/rgb\(([^)]+)\)/)[1];
791
- var parts = str.split(/ *, */).map(Number);
791
+ const parts = str.split(/ *, */).map(Number);
792
792
  return {
793
793
  r: parts[0],
794
794
  g: parts[1],
@@ -801,7 +801,7 @@
801
801
  _rgbaColorToRGBA(str) {
802
802
  if (str.indexOf('rgba(') === 0) {
803
803
  str = str.match(/rgba\(([^)]+)\)/)[1];
804
- var parts = str.split(/ *, */).map((n, index) => {
804
+ const parts = str.split(/ *, */).map((n, index) => {
805
805
  if (n.slice(-1) === '%') {
806
806
  return index === 3 ? parseInt(n) / 100 : (parseInt(n) / 100) * 255;
807
807
  }
@@ -934,8 +934,8 @@
934
934
  r2.y + r2.height < r1.y);
935
935
  },
936
936
  cloneObject(obj) {
937
- var retObj = {};
938
- for (var key in obj) {
937
+ const retObj = {};
938
+ for (const key in obj) {
939
939
  if (this._isPlainObject(obj[key])) {
940
940
  retObj[key] = this.cloneObject(obj[key]);
941
941
  }
@@ -984,7 +984,7 @@
984
984
  console.warn(KONVA_WARNING + str);
985
985
  },
986
986
  each(obj, func) {
987
- for (var key in obj) {
987
+ for (const key in obj) {
988
988
  func(key, obj[key]);
989
989
  }
990
990
  },
@@ -992,15 +992,15 @@
992
992
  return left <= val && val < right;
993
993
  },
994
994
  _getProjectionToSegment(x1, y1, x2, y2, x3, y3) {
995
- var x, y, dist;
996
- var pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
995
+ let x, y, dist;
996
+ const pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
997
997
  if (pd2 == 0) {
998
998
  x = x1;
999
999
  y = y1;
1000
1000
  dist = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);
1001
1001
  }
1002
1002
  else {
1003
- var u = ((x3 - x1) * (x2 - x1) + (y3 - y1) * (y2 - y1)) / pd2;
1003
+ const u = ((x3 - x1) * (x2 - x1) + (y3 - y1) * (y2 - y1)) / pd2;
1004
1004
  if (u < 0) {
1005
1005
  x = x1;
1006
1006
  y = y1;
@@ -1022,15 +1022,15 @@
1022
1022
  // line as array of points.
1023
1023
  // line might be closed
1024
1024
  _getProjectionToLine(pt, line, isClosed) {
1025
- var pc = Util.cloneObject(pt);
1026
- var dist = Number.MAX_VALUE;
1025
+ const pc = Util.cloneObject(pt);
1026
+ let dist = Number.MAX_VALUE;
1027
1027
  line.forEach(function (p1, i) {
1028
1028
  if (!isClosed && i === line.length - 1) {
1029
1029
  return;
1030
1030
  }
1031
- var p2 = line[(i + 1) % line.length];
1032
- var proj = Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);
1033
- var px = proj[0], py = proj[1], pdist = proj[2];
1031
+ const p2 = line[(i + 1) % line.length];
1032
+ const proj = Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);
1033
+ const px = proj[0], py = proj[1], pdist = proj[2];
1034
1034
  if (pdist < dist) {
1035
1035
  pc.x = px;
1036
1036
  pc.y = py;
@@ -1040,9 +1040,9 @@
1040
1040
  return pc;
1041
1041
  },
1042
1042
  _prepareArrayForTween(startArray, endArray, isClosed) {
1043
- var n, start = [], end = [];
1043
+ let n, start = [], end = [];
1044
1044
  if (startArray.length > endArray.length) {
1045
- var temp = endArray;
1045
+ const temp = endArray;
1046
1046
  endArray = startArray;
1047
1047
  startArray = temp;
1048
1048
  }
@@ -1058,18 +1058,18 @@
1058
1058
  y: endArray[n + 1],
1059
1059
  });
1060
1060
  }
1061
- var newStart = [];
1061
+ const newStart = [];
1062
1062
  end.forEach(function (point) {
1063
- var pr = Util._getProjectionToLine(point, start, isClosed);
1063
+ const pr = Util._getProjectionToLine(point, start, isClosed);
1064
1064
  newStart.push(pr.x);
1065
1065
  newStart.push(pr.y);
1066
1066
  });
1067
1067
  return newStart;
1068
1068
  },
1069
1069
  _prepareToStringify(obj) {
1070
- var desc;
1070
+ let desc;
1071
1071
  obj.visitedByCircularReferenceRemoval = true;
1072
- for (var key in obj) {
1072
+ for (const key in obj) {
1073
1073
  if (!(obj.hasOwnProperty(key) && obj[key] && typeof obj[key] == 'object')) {
1074
1074
  continue;
1075
1075
  }
@@ -1097,7 +1097,7 @@
1097
1097
  },
1098
1098
  // very simplified version of Object.assign
1099
1099
  _assign(target, source) {
1100
- for (var key in source) {
1100
+ for (const key in source) {
1101
1101
  target[key] = source[key];
1102
1102
  }
1103
1103
  return target;
@@ -1186,8 +1186,8 @@
1186
1186
  function getNumberOrArrayOfNumbersValidator(noOfElements) {
1187
1187
  if (Konva$2.isUnminified) {
1188
1188
  return function (val, attr) {
1189
- let isNumber = Util._isNumber(val);
1190
- let isValidArray = Util._isArray(val) && val.length == noOfElements;
1189
+ const isNumber = Util._isNumber(val);
1190
+ const isValidArray = Util._isArray(val) && val.length == noOfElements;
1191
1191
  if (!isNumber && !isValidArray) {
1192
1192
  Util.warn(_formatValue(val) +
1193
1193
  ' is a not valid value for "' +
@@ -1203,8 +1203,8 @@
1203
1203
  function getNumberOrAutoValidator() {
1204
1204
  if (Konva$2.isUnminified) {
1205
1205
  return function (val, attr) {
1206
- var isNumber = Util._isNumber(val);
1207
- var isAuto = val === 'auto';
1206
+ const isNumber = Util._isNumber(val);
1207
+ const isAuto = val === 'auto';
1208
1208
  if (!(isNumber || isAuto)) {
1209
1209
  Util.warn(_formatValue(val) +
1210
1210
  ' is a not valid value for "' +
@@ -1277,7 +1277,7 @@
1277
1277
  function getBooleanValidator() {
1278
1278
  if (Konva$2.isUnminified) {
1279
1279
  return function (val, attr) {
1280
- var isBool = val === true || val === false;
1280
+ const isBool = val === true || val === false;
1281
1281
  if (!isBool) {
1282
1282
  Util.warn(_formatValue(val) +
1283
1283
  ' is a not valid value for "' +
@@ -1307,7 +1307,7 @@
1307
1307
  }
1308
1308
  }
1309
1309
 
1310
- var GET = 'get', SET$1 = 'set';
1310
+ const GET = 'get', SET$1 = 'set';
1311
1311
  const Factory = {
1312
1312
  addGetterSetter(constructor, attr, def, validator, after) {
1313
1313
  Factory.addGetter(constructor, attr, def);
@@ -1315,22 +1315,22 @@
1315
1315
  Factory.addOverloadedGetterSetter(constructor, attr);
1316
1316
  },
1317
1317
  addGetter(constructor, attr, def) {
1318
- var method = GET + Util._capitalize(attr);
1318
+ const method = GET + Util._capitalize(attr);
1319
1319
  constructor.prototype[method] =
1320
1320
  constructor.prototype[method] ||
1321
1321
  function () {
1322
- var val = this.attrs[attr];
1322
+ const val = this.attrs[attr];
1323
1323
  return val === undefined ? def : val;
1324
1324
  };
1325
1325
  },
1326
1326
  addSetter(constructor, attr, validator, after) {
1327
- var method = SET$1 + Util._capitalize(attr);
1327
+ const method = SET$1 + Util._capitalize(attr);
1328
1328
  if (!constructor.prototype[method]) {
1329
1329
  Factory.overWriteSetter(constructor, attr, validator, after);
1330
1330
  }
1331
1331
  },
1332
1332
  overWriteSetter(constructor, attr, validator, after) {
1333
- var method = SET$1 + Util._capitalize(attr);
1333
+ const method = SET$1 + Util._capitalize(attr);
1334
1334
  constructor.prototype[method] = function (val) {
1335
1335
  if (validator && val !== undefined && val !== null) {
1336
1336
  val = validator.call(this, val, attr);
@@ -1343,20 +1343,20 @@
1343
1343
  };
1344
1344
  },
1345
1345
  addComponentsGetterSetter(constructor, attr, components, validator, after) {
1346
- var len = components.length, capitalize = Util._capitalize, getter = GET + capitalize(attr), setter = SET$1 + capitalize(attr), n, component;
1346
+ let len = components.length, capitalize = Util._capitalize, getter = GET + capitalize(attr), setter = SET$1 + capitalize(attr), n, component;
1347
1347
  // getter
1348
1348
  constructor.prototype[getter] = function () {
1349
- var ret = {};
1349
+ const ret = {};
1350
1350
  for (n = 0; n < len; n++) {
1351
1351
  component = components[n];
1352
1352
  ret[component] = this.getAttr(attr + capitalize(component));
1353
1353
  }
1354
1354
  return ret;
1355
1355
  };
1356
- var basicValidator = getComponentValidator(components);
1356
+ const basicValidator = getComponentValidator(components);
1357
1357
  // setter
1358
1358
  constructor.prototype[setter] = function (val) {
1359
- var oldVal = this.attrs[attr], key;
1359
+ let oldVal = this.attrs[attr], key;
1360
1360
  if (validator) {
1361
1361
  val = validator.call(this, val);
1362
1362
  }
@@ -1383,7 +1383,7 @@
1383
1383
  Factory.addOverloadedGetterSetter(constructor, attr);
1384
1384
  },
1385
1385
  addOverloadedGetterSetter(constructor, attr) {
1386
- var capitalizedAttr = Util._capitalize(attr), setter = SET$1 + capitalizedAttr, getter = GET + capitalizedAttr;
1386
+ const capitalizedAttr = Util._capitalize(attr), setter = SET$1 + capitalizedAttr, getter = GET + capitalizedAttr;
1387
1387
  constructor.prototype[attr] = function () {
1388
1388
  // setting
1389
1389
  if (arguments.length) {
@@ -1396,12 +1396,12 @@
1396
1396
  },
1397
1397
  addDeprecatedGetterSetter(constructor, attr, def, validator) {
1398
1398
  Util.error('Adding deprecated ' + attr);
1399
- var method = GET + Util._capitalize(attr);
1400
- var message = attr +
1399
+ const method = GET + Util._capitalize(attr);
1400
+ const message = attr +
1401
1401
  ' property is deprecated and will be removed soon. Look at Konva change log for more information.';
1402
1402
  constructor.prototype[method] = function () {
1403
1403
  Util.error(message);
1404
- var val = this.attrs[attr];
1404
+ const val = this.attrs[attr];
1405
1405
  return val === undefined ? def : val;
1406
1406
  };
1407
1407
  Factory.addSetter(constructor, attr, validator, function () {
@@ -1411,9 +1411,9 @@
1411
1411
  },
1412
1412
  backCompat(constructor, methods) {
1413
1413
  Util.each(methods, function (oldMethodName, newMethodName) {
1414
- var method = constructor.prototype[newMethodName];
1415
- var oldGetter = GET + Util._capitalize(oldMethodName);
1416
- var oldSetter = SET$1 + Util._capitalize(oldMethodName);
1414
+ const method = constructor.prototype[newMethodName];
1415
+ const oldGetter = GET + Util._capitalize(oldMethodName);
1416
+ const oldSetter = SET$1 + Util._capitalize(oldMethodName);
1417
1417
  function deprecated() {
1418
1418
  method.apply(this, arguments);
1419
1419
  Util.error('"' +
@@ -1433,7 +1433,7 @@
1433
1433
  };
1434
1434
 
1435
1435
  function simplifyArray(arr) {
1436
- var retArr = [], len = arr.length, util = Util, n, val;
1436
+ let retArr = [], len = arr.length, util = Util, n, val;
1437
1437
  for (n = 0; n < len; n++) {
1438
1438
  val = arr[n];
1439
1439
  if (util._isNumber(val)) {
@@ -1446,7 +1446,7 @@
1446
1446
  }
1447
1447
  return retArr;
1448
1448
  }
1449
- var COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', OPEN_PAREN_BRACKET = '([', CLOSE_BRACKET_PAREN = '])', SEMICOLON = ';', DOUBLE_PAREN = '()',
1449
+ const COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', OPEN_PAREN_BRACKET = '([', CLOSE_BRACKET_PAREN = '])', SEMICOLON = ';', DOUBLE_PAREN = '()',
1450
1450
  // EMPTY_STRING = '',
1451
1451
  EQUALS = '=',
1452
1452
  // SET = 'set',
@@ -1484,7 +1484,7 @@
1484
1484
  'transform',
1485
1485
  'translate',
1486
1486
  ];
1487
- var CONTEXT_PROPERTIES = [
1487
+ const CONTEXT_PROPERTIES = [
1488
1488
  'fillStyle',
1489
1489
  'strokeStyle',
1490
1490
  'shadowColor',
@@ -1581,7 +1581,7 @@
1581
1581
  }
1582
1582
  }
1583
1583
  getTrace(relaxed, rounded) {
1584
- var traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args;
1584
+ let traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args;
1585
1585
  for (n = 0; n < len; n++) {
1586
1586
  trace = traceArr[n];
1587
1587
  method = trace.method;
@@ -1619,7 +1619,7 @@
1619
1619
  this.traceArr = [];
1620
1620
  }
1621
1621
  _trace(str) {
1622
- var traceArr = this.traceArr, len;
1622
+ let traceArr = this.traceArr, len;
1623
1623
  traceArr.push(str);
1624
1624
  len = traceArr.length;
1625
1625
  if (len >= traceArrMax) {
@@ -1632,7 +1632,7 @@
1632
1632
  * @name Konva.Context#reset
1633
1633
  */
1634
1634
  reset() {
1635
- var pixelRatio = this.getCanvas().getPixelRatio();
1635
+ const pixelRatio = this.getCanvas().getPixelRatio();
1636
1636
  this.setTransform(1 * pixelRatio, 0, 0, 1 * pixelRatio, 0, 0);
1637
1637
  }
1638
1638
  /**
@@ -1655,7 +1655,7 @@
1655
1655
  * @param {Number} [bounds.height]
1656
1656
  */
1657
1657
  clear(bounds) {
1658
- var canvas = this.getCanvas();
1658
+ const canvas = this.getCanvas();
1659
1659
  if (bounds) {
1660
1660
  this.clearRect(bounds.x || 0, bounds.y || 0, bounds.width || 0, bounds.height || 0);
1661
1661
  }
@@ -1670,7 +1670,7 @@
1670
1670
  }
1671
1671
  }
1672
1672
  _applyOpacity(shape) {
1673
- var absOpacity = shape.getAbsoluteOpacity();
1673
+ const absOpacity = shape.getAbsoluteOpacity();
1674
1674
  if (absOpacity !== 1) {
1675
1675
  this.setAttr('globalAlpha', absOpacity);
1676
1676
  }
@@ -1742,7 +1742,7 @@
1742
1742
  * @name Konva.Context#createImageData
1743
1743
  */
1744
1744
  createImageData(width, height) {
1745
- var a = arguments;
1745
+ const a = arguments;
1746
1746
  if (a.length === 2) {
1747
1747
  return this._context.createImageData(width, height);
1748
1748
  }
@@ -1781,7 +1781,7 @@
1781
1781
  */
1782
1782
  drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {
1783
1783
  // this._context.drawImage(...arguments);
1784
- var a = arguments, _context = this._context;
1784
+ const a = arguments, _context = this._context;
1785
1785
  if (a.length === 3) {
1786
1786
  _context.drawImage(image, sx, sy);
1787
1787
  }
@@ -2014,10 +2014,10 @@
2014
2014
  this._context.translate(x, y);
2015
2015
  }
2016
2016
  _enableTrace() {
2017
- var that = this, len = CONTEXT_METHODS.length, origSetter = this.setAttr, n, args;
2017
+ let that = this, len = CONTEXT_METHODS.length, origSetter = this.setAttr, n, args;
2018
2018
  // to prevent creating scope function at each loop
2019
- var func = function (methodName) {
2020
- var origMethod = that[methodName], ret;
2019
+ const func = function (methodName) {
2020
+ let origMethod = that[methodName], ret;
2021
2021
  that[methodName] = function () {
2022
2022
  args = simplifyArray(Array.prototype.slice.call(arguments, 0));
2023
2023
  ret = origMethod.apply(that, arguments);
@@ -2035,8 +2035,8 @@
2035
2035
  // attrs
2036
2036
  that.setAttr = function () {
2037
2037
  origSetter.apply(that, arguments);
2038
- var prop = arguments[0];
2039
- var val = arguments[1];
2038
+ const prop = arguments[0];
2039
+ let val = arguments[1];
2040
2040
  if (prop === 'shadowOffsetX' ||
2041
2041
  prop === 'shadowOffsetY' ||
2042
2042
  prop === 'shadowBlur') {
@@ -2050,7 +2050,7 @@
2050
2050
  }
2051
2051
  _applyGlobalCompositeOperation(node) {
2052
2052
  const op = node.attrs.globalCompositeOperation;
2053
- var def = !op || op === 'source-over';
2053
+ const def = !op || op === 'source-over';
2054
2054
  if (!def) {
2055
2055
  this.setAttr('globalCompositeOperation', op);
2056
2056
  }
@@ -2074,7 +2074,7 @@
2074
2074
  });
2075
2075
  }
2076
2076
  _fillColor(shape) {
2077
- var fill = shape.fill();
2077
+ const fill = shape.fill();
2078
2078
  this.setAttr('fillStyle', fill);
2079
2079
  shape._fillFunc(this);
2080
2080
  }
@@ -2083,7 +2083,7 @@
2083
2083
  shape._fillFunc(this);
2084
2084
  }
2085
2085
  _fillLinearGradient(shape) {
2086
- var grd = shape._getLinearGradient();
2086
+ const grd = shape._getLinearGradient();
2087
2087
  if (grd) {
2088
2088
  this.setAttr('fillStyle', grd);
2089
2089
  shape._fillFunc(this);
@@ -2136,20 +2136,20 @@
2136
2136
  const start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);
2137
2137
  if (colorStops) {
2138
2138
  // build color stops
2139
- for (var n = 0; n < colorStops.length; n += 2) {
2139
+ for (let n = 0; n < colorStops.length; n += 2) {
2140
2140
  grd.addColorStop(colorStops[n], colorStops[n + 1]);
2141
2141
  }
2142
2142
  this.setAttr('strokeStyle', grd);
2143
2143
  }
2144
2144
  }
2145
2145
  _stroke(shape) {
2146
- var dash = shape.dash(),
2146
+ const dash = shape.dash(),
2147
2147
  // ignore strokeScaleEnabled for Text
2148
2148
  strokeScaleEnabled = shape.getStrokeScaleEnabled();
2149
2149
  if (shape.hasStroke()) {
2150
2150
  if (!strokeScaleEnabled) {
2151
2151
  this.save();
2152
- var pixelRatio = this.getCanvas().getPixelRatio();
2152
+ const pixelRatio = this.getCanvas().getPixelRatio();
2153
2153
  this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
2154
2154
  }
2155
2155
  this._applyLineCap(shape);
@@ -2161,7 +2161,7 @@
2161
2161
  if (!shape.getShadowForStrokeEnabled()) {
2162
2162
  this.setAttr('shadowColor', 'rgba(0,0,0,0)');
2163
2163
  }
2164
- var hasLinearGradient = shape.getStrokeLinearGradientColorStops();
2164
+ const hasLinearGradient = shape.getStrokeLinearGradientColorStops();
2165
2165
  if (hasLinearGradient) {
2166
2166
  this._strokeLinearGradient(shape);
2167
2167
  }
@@ -2176,7 +2176,7 @@
2176
2176
  }
2177
2177
  _applyShadow(shape) {
2178
2178
  var _a, _b, _c;
2179
- var color = (_a = shape.getShadowRGBA()) !== null && _a !== void 0 ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== void 0 ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== void 0 ? _c : {
2179
+ const color = (_a = shape.getShadowRGBA()) !== null && _a !== void 0 ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== void 0 ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== void 0 ? _c : {
2180
2180
  x: 0,
2181
2181
  y: 0,
2182
2182
  }, scale = shape.getAbsoluteScale(), ratio = this.canvas.getPixelRatio(), scaleX = scale.x * ratio, scaleY = scale.y * ratio;
@@ -2210,12 +2210,12 @@
2210
2210
  const strokeScaleEnabled = shape.getStrokeScaleEnabled();
2211
2211
  if (!strokeScaleEnabled) {
2212
2212
  this.save();
2213
- var pixelRatio = this.getCanvas().getPixelRatio();
2213
+ const pixelRatio = this.getCanvas().getPixelRatio();
2214
2214
  this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
2215
2215
  }
2216
2216
  this._applyLineCap(shape);
2217
- var hitStrokeWidth = shape.hitStrokeWidth();
2218
- var strokeWidth = hitStrokeWidth === 'auto' ? shape.strokeWidth() : hitStrokeWidth;
2217
+ const hitStrokeWidth = shape.hitStrokeWidth();
2218
+ const strokeWidth = hitStrokeWidth === 'auto' ? shape.strokeWidth() : hitStrokeWidth;
2219
2219
  this.setAttr('lineWidth', strokeWidth);
2220
2220
  this.setAttr('strokeStyle', shape.colorKey);
2221
2221
  shape._strokeFuncHit(this);
@@ -2227,15 +2227,15 @@
2227
2227
  }
2228
2228
 
2229
2229
  // calculate pixel ratio
2230
- var _pixelRatio;
2230
+ let _pixelRatio;
2231
2231
  function getDevicePixelRatio() {
2232
2232
  if (_pixelRatio) {
2233
2233
  return _pixelRatio;
2234
2234
  }
2235
- var canvas = Util.createCanvasElement();
2236
- var context = canvas.getContext('2d');
2235
+ const canvas = Util.createCanvasElement();
2236
+ const context = canvas.getContext('2d');
2237
2237
  _pixelRatio = (function () {
2238
- var devicePixelRatio = Konva$2._global.devicePixelRatio || 1, backingStoreRatio = context.webkitBackingStorePixelRatio ||
2238
+ const devicePixelRatio = Konva$2._global.devicePixelRatio || 1, backingStoreRatio = context.webkitBackingStorePixelRatio ||
2239
2239
  context.mozBackingStorePixelRatio ||
2240
2240
  context.msBackingStorePixelRatio ||
2241
2241
  context.oBackingStorePixelRatio ||
@@ -2263,8 +2263,8 @@
2263
2263
  this.width = 0;
2264
2264
  this.height = 0;
2265
2265
  this.isCache = false;
2266
- var conf = config || {};
2267
- var pixelRatio = conf.pixelRatio || Konva$2.pixelRatio || getDevicePixelRatio();
2266
+ const conf = config || {};
2267
+ const pixelRatio = conf.pixelRatio || Konva$2.pixelRatio || getDevicePixelRatio();
2268
2268
  this.pixelRatio = pixelRatio;
2269
2269
  this._canvas = Util.createCanvasElement();
2270
2270
  // set inline styles
@@ -2289,7 +2289,7 @@
2289
2289
  return this.pixelRatio;
2290
2290
  }
2291
2291
  setPixelRatio(pixelRatio) {
2292
- var previousRatio = this.pixelRatio;
2292
+ const previousRatio = this.pixelRatio;
2293
2293
  this.pixelRatio = pixelRatio;
2294
2294
  this.setSize(this.getWidth() / previousRatio, this.getHeight() / previousRatio);
2295
2295
  }
@@ -2297,14 +2297,14 @@
2297
2297
  // take into account pixel ratio
2298
2298
  this.width = this._canvas.width = width * this.pixelRatio;
2299
2299
  this._canvas.style.width = width + 'px';
2300
- var pixelRatio = this.pixelRatio, _context = this.getContext()._context;
2300
+ const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
2301
2301
  _context.scale(pixelRatio, pixelRatio);
2302
2302
  }
2303
2303
  setHeight(height) {
2304
2304
  // take into account pixel ratio
2305
2305
  this.height = this._canvas.height = height * this.pixelRatio;
2306
2306
  this._canvas.style.height = height + 'px';
2307
- var pixelRatio = this.pixelRatio, _context = this.getContext()._context;
2307
+ const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
2308
2308
  _context.scale(pixelRatio, pixelRatio);
2309
2309
  }
2310
2310
  getWidth() {
@@ -2385,7 +2385,7 @@
2385
2385
 
2386
2386
  const DD = {
2387
2387
  get isDragging() {
2388
- var flag = false;
2388
+ let flag = false;
2389
2389
  DD._dragElements.forEach((elem) => {
2390
2390
  if (elem.dragStatus === 'dragging') {
2391
2391
  flag = true;
@@ -2396,7 +2396,7 @@
2396
2396
  justDragged: false,
2397
2397
  get node() {
2398
2398
  // return first dragging node
2399
- var node;
2399
+ let node;
2400
2400
  DD._dragElements.forEach((elem) => {
2401
2401
  node = elem.node;
2402
2402
  });
@@ -2422,8 +2422,8 @@
2422
2422
  return;
2423
2423
  }
2424
2424
  if (elem.dragStatus !== 'dragging') {
2425
- var dragDistance = node.dragDistance();
2426
- var distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));
2425
+ const dragDistance = node.dragDistance();
2426
+ const distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));
2427
2427
  if (distance < dragDistance) {
2428
2428
  return;
2429
2429
  }
@@ -2500,14 +2500,17 @@
2500
2500
  if (Konva$2.isBrowser) {
2501
2501
  window.addEventListener('mouseup', DD._endDragBefore, true);
2502
2502
  window.addEventListener('touchend', DD._endDragBefore, true);
2503
+ // add touchcancel to fix this: https://github.com/konvajs/konva/issues/1843
2504
+ window.addEventListener('touchcancel', DD._endDragBefore, true);
2503
2505
  window.addEventListener('mousemove', DD._drag);
2504
2506
  window.addEventListener('touchmove', DD._drag);
2505
2507
  window.addEventListener('mouseup', DD._endDragAfter, false);
2506
2508
  window.addEventListener('touchend', DD._endDragAfter, false);
2509
+ window.addEventListener('touchcancel', DD._endDragAfter, false);
2507
2510
  }
2508
2511
 
2509
2512
  // CONSTANTS
2510
- var ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER$1 = 'mouseenter', MOUSELEAVE$1 = 'mouseleave', SET = 'set', SHAPE = 'Shape', SPACE$1 = ' ', STAGE$1 = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR$1 = [
2513
+ const ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER$1 = 'mouseenter', MOUSELEAVE$1 = 'mouseleave', SET = 'set', SHAPE = 'Shape', SPACE$1 = ' ', STAGE$1 = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR$1 = [
2511
2514
  'xChange.konva',
2512
2515
  'yChange.konva',
2513
2516
  'scaleXChange.konva',
@@ -2590,11 +2593,11 @@
2590
2593
  }
2591
2594
  }
2592
2595
  _getCache(attr, privateGetter) {
2593
- var cache = this._cache.get(attr);
2596
+ let cache = this._cache.get(attr);
2594
2597
  // for transform the cache can be NOT empty
2595
2598
  // but we still need to recalculate it if it is dirty
2596
- var isTransform = attr === TRANSFORM || attr === ABSOLUTE_TRANSFORM;
2597
- var invalid = cache === undefined || (isTransform && cache.dirty === true);
2599
+ const isTransform = attr === TRANSFORM || attr === ABSOLUTE_TRANSFORM;
2600
+ const invalid = cache === undefined || (isTransform && cache.dirty === true);
2598
2601
  // if not cached, we need to set it using the private getter method.
2599
2602
  if (invalid) {
2600
2603
  cache = privateGetter.call(this);
@@ -2692,8 +2695,8 @@
2692
2695
  * });
2693
2696
  */
2694
2697
  cache(config) {
2695
- var conf = config || {};
2696
- var rect = {};
2698
+ const conf = config || {};
2699
+ let rect = {};
2697
2700
  // don't call getClientRect if we have all attributes
2698
2701
  // it means call it only if have one undefined
2699
2702
  if (conf.x === undefined ||
@@ -2705,7 +2708,7 @@
2705
2708
  relativeTo: this.getParent() || undefined,
2706
2709
  });
2707
2710
  }
2708
- var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? Math.floor(rect.x) : conf.x, y = conf.y === undefined ? Math.floor(rect.y) : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
2711
+ let width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? Math.floor(rect.x) : conf.x, y = conf.y === undefined ? Math.floor(rect.y) : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
2709
2712
  if (!width || !height) {
2710
2713
  Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');
2711
2714
  return;
@@ -2728,7 +2731,7 @@
2728
2731
  // // height += 1;
2729
2732
  // }
2730
2733
  // console.log({ x, y, width, height }, rect);
2731
- var cachedSceneCanvas = new SceneCanvas({
2734
+ const cachedSceneCanvas = new SceneCanvas({
2732
2735
  pixelRatio: pixelRatio,
2733
2736
  width: width,
2734
2737
  height: height,
@@ -2836,16 +2839,16 @@
2836
2839
  throw new Error('abstract "getClientRect" method call');
2837
2840
  }
2838
2841
  _transformedRect(rect, top) {
2839
- var points = [
2842
+ const points = [
2840
2843
  { x: rect.x, y: rect.y },
2841
2844
  { x: rect.x + rect.width, y: rect.y },
2842
2845
  { x: rect.x + rect.width, y: rect.y + rect.height },
2843
2846
  { x: rect.x, y: rect.y + rect.height },
2844
2847
  ];
2845
- var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
2846
- var trans = this.getAbsoluteTransform(top);
2848
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
2849
+ const trans = this.getAbsoluteTransform(top);
2847
2850
  points.forEach(function (point) {
2848
- var transformed = trans.point(point);
2851
+ const transformed = trans.point(point);
2849
2852
  if (minX === undefined) {
2850
2853
  minX = maxX = transformed.x;
2851
2854
  minY = maxY = transformed.y;
@@ -2868,23 +2871,23 @@
2868
2871
  context._applyGlobalCompositeOperation(this);
2869
2872
  const canvasCache = this._getCanvasCache();
2870
2873
  context.translate(canvasCache.x, canvasCache.y);
2871
- var cacheCanvas = this._getCachedSceneCanvas();
2872
- var ratio = cacheCanvas.pixelRatio;
2874
+ const cacheCanvas = this._getCachedSceneCanvas();
2875
+ const ratio = cacheCanvas.pixelRatio;
2873
2876
  context.drawImage(cacheCanvas._canvas, 0, 0, cacheCanvas.width / ratio, cacheCanvas.height / ratio);
2874
2877
  context.restore();
2875
2878
  }
2876
2879
  _drawCachedHitCanvas(context) {
2877
- var canvasCache = this._getCanvasCache(), hitCanvas = canvasCache.hit;
2880
+ const canvasCache = this._getCanvasCache(), hitCanvas = canvasCache.hit;
2878
2881
  context.save();
2879
2882
  context.translate(canvasCache.x, canvasCache.y);
2880
2883
  context.drawImage(hitCanvas._canvas, 0, 0, hitCanvas.width / hitCanvas.pixelRatio, hitCanvas.height / hitCanvas.pixelRatio);
2881
2884
  context.restore();
2882
2885
  }
2883
2886
  _getCachedSceneCanvas() {
2884
- var filters = this.filters(), cachedCanvas = this._getCanvasCache(), sceneCanvas = cachedCanvas.scene, filterCanvas = cachedCanvas.filter, filterContext = filterCanvas.getContext(), len, imageData, n, filter;
2887
+ let filters = this.filters(), cachedCanvas = this._getCanvasCache(), sceneCanvas = cachedCanvas.scene, filterCanvas = cachedCanvas.filter, filterContext = filterCanvas.getContext(), len, imageData, n, filter;
2885
2888
  if (filters) {
2886
2889
  if (!this._filterUpToDate) {
2887
- var ratio = sceneCanvas.pixelRatio;
2890
+ const ratio = sceneCanvas.pixelRatio;
2888
2891
  filterCanvas.setSize(sceneCanvas.width / sceneCanvas.pixelRatio, sceneCanvas.height / sceneCanvas.pixelRatio);
2889
2892
  try {
2890
2893
  len = filters.length;
@@ -2982,7 +2985,7 @@
2982
2985
  if (arguments.length === 3) {
2983
2986
  return this._delegate.apply(this, arguments);
2984
2987
  }
2985
- var events = evtStr.split(SPACE$1), len = events.length, n, event, parts, baseEvent, name;
2988
+ let events = evtStr.split(SPACE$1), len = events.length, n, event, parts, baseEvent, name;
2986
2989
  /*
2987
2990
  * loop through types and attach event listeners to
2988
2991
  * each one. eg. 'click mouseover.namespace mouseout'
@@ -3026,7 +3029,7 @@
3026
3029
  * node.off('click.foo');
3027
3030
  */
3028
3031
  off(evtStr, callback) {
3029
- var events = (evtStr || '').split(SPACE$1), len = events.length, n, t, event, parts, baseEvent, name;
3032
+ let events = (evtStr || '').split(SPACE$1), len = events.length, n, t, event, parts, baseEvent, name;
3030
3033
  this._cache && this._cache.delete(ALL_LISTENERS);
3031
3034
  if (!evtStr) {
3032
3035
  // remove all events
@@ -3054,7 +3057,7 @@
3054
3057
  }
3055
3058
  // some event aliases for third party integration like HammerJS
3056
3059
  dispatchEvent(evt) {
3057
- var e = {
3060
+ const e = {
3058
3061
  target: this,
3059
3062
  type: evt.type,
3060
3063
  evt: evt,
@@ -3075,10 +3078,10 @@
3075
3078
  }
3076
3079
  // like node.on
3077
3080
  _delegate(event, selector, handler) {
3078
- var stopNode = this;
3081
+ const stopNode = this;
3079
3082
  this.on(event, function (evt) {
3080
- var targets = evt.target.findAncestors(selector, true, stopNode);
3081
- for (var i = 0; i < targets.length; i++) {
3083
+ const targets = evt.target.findAncestors(selector, true, stopNode);
3084
+ for (let i = 0; i < targets.length; i++) {
3082
3085
  evt = Util.cloneObject(evt);
3083
3086
  evt.currentTarget = targets[i];
3084
3087
  handler.call(targets[i], evt);
@@ -3115,7 +3118,7 @@
3115
3118
  // every cached attr that is calculated via node tree
3116
3119
  // traversal must be cleared when removing a node
3117
3120
  this._clearCaches();
3118
- var parent = this.getParent();
3121
+ const parent = this.getParent();
3119
3122
  if (parent && parent.children) {
3120
3123
  parent.children.splice(this.index, 1);
3121
3124
  parent._setChildrenIndices();
@@ -3145,7 +3148,7 @@
3145
3148
  * var x = node.getAttr('x');
3146
3149
  */
3147
3150
  getAttr(attr) {
3148
- var method = 'get' + Util._capitalize(attr);
3151
+ const method = 'get' + Util._capitalize(attr);
3149
3152
  if (Util._isFunction(this[method])) {
3150
3153
  return this[method]();
3151
3154
  }
@@ -3163,7 +3166,7 @@
3163
3166
  * })
3164
3167
  */
3165
3168
  getAncestors() {
3166
- var parent = this.getParent(), ancestors = [];
3169
+ let parent = this.getParent(), ancestors = [];
3167
3170
  while (parent) {
3168
3171
  ancestors.push(parent);
3169
3172
  parent = parent.getParent();
@@ -3193,7 +3196,7 @@
3193
3196
  */
3194
3197
  setAttrs(config) {
3195
3198
  this._batchTransformChanges(() => {
3196
- var key, method;
3199
+ let key, method;
3197
3200
  if (!config) {
3198
3201
  return this;
3199
3202
  }
@@ -3279,8 +3282,8 @@
3279
3282
  if (top) {
3280
3283
  return this._isVisible(top) && this._isListening(top);
3281
3284
  }
3282
- var layer = this.getLayer();
3283
- var layerUnderDrag = false;
3285
+ const layer = this.getLayer();
3286
+ let layerUnderDrag = false;
3284
3287
  DD._dragElements.forEach((elem) => {
3285
3288
  if (elem.dragStatus !== 'dragging') {
3286
3289
  return;
@@ -3292,7 +3295,7 @@
3292
3295
  layerUnderDrag = true;
3293
3296
  }
3294
3297
  });
3295
- var dragSkip = !skipDragCheck &&
3298
+ const dragSkip = !skipDragCheck &&
3296
3299
  !Konva$2.hitOnDragEnabled &&
3297
3300
  (layerUnderDrag || Konva$2.isTransforming());
3298
3301
  return this.isListening() && this.isVisible() && !dragSkip;
@@ -3328,7 +3331,7 @@
3328
3331
  * @returns {Integer}
3329
3332
  */
3330
3333
  getAbsoluteZIndex() {
3331
- var depth = this.getDepth(), that = this, index = 0, nodes, len, n, child;
3334
+ let depth = this.getDepth(), that = this, index = 0, nodes, len, n, child;
3332
3335
  function addChildren(children) {
3333
3336
  nodes = [];
3334
3337
  len = children.length;
@@ -3361,7 +3364,7 @@
3361
3364
  * @returns {Integer}
3362
3365
  */
3363
3366
  getDepth() {
3364
- var depth = 0, parent = this.parent;
3367
+ let depth = 0, parent = this.parent;
3365
3368
  while (parent) {
3366
3369
  depth++;
3367
3370
  parent = parent.parent;
@@ -3413,11 +3416,11 @@
3413
3416
  return null;
3414
3417
  }
3415
3418
  // get pointer (say mouse or touch) position
3416
- var pos = stage.getPointerPosition();
3419
+ const pos = stage.getPointerPosition();
3417
3420
  if (!pos) {
3418
3421
  return null;
3419
3422
  }
3420
- var transform = this.getAbsoluteTransform().copy();
3423
+ const transform = this.getAbsoluteTransform().copy();
3421
3424
  // to detect relative position we need to invert transform
3422
3425
  transform.invert();
3423
3426
  // now we can find relative point
@@ -3453,7 +3456,7 @@
3453
3456
  // "true" is not a node, but it will just allow skip all caching
3454
3457
  top = true;
3455
3458
  }
3456
- var absoluteMatrix = this.getAbsoluteTransform(top).getMatrix(), absoluteTransform = new Transform(), offset = this.offset();
3459
+ const absoluteMatrix = this.getAbsoluteTransform(top).getMatrix(), absoluteTransform = new Transform(), offset = this.offset();
3457
3460
  // clone the matrix array
3458
3461
  absoluteTransform.m = absoluteMatrix.slice();
3459
3462
  absoluteTransform.translate(offset.x, offset.y);
@@ -3466,7 +3469,7 @@
3466
3469
  this.attrs.y = y;
3467
3470
  // important, use non cached value
3468
3471
  this._clearCache(TRANSFORM);
3469
- var it = this._getAbsoluteTransform().copy();
3472
+ const it = this._getAbsoluteTransform().copy();
3470
3473
  it.invert();
3471
3474
  it.translate(pos.x, pos.y);
3472
3475
  pos = {
@@ -3480,7 +3483,7 @@
3480
3483
  return this;
3481
3484
  }
3482
3485
  _setTransform(trans) {
3483
- var key;
3486
+ let key;
3484
3487
  for (key in trans) {
3485
3488
  this.attrs[key] = trans[key];
3486
3489
  }
@@ -3488,7 +3491,7 @@
3488
3491
  // this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);
3489
3492
  }
3490
3493
  _clearTransform() {
3491
- var trans = {
3494
+ const trans = {
3492
3495
  x: this.x(),
3493
3496
  y: this.y(),
3494
3497
  rotation: this.rotation(),
@@ -3527,7 +3530,7 @@
3527
3530
  * });
3528
3531
  */
3529
3532
  move(change) {
3530
- var changeX = change.x, changeY = change.y, x = this.x(), y = this.y();
3533
+ let changeX = change.x, changeY = change.y, x = this.x(), y = this.y();
3531
3534
  if (changeX !== undefined) {
3532
3535
  x += changeX;
3533
3536
  }
@@ -3538,7 +3541,7 @@
3538
3541
  return this;
3539
3542
  }
3540
3543
  _eachAncestorReverse(func, top) {
3541
- var family = [], parent = this.getParent(), len, n;
3544
+ let family = [], parent = this.getParent(), len, n;
3542
3545
  // if top node is defined, and this node is top node,
3543
3546
  // there's no need to build a family tree. just execute
3544
3547
  // func with this because it will be the only node
@@ -3578,7 +3581,7 @@
3578
3581
  Util.warn('Node has no parent. moveToTop function is ignored.');
3579
3582
  return false;
3580
3583
  }
3581
- var index = this.index, len = this.parent.getChildren().length;
3584
+ const index = this.index, len = this.parent.getChildren().length;
3582
3585
  if (index < len - 1) {
3583
3586
  this.parent.children.splice(index, 1);
3584
3587
  this.parent.children.push(this);
@@ -3598,7 +3601,7 @@
3598
3601
  Util.warn('Node has no parent. moveUp function is ignored.');
3599
3602
  return false;
3600
3603
  }
3601
- var index = this.index, len = this.parent.getChildren().length;
3604
+ const index = this.index, len = this.parent.getChildren().length;
3602
3605
  if (index < len - 1) {
3603
3606
  this.parent.children.splice(index, 1);
3604
3607
  this.parent.children.splice(index + 1, 0, this);
@@ -3618,7 +3621,7 @@
3618
3621
  Util.warn('Node has no parent. moveDown function is ignored.');
3619
3622
  return false;
3620
3623
  }
3621
- var index = this.index;
3624
+ const index = this.index;
3622
3625
  if (index > 0) {
3623
3626
  this.parent.children.splice(index, 1);
3624
3627
  this.parent.children.splice(index - 1, 0, this);
@@ -3638,7 +3641,7 @@
3638
3641
  Util.warn('Node has no parent. moveToBottom function is ignored.');
3639
3642
  return false;
3640
3643
  }
3641
- var index = this.index;
3644
+ const index = this.index;
3642
3645
  if (index > 0) {
3643
3646
  this.parent.children.splice(index, 1);
3644
3647
  this.parent.children.unshift(this);
@@ -3659,7 +3662,7 @@
3659
3662
  (this.parent.children.length - 1) +
3660
3663
  '.');
3661
3664
  }
3662
- var index = this.index;
3665
+ const index = this.index;
3663
3666
  this.parent.children.splice(index, 1);
3664
3667
  this.parent.children.splice(zIndex, 0, this);
3665
3668
  this.parent._setChildrenIndices();
@@ -3675,8 +3678,8 @@
3675
3678
  return this._getCache(ABSOLUTE_OPACITY, this._getAbsoluteOpacity);
3676
3679
  }
3677
3680
  _getAbsoluteOpacity() {
3678
- var absOpacity = this.opacity();
3679
- var parent = this.getParent();
3681
+ let absOpacity = this.opacity();
3682
+ const parent = this.getParent();
3680
3683
  if (parent && !parent._isUnderCache) {
3681
3684
  absOpacity *= parent.getAbsoluteOpacity();
3682
3685
  }
@@ -3707,7 +3710,7 @@
3707
3710
  * @returns {Object}
3708
3711
  */
3709
3712
  toObject() {
3710
- var attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;
3713
+ let attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;
3711
3714
  const obj = {
3712
3715
  attrs: {},
3713
3716
  className: this.getClassName(),
@@ -3764,11 +3767,11 @@
3764
3767
  * var parentGroups = node.findAncestors('Group');
3765
3768
  */
3766
3769
  findAncestors(selector, includeSelf, stopNode) {
3767
- var res = [];
3770
+ const res = [];
3768
3771
  if (includeSelf && this._isMatch(selector)) {
3769
3772
  res.push(this);
3770
3773
  }
3771
- var ancestor = this.parent;
3774
+ let ancestor = this.parent;
3772
3775
  while (ancestor) {
3773
3776
  if (ancestor === stopNode) {
3774
3777
  return res;
@@ -3806,7 +3809,7 @@
3806
3809
  if (typeof selector === 'function') {
3807
3810
  return selector(this);
3808
3811
  }
3809
- var selectorArr = selector.replace(/ /g, '').split(','), len = selectorArr.length, n, sel;
3812
+ let selectorArr = selector.replace(/ /g, '').split(','), len = selectorArr.length, n, sel;
3810
3813
  for (n = 0; n < len; n++) {
3811
3814
  sel = selectorArr[n];
3812
3815
  if (!Util.isValidSelector(sel)) {
@@ -3841,7 +3844,7 @@
3841
3844
  * @returns {Konva.Layer}
3842
3845
  */
3843
3846
  getLayer() {
3844
- var parent = this.getParent();
3847
+ const parent = this.getParent();
3845
3848
  return parent ? parent.getLayer() : null;
3846
3849
  }
3847
3850
  /**
@@ -3854,7 +3857,7 @@
3854
3857
  return this._getCache(STAGE$1, this._getStage);
3855
3858
  }
3856
3859
  _getStage() {
3857
- var parent = this.getParent();
3860
+ const parent = this.getParent();
3858
3861
  if (parent) {
3859
3862
  return parent.getStage();
3860
3863
  }
@@ -3916,13 +3919,13 @@
3916
3919
  }
3917
3920
  }
3918
3921
  _getAbsoluteTransform(top) {
3919
- var at;
3922
+ let at;
3920
3923
  // we we need position relative to an ancestor, we will iterate for all
3921
3924
  if (top) {
3922
3925
  at = new Transform();
3923
3926
  // start with stage and traverse downwards to self
3924
3927
  this._eachAncestorReverse(function (node) {
3925
- var transformsEnabled = node.transformsEnabled();
3928
+ const transformsEnabled = node.transformsEnabled();
3926
3929
  if (transformsEnabled === 'all') {
3927
3930
  at.multiply(node.getTransform());
3928
3931
  }
@@ -3942,7 +3945,7 @@
3942
3945
  else {
3943
3946
  at.reset();
3944
3947
  }
3945
- var transformsEnabled = this.transformsEnabled();
3948
+ const transformsEnabled = this.transformsEnabled();
3946
3949
  if (transformsEnabled === 'all') {
3947
3950
  at.multiply(this.getTransform());
3948
3951
  }
@@ -3972,7 +3975,7 @@
3972
3975
  // do not cache this calculations,
3973
3976
  // because it use cache transform
3974
3977
  // this is special logic for caching with some shapes with shadow
3975
- var parent = this;
3978
+ let parent = this;
3976
3979
  while (parent) {
3977
3980
  if (parent._isUnderCache) {
3978
3981
  top = parent;
@@ -4017,12 +4020,12 @@
4017
4020
  }
4018
4021
  _getTransform() {
4019
4022
  var _a, _b;
4020
- var m = this._cache.get(TRANSFORM) || new Transform();
4023
+ const m = this._cache.get(TRANSFORM) || new Transform();
4021
4024
  m.reset();
4022
4025
  // I was trying to use attributes directly here
4023
4026
  // but it doesn't work for Transformer well
4024
4027
  // because it overwrite x,y getters
4025
- var x = this.x(), y = this.y(), rotation = Konva$2.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
4028
+ const x = this.x(), y = this.y(), rotation = Konva$2.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
4026
4029
  if (x !== 0 || y !== 0) {
4027
4030
  m.translate(x, y);
4028
4031
  }
@@ -4060,12 +4063,12 @@
4060
4063
  */
4061
4064
  clone(obj) {
4062
4065
  // instantiate new node
4063
- var attrs = Util.cloneObject(this.attrs), key, allListeners, len, n, listener;
4066
+ let attrs = Util.cloneObject(this.attrs), key, allListeners, len, n, listener;
4064
4067
  // apply attr overrides
4065
4068
  for (key in obj) {
4066
4069
  attrs[key] = obj[key];
4067
4070
  }
4068
- var node = new this.constructor(attrs);
4071
+ const node = new this.constructor(attrs);
4069
4072
  // copy over listeners
4070
4073
  for (key in this.eventListeners) {
4071
4074
  allListeners = this.eventListeners[key];
@@ -4089,8 +4092,8 @@
4089
4092
  }
4090
4093
  _toKonvaCanvas(config) {
4091
4094
  config = config || {};
4092
- var box = this.getClientRect();
4093
- var stage = this.getStage(), x = config.x !== undefined ? config.x : Math.floor(box.x), y = config.y !== undefined ? config.y : Math.floor(box.y), pixelRatio = config.pixelRatio || 1, canvas = new SceneCanvas({
4095
+ const box = this.getClientRect();
4096
+ const stage = this.getStage(), x = config.x !== undefined ? config.x : Math.floor(box.x), y = config.y !== undefined ? config.y : Math.floor(box.y), pixelRatio = config.pixelRatio || 1, canvas = new SceneCanvas({
4094
4097
  width: config.width || Math.ceil(box.width) || (stage ? stage.width() : 0),
4095
4098
  height: config.height ||
4096
4099
  Math.ceil(box.height) ||
@@ -4162,8 +4165,8 @@
4162
4165
  */
4163
4166
  toDataURL(config) {
4164
4167
  config = config || {};
4165
- var mimeType = config.mimeType || null, quality = config.quality || null;
4166
- var url = this._toKonvaCanvas(config).toDataURL(mimeType, quality);
4168
+ const mimeType = config.mimeType || null, quality = config.quality || null;
4169
+ const url = this._toKonvaCanvas(config).toDataURL(mimeType, quality);
4167
4170
  if (config.callback) {
4168
4171
  config.callback(url);
4169
4172
  }
@@ -4295,7 +4298,7 @@
4295
4298
  }
4296
4299
  }
4297
4300
  _off(type, name, callback) {
4298
- var evtListeners = this.eventListeners[type], i, evtName, handler;
4301
+ let evtListeners = this.eventListeners[type], i, evtName, handler;
4299
4302
  for (i = 0; i < evtListeners.length; i++) {
4300
4303
  evtName = evtListeners[i].name;
4301
4304
  handler = evtListeners[i].handler;
@@ -4334,8 +4337,8 @@
4334
4337
  */
4335
4338
  addName(name) {
4336
4339
  if (!this.hasName(name)) {
4337
- var oldName = this.name();
4338
- var newName = oldName ? oldName + ' ' + name : name;
4340
+ const oldName = this.name();
4341
+ const newName = oldName ? oldName + ' ' + name : name;
4339
4342
  this.name(newName);
4340
4343
  }
4341
4344
  return this;
@@ -4361,7 +4364,7 @@
4361
4364
  return false;
4362
4365
  }
4363
4366
  // if name is '' the "names" will be [''], so I added extra check above
4364
- var names = (fullName || '').split(/\s/g);
4367
+ const names = (fullName || '').split(/\s/g);
4365
4368
  return names.indexOf(name) !== -1;
4366
4369
  }
4367
4370
  /**
@@ -4377,8 +4380,8 @@
4377
4380
  * node.name(); // return 'red'
4378
4381
  */
4379
4382
  removeName(name) {
4380
- var names = (this.name() || '').split(/\s/g);
4381
- var index = names.indexOf(name);
4383
+ const names = (this.name() || '').split(/\s/g);
4384
+ const index = names.indexOf(name);
4382
4385
  if (index !== -1) {
4383
4386
  names.splice(index, 1);
4384
4387
  this.name(names.join(' '));
@@ -4396,7 +4399,7 @@
4396
4399
  * node.setAttr('x', 5);
4397
4400
  */
4398
4401
  setAttr(attr, val) {
4399
- var func = this[SET + Util._capitalize(attr)];
4402
+ const func = this[SET + Util._capitalize(attr)];
4400
4403
  if (Util._isFunction(func)) {
4401
4404
  func.call(this, val);
4402
4405
  }
@@ -4413,7 +4416,7 @@
4413
4416
  }
4414
4417
  }
4415
4418
  _setAttr(key, val) {
4416
- var oldVal = this.attrs[key];
4419
+ const oldVal = this.attrs[key];
4417
4420
  if (oldVal === val && !Util.isObject(val)) {
4418
4421
  return;
4419
4422
  }
@@ -4429,7 +4432,7 @@
4429
4432
  this._requestDraw();
4430
4433
  }
4431
4434
  _setComponentAttr(key, component, val) {
4432
- var oldVal;
4435
+ let oldVal;
4433
4436
  if (val !== undefined) {
4434
4437
  oldVal = this.attrs[key];
4435
4438
  if (!oldVal) {
@@ -4444,7 +4447,7 @@
4444
4447
  if (evt && this.nodeType === SHAPE) {
4445
4448
  evt.target = this;
4446
4449
  }
4447
- var shouldStop = (eventType === MOUSEENTER$1 || eventType === MOUSELEAVE$1) &&
4450
+ const shouldStop = (eventType === MOUSEENTER$1 || eventType === MOUSELEAVE$1) &&
4448
4451
  ((compareShape &&
4449
4452
  (this === compareShape ||
4450
4453
  (this.isAncestorOf && this.isAncestorOf(compareShape)))) ||
@@ -4452,7 +4455,7 @@
4452
4455
  if (!shouldStop) {
4453
4456
  this._fire(eventType, evt);
4454
4457
  // simulate event bubbling
4455
- var stopBubble = (eventType === MOUSEENTER$1 || eventType === MOUSELEAVE$1) &&
4458
+ const stopBubble = (eventType === MOUSEENTER$1 || eventType === MOUSELEAVE$1) &&
4456
4459
  compareShape &&
4457
4460
  compareShape.isAncestorOf &&
4458
4461
  compareShape.isAncestorOf(this) &&
@@ -4521,13 +4524,13 @@
4521
4524
  }
4522
4525
  // drag & drop
4523
4526
  _createDragElement(evt) {
4524
- var pointerId = evt ? evt.pointerId : undefined;
4525
- var stage = this.getStage();
4526
- var ap = this.getAbsolutePosition();
4527
+ const pointerId = evt ? evt.pointerId : undefined;
4528
+ const stage = this.getStage();
4529
+ const ap = this.getAbsolutePosition();
4527
4530
  if (!stage) {
4528
4531
  return;
4529
4532
  }
4530
- var pos = stage._getPointerById(pointerId) ||
4533
+ const pos = stage._getPointerById(pointerId) ||
4531
4534
  stage._changedPointerPositions[0] ||
4532
4535
  ap;
4533
4536
  DD._dragElements.set(this._id, {
@@ -4565,11 +4568,11 @@
4565
4568
  if (!pos) {
4566
4569
  return;
4567
4570
  }
4568
- var newNodePos = {
4571
+ let newNodePos = {
4569
4572
  x: pos.x - elem.offset.x,
4570
4573
  y: pos.y - elem.offset.y,
4571
4574
  };
4572
- var dbf = this.dragBoundFunc();
4575
+ const dbf = this.dragBoundFunc();
4573
4576
  if (dbf !== undefined) {
4574
4577
  const bounded = dbf.call(this, newNodePos, evt);
4575
4578
  if (!bounded) {
@@ -4616,15 +4619,15 @@
4616
4619
  _listenDrag() {
4617
4620
  this._dragCleanup();
4618
4621
  this.on('mousedown.konva touchstart.konva', function (evt) {
4619
- var shouldCheckButton = evt.evt['button'] !== undefined;
4620
- var canDrag = !shouldCheckButton || Konva$2.dragButtons.indexOf(evt.evt['button']) >= 0;
4622
+ const shouldCheckButton = evt.evt['button'] !== undefined;
4623
+ const canDrag = !shouldCheckButton || Konva$2.dragButtons.indexOf(evt.evt['button']) >= 0;
4621
4624
  if (!canDrag) {
4622
4625
  return;
4623
4626
  }
4624
4627
  if (this.isDragging()) {
4625
4628
  return;
4626
4629
  }
4627
- var hasDraggingChild = false;
4630
+ let hasDraggingChild = false;
4628
4631
  DD._dragElements.forEach((elem) => {
4629
4632
  if (this.isAncestorOf(elem.node)) {
4630
4633
  hasDraggingChild = true;
@@ -4649,7 +4652,7 @@
4649
4652
  * if this node is currently in
4650
4653
  * drag and drop mode
4651
4654
  */
4652
- var stage = this.getStage();
4655
+ const stage = this.getStage();
4653
4656
  if (!stage) {
4654
4657
  return;
4655
4658
  }
@@ -4716,7 +4719,7 @@
4716
4719
  return this._createNode(data, container);
4717
4720
  }
4718
4721
  static _createNode(obj, container) {
4719
- var className = Node.prototype.getClassName.call(obj), children = obj.children, no, len, n;
4722
+ let className = Node.prototype.getClassName.call(obj), children = obj.children, no, len, n;
4720
4723
  // if container was passed in, add it to attrs
4721
4724
  if (container) {
4722
4725
  obj.attrs.container = container;
@@ -5328,7 +5331,7 @@
5328
5331
  return this.children || [];
5329
5332
  }
5330
5333
  const children = this.children || [];
5331
- var results = [];
5334
+ const results = [];
5332
5335
  children.forEach(function (child) {
5333
5336
  if (filterFunc(child)) {
5334
5337
  results.push(child);
@@ -5399,7 +5402,7 @@
5399
5402
  return this;
5400
5403
  }
5401
5404
  if (children.length > 1) {
5402
- for (var i = 0; i < children.length; i++) {
5405
+ for (let i = 0; i < children.length; i++) {
5403
5406
  this.add(children[i]);
5404
5407
  }
5405
5408
  return this;
@@ -5492,11 +5495,11 @@
5492
5495
  * })
5493
5496
  */
5494
5497
  findOne(selector) {
5495
- var result = this._generalFind(selector, true);
5498
+ const result = this._generalFind(selector, true);
5496
5499
  return result.length > 0 ? result[0] : undefined;
5497
5500
  }
5498
5501
  _generalFind(selector, findOne) {
5499
- var retArr = [];
5502
+ const retArr = [];
5500
5503
  this._descendants((node) => {
5501
5504
  const valid = node._isMatch(selector);
5502
5505
  if (valid) {
@@ -5529,7 +5532,7 @@
5529
5532
  }
5530
5533
  // extenders
5531
5534
  toObject() {
5532
- var obj = Node.prototype.toObject.call(this);
5535
+ const obj = Node.prototype.toObject.call(this);
5533
5536
  obj.children = [];
5534
5537
  this.getChildren().forEach((child) => {
5535
5538
  obj.children.push(child.toObject());
@@ -5544,7 +5547,7 @@
5544
5547
  * @param {Konva.Node} node
5545
5548
  */
5546
5549
  isAncestorOf(node) {
5547
- var parent = node.getParent();
5550
+ let parent = node.getParent();
5548
5551
  while (parent) {
5549
5552
  if (parent._id === this._id) {
5550
5553
  return true;
@@ -5555,7 +5558,7 @@
5555
5558
  }
5556
5559
  clone(obj) {
5557
5560
  // call super method
5558
- var node = Node.prototype.clone.call(this, obj);
5561
+ const node = Node.prototype.clone.call(this, obj);
5559
5562
  this.getChildren().forEach(function (no) {
5560
5563
  node.add(no.clone());
5561
5564
  });
@@ -5575,7 +5578,7 @@
5575
5578
  * @returns {Array} array of shapes
5576
5579
  */
5577
5580
  getAllIntersections(pos) {
5578
- var arr = [];
5581
+ const arr = [];
5579
5582
  this.find('Shape').forEach((shape) => {
5580
5583
  if (shape.isVisible() && shape.intersects(pos)) {
5581
5584
  arr.push(shape);
@@ -5603,14 +5606,14 @@
5603
5606
  this._requestDraw();
5604
5607
  }
5605
5608
  drawScene(can, top, bufferCanvas) {
5606
- var layer = this.getLayer(), canvas = can || (layer && layer.getCanvas()), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedSceneCanvas = cachedCanvas && cachedCanvas.scene;
5607
- var caching = canvas && canvas.isCache;
5609
+ const layer = this.getLayer(), canvas = can || (layer && layer.getCanvas()), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedSceneCanvas = cachedCanvas && cachedCanvas.scene;
5610
+ const caching = canvas && canvas.isCache;
5608
5611
  if (!this.isVisible() && !caching) {
5609
5612
  return this;
5610
5613
  }
5611
5614
  if (cachedSceneCanvas) {
5612
5615
  context.save();
5613
- var m = this.getAbsoluteTransform(top).getMatrix();
5616
+ const m = this.getAbsoluteTransform(top).getMatrix();
5614
5617
  context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
5615
5618
  this._drawCachedSceneCanvas(context);
5616
5619
  context.restore();
@@ -5624,10 +5627,10 @@
5624
5627
  if (!this.shouldDrawHit(top)) {
5625
5628
  return this;
5626
5629
  }
5627
- var layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
5630
+ const layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
5628
5631
  if (cachedHitCanvas) {
5629
5632
  context.save();
5630
- var m = this.getAbsoluteTransform(top).getMatrix();
5633
+ const m = this.getAbsoluteTransform(top).getMatrix();
5631
5634
  context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
5632
5635
  this._drawCachedHitCanvas(context);
5633
5636
  context.restore();
@@ -5639,13 +5642,13 @@
5639
5642
  }
5640
5643
  _drawChildren(drawMethod, canvas, top, bufferCanvas) {
5641
5644
  var _a;
5642
- var context = canvas && canvas.getContext(), clipWidth = this.clipWidth(), clipHeight = this.clipHeight(), clipFunc = this.clipFunc(), hasClip = (typeof clipWidth === 'number' && typeof clipHeight === 'number') ||
5645
+ const context = canvas && canvas.getContext(), clipWidth = this.clipWidth(), clipHeight = this.clipHeight(), clipFunc = this.clipFunc(), hasClip = (typeof clipWidth === 'number' && typeof clipHeight === 'number') ||
5643
5646
  clipFunc;
5644
5647
  const selfCache = top === this;
5645
5648
  if (hasClip) {
5646
5649
  context.save();
5647
- var transform = this.getAbsoluteTransform(top);
5648
- var m = transform.getMatrix();
5650
+ const transform = this.getAbsoluteTransform(top);
5651
+ let m = transform.getMatrix();
5649
5652
  context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
5650
5653
  context.beginPath();
5651
5654
  let clipArgs;
@@ -5653,15 +5656,15 @@
5653
5656
  clipArgs = clipFunc.call(this, context, this);
5654
5657
  }
5655
5658
  else {
5656
- var clipX = this.clipX();
5657
- var clipY = this.clipY();
5659
+ const clipX = this.clipX();
5660
+ const clipY = this.clipY();
5658
5661
  context.rect(clipX || 0, clipY || 0, clipWidth, clipHeight);
5659
5662
  }
5660
5663
  context.clip.apply(context, clipArgs);
5661
5664
  m = transform.copy().invert().getMatrix();
5662
5665
  context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
5663
5666
  }
5664
- var hasComposition = !selfCache &&
5667
+ const hasComposition = !selfCache &&
5665
5668
  this.globalCompositeOperation() !== 'source-over' &&
5666
5669
  drawMethod === 'drawScene';
5667
5670
  if (hasComposition) {
@@ -5680,22 +5683,22 @@
5680
5683
  }
5681
5684
  getClientRect(config = {}) {
5682
5685
  var _a;
5683
- var skipTransform = config.skipTransform;
5684
- var relativeTo = config.relativeTo;
5685
- var minX, minY, maxX, maxY;
5686
- var selfRect = {
5686
+ const skipTransform = config.skipTransform;
5687
+ const relativeTo = config.relativeTo;
5688
+ let minX, minY, maxX, maxY;
5689
+ let selfRect = {
5687
5690
  x: Infinity,
5688
5691
  y: Infinity,
5689
5692
  width: 0,
5690
5693
  height: 0,
5691
5694
  };
5692
- var that = this;
5695
+ const that = this;
5693
5696
  (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
5694
5697
  // skip invisible children
5695
5698
  if (!child.visible()) {
5696
5699
  return;
5697
5700
  }
5698
- var rect = child.getClientRect({
5701
+ const rect = child.getClientRect({
5699
5702
  relativeTo: that,
5700
5703
  skipShadow: config.skipShadow,
5701
5704
  skipStroke: config.skipStroke,
@@ -5719,10 +5722,10 @@
5719
5722
  }
5720
5723
  });
5721
5724
  // if child is group we need to make sure it has visible shapes inside
5722
- var shapes = this.find('Shape');
5723
- var hasVisible = false;
5724
- for (var i = 0; i < shapes.length; i++) {
5725
- var shape = shapes[i];
5725
+ const shapes = this.find('Shape');
5726
+ let hasVisible = false;
5727
+ for (let i = 0; i < shapes.length; i++) {
5728
+ const shape = shapes[i];
5726
5729
  if (shape._isVisible(this)) {
5727
5730
  hasVisible = true;
5728
5731
  break;
@@ -5896,7 +5899,7 @@
5896
5899
  }
5897
5900
 
5898
5901
  // CONSTANTS
5899
- var STAGE = 'Stage', STRING = 'string', PX = 'px', MOUSEOUT = 'mouseout', MOUSELEAVE = 'mouseleave', MOUSEOVER = 'mouseover', MOUSEENTER = 'mouseenter', MOUSEMOVE = 'mousemove', MOUSEDOWN = 'mousedown', MOUSEUP = 'mouseup', POINTERMOVE = 'pointermove', POINTERDOWN = 'pointerdown', POINTERUP = 'pointerup', POINTERCANCEL = 'pointercancel', LOSTPOINTERCAPTURE = 'lostpointercapture', POINTEROUT = 'pointerout', POINTERLEAVE = 'pointerleave', POINTEROVER = 'pointerover', POINTERENTER = 'pointerenter', CONTEXTMENU = 'contextmenu', TOUCHSTART = 'touchstart', TOUCHEND = 'touchend', TOUCHMOVE = 'touchmove', TOUCHCANCEL = 'touchcancel', WHEEL = 'wheel', MAX_LAYERS_NUMBER = 5, EVENTS = [
5902
+ const STAGE = 'Stage', STRING = 'string', PX = 'px', MOUSEOUT = 'mouseout', MOUSELEAVE = 'mouseleave', MOUSEOVER = 'mouseover', MOUSEENTER = 'mouseenter', MOUSEMOVE = 'mousemove', MOUSEDOWN = 'mousedown', MOUSEUP = 'mouseup', POINTERMOVE = 'pointermove', POINTERDOWN = 'pointerdown', POINTERUP = 'pointerup', POINTERCANCEL = 'pointercancel', LOSTPOINTERCAPTURE = 'lostpointercapture', POINTEROUT = 'pointerout', POINTERLEAVE = 'pointerleave', POINTEROVER = 'pointerover', POINTERENTER = 'pointerenter', CONTEXTMENU = 'contextmenu', TOUCHSTART = 'touchstart', TOUCHEND = 'touchend', TOUCHMOVE = 'touchmove', TOUCHCANCEL = 'touchcancel', WHEEL = 'wheel', MAX_LAYERS_NUMBER = 5, EVENTS = [
5900
5903
  [MOUSEENTER, '_pointerenter'],
5901
5904
  [MOUSEDOWN, '_pointerdown'],
5902
5905
  [MOUSEMOVE, '_pointermove'],
@@ -6055,7 +6058,7 @@
6055
6058
  setContainer(container) {
6056
6059
  if (typeof container === STRING) {
6057
6060
  if (container.charAt(0) === '.') {
6058
- var className = container.slice(1);
6061
+ const className = container.slice(1);
6059
6062
  container = document.getElementsByClassName(className)[0];
6060
6063
  }
6061
6064
  else {
@@ -6090,7 +6093,7 @@
6090
6093
  * @name Konva.Stage#clear
6091
6094
  */
6092
6095
  clear() {
6093
- var layers = this.children, len = layers.length, n;
6096
+ let layers = this.children, len = layers.length, n;
6094
6097
  for (n = 0; n < len; n++) {
6095
6098
  layers[n].clear();
6096
6099
  }
@@ -6106,11 +6109,11 @@
6106
6109
  }
6107
6110
  destroy() {
6108
6111
  super.destroy();
6109
- var content = this.content;
6112
+ const content = this.content;
6110
6113
  if (content && Util._isInDocument(content)) {
6111
6114
  this.container().removeChild(content);
6112
6115
  }
6113
- var index = stages.indexOf(this);
6116
+ const index = stages.indexOf(this);
6114
6117
  if (index > -1) {
6115
6118
  stages.splice(index, 1);
6116
6119
  }
@@ -6154,13 +6157,13 @@
6154
6157
  config.y = config.y || 0;
6155
6158
  config.width = config.width || this.width();
6156
6159
  config.height = config.height || this.height();
6157
- var canvas = new SceneCanvas({
6160
+ const canvas = new SceneCanvas({
6158
6161
  width: config.width,
6159
6162
  height: config.height,
6160
6163
  pixelRatio: config.pixelRatio || 1,
6161
6164
  });
6162
- var _context = canvas.getContext()._context;
6163
- var layers = this.children;
6165
+ const _context = canvas.getContext()._context;
6166
+ const layers = this.children;
6164
6167
  if (config.x || config.y) {
6165
6168
  _context.translate(-1 * config.x, -1 * config.y);
6166
6169
  }
@@ -6168,7 +6171,7 @@
6168
6171
  if (!layer.isVisible()) {
6169
6172
  return;
6170
6173
  }
6171
- var layerCanvas = layer._toKonvaCanvas(config);
6174
+ const layerCanvas = layer._toKonvaCanvas(config);
6172
6175
  _context.drawImage(layerCanvas._canvas, config.x, config.y, layerCanvas.getWidth() / layerCanvas.getPixelRatio(), layerCanvas.getHeight() / layerCanvas.getPixelRatio());
6173
6176
  });
6174
6177
  return canvas;
@@ -6190,7 +6193,7 @@
6190
6193
  if (!pos) {
6191
6194
  return null;
6192
6195
  }
6193
- var layers = this.children, len = layers.length, end = len - 1, n;
6196
+ let layers = this.children, len = layers.length, end = len - 1, n;
6194
6197
  for (n = end; n >= 0; n--) {
6195
6198
  const shape = layers[n].getIntersection(pos);
6196
6199
  if (shape) {
@@ -6200,8 +6203,8 @@
6200
6203
  return null;
6201
6204
  }
6202
6205
  _resizeDOM() {
6203
- var width = this.width();
6204
- var height = this.height();
6206
+ const width = this.width();
6207
+ const height = this.height();
6205
6208
  if (this.content) {
6206
6209
  // set content dimensions
6207
6210
  this.content.style.width = width + PX;
@@ -6217,13 +6220,13 @@
6217
6220
  }
6218
6221
  add(layer, ...rest) {
6219
6222
  if (arguments.length > 1) {
6220
- for (var i = 0; i < arguments.length; i++) {
6223
+ for (let i = 0; i < arguments.length; i++) {
6221
6224
  this.add(arguments[i]);
6222
6225
  }
6223
6226
  return this;
6224
6227
  }
6225
6228
  super.add(layer);
6226
- var length = this.children.length;
6229
+ const length = this.children.length;
6227
6230
  if (length > MAX_LAYERS_NUMBER) {
6228
6231
  Util.warn('The stage has ' +
6229
6232
  length +
@@ -6307,8 +6310,8 @@
6307
6310
  return;
6308
6311
  }
6309
6312
  this.setPointersPositions(evt);
6310
- var targetShape = this._getTargetShape(eventType);
6311
- var eventsEnabled = !(Konva$2.isDragging() || Konva$2.isTransforming()) || Konva$2.hitOnDragEnabled;
6313
+ const targetShape = this._getTargetShape(eventType);
6314
+ const eventsEnabled = !(Konva$2.isDragging() || Konva$2.isTransforming()) || Konva$2.hitOnDragEnabled;
6312
6315
  if (targetShape && eventsEnabled) {
6313
6316
  targetShape._fireAndBubble(events.pointerout, { evt: evt });
6314
6317
  targetShape._fireAndBubble(events.pointerleave, { evt: evt });
@@ -6341,9 +6344,9 @@
6341
6344
  return;
6342
6345
  }
6343
6346
  this.setPointersPositions(evt);
6344
- var triggeredOnShape = false;
6347
+ let triggeredOnShape = false;
6345
6348
  this._changedPointerPositions.forEach((pos) => {
6346
- var shape = this.getIntersection(pos);
6349
+ const shape = this.getIntersection(pos);
6347
6350
  DD.justDragged = false;
6348
6351
  // probably we are staring a click
6349
6352
  Konva$2['_' + eventType + 'ListenClick'] = true;
@@ -6389,19 +6392,19 @@
6389
6392
  evt.preventDefault();
6390
6393
  }
6391
6394
  this.setPointersPositions(evt);
6392
- var eventsEnabled = !(Konva$2.isDragging() || Konva$2.isTransforming()) || Konva$2.hitOnDragEnabled;
6395
+ const eventsEnabled = !(Konva$2.isDragging() || Konva$2.isTransforming()) || Konva$2.hitOnDragEnabled;
6393
6396
  if (!eventsEnabled) {
6394
6397
  return;
6395
6398
  }
6396
- var processedShapesIds = {};
6399
+ const processedShapesIds = {};
6397
6400
  let triggeredOnShape = false;
6398
- var targetShape = this._getTargetShape(eventType);
6401
+ const targetShape = this._getTargetShape(eventType);
6399
6402
  this._changedPointerPositions.forEach((pos) => {
6400
6403
  const shape = (getCapturedShape(pos.id) ||
6401
6404
  this.getIntersection(pos));
6402
6405
  const pointerId = pos.id;
6403
6406
  const event = { evt: evt, pointerId };
6404
- var differentTarget = targetShape !== shape;
6407
+ const differentTarget = targetShape !== shape;
6405
6408
  if (differentTarget && targetShape) {
6406
6409
  targetShape._fireAndBubble(events.pointerout, { ...event }, shape);
6407
6410
  targetShape._fireAndBubble(events.pointerleave, { ...event }, shape);
@@ -6451,7 +6454,7 @@
6451
6454
  this.setPointersPositions(evt);
6452
6455
  const clickStartShape = this[eventType + 'ClickStartShape'];
6453
6456
  const clickEndShape = this[eventType + 'ClickEndShape'];
6454
- var processedShapesIds = {};
6457
+ const processedShapesIds = {};
6455
6458
  let triggeredOnShape = false;
6456
6459
  this._changedPointerPositions.forEach((pos) => {
6457
6460
  const shape = (getCapturedShape(pos.id) ||
@@ -6532,7 +6535,7 @@
6532
6535
  }
6533
6536
  _contextmenu(evt) {
6534
6537
  this.setPointersPositions(evt);
6535
- var shape = this.getIntersection(this.getPointerPosition());
6538
+ const shape = this.getIntersection(this.getPointerPosition());
6536
6539
  if (shape && shape.isListening()) {
6537
6540
  shape._fireAndBubble(CONTEXTMENU, { evt: evt });
6538
6541
  }
@@ -6546,7 +6549,7 @@
6546
6549
  }
6547
6550
  _wheel(evt) {
6548
6551
  this.setPointersPositions(evt);
6549
- var shape = this.getIntersection(this.getPointerPosition());
6552
+ const shape = this.getIntersection(this.getPointerPosition());
6550
6553
  if (shape && shape.isListening()) {
6551
6554
  shape._fireAndBubble(WHEEL, { evt: evt });
6552
6555
  }
@@ -6585,7 +6588,7 @@
6585
6588
  * });
6586
6589
  */
6587
6590
  setPointersPositions(evt) {
6588
- var contentPosition = this._getContentPosition(), x = null, y = null;
6591
+ let contentPosition = this._getContentPosition(), x = null, y = null;
6589
6592
  evt = evt ? evt : window.event;
6590
6593
  // touch events
6591
6594
  if (evt.touches !== undefined) {
@@ -6635,7 +6638,7 @@
6635
6638
  scaleY: 1,
6636
6639
  };
6637
6640
  }
6638
- var rect = this.content.getBoundingClientRect();
6641
+ const rect = this.content.getBoundingClientRect();
6639
6642
  return {
6640
6643
  top: rect.top,
6641
6644
  left: rect.left,
@@ -6658,7 +6661,7 @@
6658
6661
  if (!Konva$2.isBrowser) {
6659
6662
  return;
6660
6663
  }
6661
- var container = this.container();
6664
+ const container = this.container();
6662
6665
  if (!container) {
6663
6666
  throw 'Stage has no container. A container is required.';
6664
6667
  }
@@ -6722,11 +6725,11 @@
6722
6725
  });
6723
6726
  }
6724
6727
 
6725
- var HAS_SHADOW = 'hasShadow';
6726
- var SHADOW_RGBA = 'shadowRGBA';
6727
- var patternImage = 'patternImage';
6728
- var linearGradient = 'linearGradient';
6729
- var radialGradient = 'radialGradient';
6728
+ const HAS_SHADOW = 'hasShadow';
6729
+ const SHADOW_RGBA = 'shadowRGBA';
6730
+ const patternImage = 'patternImage';
6731
+ const linearGradient = 'linearGradient';
6732
+ const radialGradient = 'radialGradient';
6730
6733
  let dummyContext$1;
6731
6734
  function getDummyContext$1() {
6732
6735
  if (dummyContext$1) {
@@ -6928,7 +6931,7 @@
6928
6931
  }
6929
6932
  __getFillPattern() {
6930
6933
  if (this.fillPatternImage()) {
6931
- var ctx = getDummyContext$1();
6934
+ const ctx = getDummyContext$1();
6932
6935
  const pattern = ctx.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || 'repeat');
6933
6936
  if (pattern && pattern.setTransform) {
6934
6937
  const tr = new Transform();
@@ -6956,14 +6959,14 @@
6956
6959
  return this._getCache(linearGradient, this.__getLinearGradient);
6957
6960
  }
6958
6961
  __getLinearGradient() {
6959
- var colorStops = this.fillLinearGradientColorStops();
6962
+ const colorStops = this.fillLinearGradientColorStops();
6960
6963
  if (colorStops) {
6961
- var ctx = getDummyContext$1();
6962
- var start = this.fillLinearGradientStartPoint();
6963
- var end = this.fillLinearGradientEndPoint();
6964
- var grd = ctx.createLinearGradient(start.x, start.y, end.x, end.y);
6964
+ const ctx = getDummyContext$1();
6965
+ const start = this.fillLinearGradientStartPoint();
6966
+ const end = this.fillLinearGradientEndPoint();
6967
+ const grd = ctx.createLinearGradient(start.x, start.y, end.x, end.y);
6965
6968
  // build color stops
6966
- for (var n = 0; n < colorStops.length; n += 2) {
6969
+ for (let n = 0; n < colorStops.length; n += 2) {
6967
6970
  grd.addColorStop(colorStops[n], colorStops[n + 1]);
6968
6971
  }
6969
6972
  return grd;
@@ -6973,14 +6976,14 @@
6973
6976
  return this._getCache(radialGradient, this.__getRadialGradient);
6974
6977
  }
6975
6978
  __getRadialGradient() {
6976
- var colorStops = this.fillRadialGradientColorStops();
6979
+ const colorStops = this.fillRadialGradientColorStops();
6977
6980
  if (colorStops) {
6978
- var ctx = getDummyContext$1();
6979
- var start = this.fillRadialGradientStartPoint();
6980
- var end = this.fillRadialGradientEndPoint();
6981
- var grd = ctx.createRadialGradient(start.x, start.y, this.fillRadialGradientStartRadius(), end.x, end.y, this.fillRadialGradientEndRadius());
6981
+ const ctx = getDummyContext$1();
6982
+ const start = this.fillRadialGradientStartPoint();
6983
+ const end = this.fillRadialGradientEndPoint();
6984
+ const grd = ctx.createRadialGradient(start.x, start.y, this.fillRadialGradientStartRadius(), end.x, end.y, this.fillRadialGradientEndRadius());
6982
6985
  // build color stops
6983
- for (var n = 0; n < colorStops.length; n += 2) {
6986
+ for (let n = 0; n < colorStops.length; n += 2) {
6984
6987
  grd.addColorStop(colorStops[n], colorStops[n + 1]);
6985
6988
  }
6986
6989
  return grd;
@@ -6993,7 +6996,7 @@
6993
6996
  if (!this.hasShadow()) {
6994
6997
  return;
6995
6998
  }
6996
- var rgba = Util.colorToRGBA(this.shadowColor());
6999
+ const rgba = Util.colorToRGBA(this.shadowColor());
6997
7000
  if (rgba) {
6998
7001
  return ('rgba(' +
6999
7002
  rgba.r +
@@ -7076,7 +7079,7 @@
7076
7079
  * @returns {Boolean}
7077
7080
  */
7078
7081
  intersects(point) {
7079
- var stage = this.getStage();
7082
+ const stage = this.getStage();
7080
7083
  if (!stage) {
7081
7084
  return false;
7082
7085
  }
@@ -7148,7 +7151,7 @@
7148
7151
  *
7149
7152
  */
7150
7153
  getSelfRect() {
7151
- var size = this.size();
7154
+ const size = this.size();
7152
7155
  return {
7153
7156
  x: this._centroid ? -size.width / 2 : 0,
7154
7157
  y: this._centroid ? -size.height / 2 : 0,
@@ -7204,17 +7207,17 @@
7204
7207
  // 1 - simple drawing when nothing is cached.
7205
7208
  // 2 - when we are caching current
7206
7209
  // 3 - when node is cached and we need to draw it into layer
7207
- var layer = this.getLayer();
7208
- var canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferContext;
7209
- var skipBuffer = canvas.isCache;
7210
- var cachingSelf = top === this;
7210
+ const layer = this.getLayer();
7211
+ let canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferContext;
7212
+ const skipBuffer = canvas.isCache;
7213
+ const cachingSelf = top === this;
7211
7214
  if (!this.isVisible() && !cachingSelf) {
7212
7215
  return this;
7213
7216
  }
7214
7217
  // if node is cached we just need to draw from cache
7215
7218
  if (cachedCanvas) {
7216
7219
  context.save();
7217
- var m = this.getAbsoluteTransform(top).getMatrix();
7220
+ const m = this.getAbsoluteTransform(top).getMatrix();
7218
7221
  context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
7219
7222
  this._drawCachedSceneCanvas(context);
7220
7223
  context.restore();
@@ -7237,7 +7240,7 @@
7237
7240
  bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
7238
7241
  drawFunc.call(this, bufferContext, this);
7239
7242
  bufferContext.restore();
7240
- var ratio = bc.pixelRatio;
7243
+ const ratio = bc.pixelRatio;
7241
7244
  if (hasShadow) {
7242
7245
  context._applyShadow(this);
7243
7246
  }
@@ -7265,13 +7268,13 @@
7265
7268
  if (!this.shouldDrawHit(top, skipDragCheck)) {
7266
7269
  return this;
7267
7270
  }
7268
- var layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
7271
+ const layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
7269
7272
  if (!this.colorKey) {
7270
7273
  Util.warn('Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()');
7271
7274
  }
7272
7275
  if (cachedHitCanvas) {
7273
7276
  context.save();
7274
- var m = this.getAbsoluteTransform(top).getMatrix();
7277
+ const m = this.getAbsoluteTransform(top).getMatrix();
7275
7278
  context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
7276
7279
  this._drawCachedHitCanvas(context);
7277
7280
  context.restore();
@@ -7284,7 +7287,7 @@
7284
7287
  context._applyLineJoin(this);
7285
7288
  const selfCache = this === top;
7286
7289
  if (!selfCache) {
7287
- var o = this.getAbsoluteTransform(top).getMatrix();
7290
+ const o = this.getAbsoluteTransform(top).getMatrix();
7288
7291
  context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
7289
7292
  }
7290
7293
  drawFunc.call(this, context, this);
@@ -7304,7 +7307,7 @@
7304
7307
  * shape.drawHitFromCache();
7305
7308
  */
7306
7309
  drawHitFromCache(alphaThreshold = 0) {
7307
- var cachedCanvas = this._getCanvasCache(), sceneCanvas = this._getCachedSceneCanvas(), hitCanvas = cachedCanvas.hit, hitContext = hitCanvas.getContext(), hitWidth = hitCanvas.getWidth(), hitHeight = hitCanvas.getHeight(), hitImageData, hitData, len, rgbColorKey, i, alpha;
7310
+ let cachedCanvas = this._getCanvasCache(), sceneCanvas = this._getCachedSceneCanvas(), hitCanvas = cachedCanvas.hit, hitContext = hitCanvas.getContext(), hitWidth = hitCanvas.getWidth(), hitHeight = hitCanvas.getHeight(), hitImageData, hitData, len, rgbColorKey, i, alpha;
7308
7311
  hitContext.clear();
7309
7312
  hitContext.drawImage(sceneCanvas._canvas, 0, 0, hitWidth, hitHeight);
7310
7313
  try {
@@ -8368,7 +8371,7 @@
8368
8371
  });
8369
8372
 
8370
8373
  // constants
8371
- var HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw',
8374
+ const HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw',
8372
8375
  /*
8373
8376
  * 2 - 3 - 4
8374
8377
  * | |
@@ -8483,7 +8486,7 @@
8483
8486
  // extend Node.prototype.setZIndex
8484
8487
  setZIndex(index) {
8485
8488
  super.setZIndex(index);
8486
- var stage = this.getStage();
8489
+ const stage = this.getStage();
8487
8490
  if (stage && stage.content) {
8488
8491
  stage.content.removeChild(this.getNativeCanvasElement());
8489
8492
  if (index < stage.children.length - 1) {
@@ -8497,7 +8500,7 @@
8497
8500
  }
8498
8501
  moveToTop() {
8499
8502
  Node.prototype.moveToTop.call(this);
8500
- var stage = this.getStage();
8503
+ const stage = this.getStage();
8501
8504
  if (stage && stage.content) {
8502
8505
  stage.content.removeChild(this.getNativeCanvasElement());
8503
8506
  stage.content.appendChild(this.getNativeCanvasElement());
@@ -8505,11 +8508,11 @@
8505
8508
  return true;
8506
8509
  }
8507
8510
  moveUp() {
8508
- var moved = Node.prototype.moveUp.call(this);
8511
+ const moved = Node.prototype.moveUp.call(this);
8509
8512
  if (!moved) {
8510
8513
  return false;
8511
8514
  }
8512
- var stage = this.getStage();
8515
+ const stage = this.getStage();
8513
8516
  if (!stage || !stage.content) {
8514
8517
  return false;
8515
8518
  }
@@ -8525,9 +8528,9 @@
8525
8528
  // extend Node.prototype.moveDown
8526
8529
  moveDown() {
8527
8530
  if (Node.prototype.moveDown.call(this)) {
8528
- var stage = this.getStage();
8531
+ const stage = this.getStage();
8529
8532
  if (stage) {
8530
- var children = stage.children;
8533
+ const children = stage.children;
8531
8534
  if (stage.content) {
8532
8535
  stage.content.removeChild(this.getNativeCanvasElement());
8533
8536
  stage.content.insertBefore(this.getNativeCanvasElement(), children[this.index + 1].getCanvas()._canvas);
@@ -8540,9 +8543,9 @@
8540
8543
  // extend Node.prototype.moveToBottom
8541
8544
  moveToBottom() {
8542
8545
  if (Node.prototype.moveToBottom.call(this)) {
8543
- var stage = this.getStage();
8546
+ const stage = this.getStage();
8544
8547
  if (stage) {
8545
- var children = stage.children;
8548
+ const children = stage.children;
8546
8549
  if (stage.content) {
8547
8550
  stage.content.removeChild(this.getNativeCanvasElement());
8548
8551
  stage.content.insertBefore(this.getNativeCanvasElement(), children[1].getCanvas()._canvas);
@@ -8556,7 +8559,7 @@
8556
8559
  return this;
8557
8560
  }
8558
8561
  remove() {
8559
- var _canvas = this.getNativeCanvasElement();
8562
+ const _canvas = this.getNativeCanvasElement();
8560
8563
  Node.prototype.remove.call(this);
8561
8564
  if (_canvas && _canvas.parentNode && Util._isInDocument(_canvas)) {
8562
8565
  _canvas.parentNode.removeChild(_canvas);
@@ -8573,7 +8576,7 @@
8573
8576
  return this;
8574
8577
  }
8575
8578
  _validateAdd(child) {
8576
- var type = child.getType();
8579
+ const type = child.getType();
8577
8580
  if (type !== 'Group' && type !== 'Shape') {
8578
8581
  Util.throw('You may only add groups and shapes to a layer.');
8579
8582
  }
@@ -8670,8 +8673,8 @@
8670
8673
  }
8671
8674
  // in some cases antialiased area may be bigger than 1px
8672
8675
  // it is possible if we will cache node, then scale it a lot
8673
- var spiralSearchDistance = 1;
8674
- var continueSearch = false;
8676
+ let spiralSearchDistance = 1;
8677
+ let continueSearch = false;
8675
8678
  while (true) {
8676
8679
  for (let i = 0; i < INTERSECTION_OFFSETS_LEN; i++) {
8677
8680
  const intersectionOffset = INTERSECTION_OFFSETS[i];
@@ -8727,7 +8730,7 @@
8727
8730
  return {};
8728
8731
  }
8729
8732
  drawScene(can, top) {
8730
- var layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());
8733
+ const layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());
8731
8734
  this._fire(BEFORE_DRAW, {
8732
8735
  node: this,
8733
8736
  });
@@ -8741,7 +8744,7 @@
8741
8744
  return this;
8742
8745
  }
8743
8746
  drawHit(can, top) {
8744
- var layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas);
8747
+ const layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas);
8745
8748
  if (layer && layer.clearBeforeDraw()) {
8746
8749
  layer.getHitCanvas().getContext().clear();
8747
8750
  }
@@ -8785,8 +8788,8 @@
8785
8788
  if (!this.parent || !this.parent['content']) {
8786
8789
  return;
8787
8790
  }
8788
- var parent = this.parent;
8789
- var added = !!this.hitCanvas._canvas.parentNode;
8791
+ const parent = this.parent;
8792
+ const added = !!this.hitCanvas._canvas.parentNode;
8790
8793
  if (added) {
8791
8794
  parent.content.removeChild(this.hitCanvas._canvas);
8792
8795
  }
@@ -8923,7 +8926,7 @@
8923
8926
  */
8924
8927
  class Group extends Container {
8925
8928
  _validateAdd(child) {
8926
- var type = child.getType();
8929
+ const type = child.getType();
8927
8930
  if (type !== 'Group' && type !== 'Shape') {
8928
8931
  Util.throw('You may only add groups and shapes to groups.');
8929
8932
  }
@@ -9120,7 +9123,7 @@
9120
9123
  }
9121
9124
  }
9122
9125
  }
9123
- for (let key in layerHash) {
9126
+ for (const key in layerHash) {
9124
9127
  if (!layerHash.hasOwnProperty(key)) {
9125
9128
  continue;
9126
9129
  }
@@ -9148,7 +9151,7 @@
9148
9151
  Animation.animIdCounter = 0;
9149
9152
  Animation.animRunning = false;
9150
9153
 
9151
- var blacklist = {
9154
+ let blacklist = {
9152
9155
  node: 1,
9153
9156
  duration: 1,
9154
9157
  easing: 1,
@@ -9174,7 +9177,7 @@
9174
9177
  this.pause();
9175
9178
  }
9176
9179
  fire(str) {
9177
- var handler = this[str];
9180
+ const handler = this[str];
9178
9181
  if (handler) {
9179
9182
  handler();
9180
9183
  }
@@ -9253,7 +9256,7 @@
9253
9256
  this.fire('onUpdate');
9254
9257
  }
9255
9258
  onEnterFrame() {
9256
- var t = this.getTimer() - this._startTime;
9259
+ const t = this.getTimer() - this._startTime;
9257
9260
  if (this.state === PLAYING) {
9258
9261
  this.setTime(t);
9259
9262
  }
@@ -9297,7 +9300,7 @@
9297
9300
  */
9298
9301
  class Tween {
9299
9302
  constructor(config) {
9300
- var that = this, node = config.node, nodeId = node._id, duration, easing = config.easing || Easings.Linear, yoyo = !!config.yoyo, key;
9303
+ let that = this, node = config.node, nodeId = node._id, duration, easing = config.easing || Easings.Linear, yoyo = !!config.yoyo, key;
9301
9304
  if (typeof config.duration === 'undefined') {
9302
9305
  duration = 0.3;
9303
9306
  }
@@ -9310,7 +9313,7 @@
9310
9313
  }
9311
9314
  this.node = node;
9312
9315
  this._id = idCounter++;
9313
- var layers = node.getLayer() ||
9316
+ const layers = node.getLayer() ||
9314
9317
  (node instanceof Konva$2['Stage'] ? node.getLayers() : null);
9315
9318
  if (!layers) {
9316
9319
  Util.error('Tween constructor have `node` that is not in a layer. Please add node into layer first.');
@@ -9345,7 +9348,7 @@
9345
9348
  this.onUpdate = config.onUpdate;
9346
9349
  }
9347
9350
  _addAttr(key, end) {
9348
- var node = this.node, nodeId = node._id, start, diff, tweenId, n, len, trueEnd, trueStart, endRGBA;
9351
+ let node = this.node, nodeId = node._id, start, diff, tweenId, n, len, trueEnd, trueStart, endRGBA;
9349
9352
  // remove conflict from tween map if it exists
9350
9353
  tweenId = Tween.tweens[nodeId][key];
9351
9354
  if (tweenId) {
@@ -9376,7 +9379,7 @@
9376
9379
  diff.push(end[n] - start[n]);
9377
9380
  }
9378
9381
  else {
9379
- var startRGBA = Util.colorToRGBA(start[n]);
9382
+ const startRGBA = Util.colorToRGBA(start[n]);
9380
9383
  endRGBA = Util.colorToRGBA(end[n]);
9381
9384
  start[n] = startRGBA;
9382
9385
  diff.push({
@@ -9417,7 +9420,7 @@
9417
9420
  Tween.tweens[nodeId][key] = this._id;
9418
9421
  }
9419
9422
  _tweenFunc(i) {
9420
- var node = this.node, attrs = Tween.attrs[node._id][this._id], key, attr, start, diff, newVal, n, len, end;
9423
+ let node = this.node, attrs = Tween.attrs[node._id][this._id], key, attr, start, diff, newVal, n, len, end;
9421
9424
  for (key in attrs) {
9422
9425
  attr = attrs[key];
9423
9426
  start = attr.start;
@@ -9481,9 +9484,9 @@
9481
9484
  this.anim.stop();
9482
9485
  };
9483
9486
  this.tween.onFinish = () => {
9484
- var node = this.node;
9487
+ const node = this.node;
9485
9488
  // after tweening points of line we need to set original end
9486
- var attrs = Tween.attrs[node._id][this._id];
9489
+ const attrs = Tween.attrs[node._id][this._id];
9487
9490
  if (attrs.points && attrs.points.trueEnd) {
9488
9491
  node.setAttr('points', attrs.points.trueEnd);
9489
9492
  }
@@ -9492,9 +9495,9 @@
9492
9495
  }
9493
9496
  };
9494
9497
  this.tween.onReset = () => {
9495
- var node = this.node;
9498
+ const node = this.node;
9496
9499
  // after tweening points of line we need to set original start
9497
- var attrs = Tween.attrs[node._id][this._id];
9500
+ const attrs = Tween.attrs[node._id][this._id];
9498
9501
  if (attrs.points && attrs.points.trueStart) {
9499
9502
  node.points(attrs.points.trueStart);
9500
9503
  }
@@ -9575,7 +9578,7 @@
9575
9578
  * @name Konva.Tween#destroy
9576
9579
  */
9577
9580
  destroy() {
9578
- var nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId], key;
9581
+ let nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId], key;
9579
9582
  this.pause();
9580
9583
  for (key in attrs) {
9581
9584
  delete Tween.tweens[nodeId][key];
@@ -9600,7 +9603,7 @@
9600
9603
  * });
9601
9604
  */
9602
9605
  Node.prototype.to = function (params) {
9603
- var onFinish = params.onFinish;
9606
+ const onFinish = params.onFinish;
9604
9607
  params.node = this;
9605
9608
  params.onFinish = function () {
9606
9609
  this.destroy();
@@ -9608,7 +9611,7 @@
9608
9611
  onFinish();
9609
9612
  }
9610
9613
  };
9611
- var tween = new Tween(params);
9614
+ const tween = new Tween(params);
9612
9615
  tween.play();
9613
9616
  };
9614
9617
  /*
@@ -9626,7 +9629,7 @@
9626
9629
  * @memberof Konva.Easings
9627
9630
  */
9628
9631
  BackEaseIn(t, b, c, d) {
9629
- var s = 1.70158;
9632
+ const s = 1.70158;
9630
9633
  return c * (t /= d) * t * ((s + 1) * t - s) + b;
9631
9634
  },
9632
9635
  /**
@@ -9635,7 +9638,7 @@
9635
9638
  * @memberof Konva.Easings
9636
9639
  */
9637
9640
  BackEaseOut(t, b, c, d) {
9638
- var s = 1.70158;
9641
+ const s = 1.70158;
9639
9642
  return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
9640
9643
  },
9641
9644
  /**
@@ -9644,7 +9647,7 @@
9644
9647
  * @memberof Konva.Easings
9645
9648
  */
9646
9649
  BackEaseInOut(t, b, c, d) {
9647
- var s = 1.70158;
9650
+ let s = 1.70158;
9648
9651
  if ((t /= d / 2) < 1) {
9649
9652
  return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;
9650
9653
  }
@@ -9657,7 +9660,7 @@
9657
9660
  */
9658
9661
  ElasticEaseIn(t, b, c, d, a, p) {
9659
9662
  // added s = 0
9660
- var s = 0;
9663
+ let s = 0;
9661
9664
  if (t === 0) {
9662
9665
  return b;
9663
9666
  }
@@ -9685,7 +9688,7 @@
9685
9688
  */
9686
9689
  ElasticEaseOut(t, b, c, d, a, p) {
9687
9690
  // added s = 0
9688
- var s = 0;
9691
+ let s = 0;
9689
9692
  if (t === 0) {
9690
9693
  return b;
9691
9694
  }
@@ -9713,7 +9716,7 @@
9713
9716
  */
9714
9717
  ElasticEaseInOut(t, b, c, d, a, p) {
9715
9718
  // added s = 0
9716
- var s = 0;
9719
+ let s = 0;
9717
9720
  if (t === 0) {
9718
9721
  return b;
9719
9722
  }
@@ -9967,7 +9970,7 @@
9967
9970
  */
9968
9971
  class Arc extends Shape {
9969
9972
  _sceneFunc(context) {
9970
- var angle = Konva$2.getAngle(this.angle()), clockwise = this.clockwise();
9973
+ const angle = Konva$2.getAngle(this.angle()), clockwise = this.clockwise();
9971
9974
  context.beginPath();
9972
9975
  context.arc(0, 0, this.outerRadius(), 0, angle, clockwise);
9973
9976
  context.arc(0, 0, this.innerRadius(), angle, 0, !clockwise);
@@ -10073,13 +10076,13 @@
10073
10076
  */
10074
10077
 
10075
10078
  function getControlPoints(x0, y0, x1, y1, x2, y2, t) {
10076
- var d01 = Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)), d12 = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)), fa = (t * d01) / (d01 + d12), fb = (t * d12) / (d01 + d12), p1x = x1 - fa * (x2 - x0), p1y = y1 - fa * (y2 - y0), p2x = x1 + fb * (x2 - x0), p2y = y1 + fb * (y2 - y0);
10079
+ const d01 = Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)), d12 = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)), fa = (t * d01) / (d01 + d12), fb = (t * d12) / (d01 + d12), p1x = x1 - fa * (x2 - x0), p1y = y1 - fa * (y2 - y0), p2x = x1 + fb * (x2 - x0), p2y = y1 + fb * (y2 - y0);
10077
10080
  return [p1x, p1y, p2x, p2y];
10078
10081
  }
10079
10082
  function expandPoints(p, tension) {
10080
- var len = p.length, allPoints = [], n, cp;
10081
- for (n = 2; n < len - 2; n += 2) {
10082
- cp = getControlPoints(p[n - 2], p[n - 1], p[n], p[n + 1], p[n + 2], p[n + 3], tension);
10083
+ const len = p.length, allPoints = [];
10084
+ for (let n = 2; n < len - 2; n += 2) {
10085
+ const cp = getControlPoints(p[n - 2], p[n - 1], p[n], p[n + 1], p[n + 2], p[n + 3], tension);
10083
10086
  if (isNaN(cp[0])) {
10084
10087
  continue;
10085
10088
  }
@@ -10195,7 +10198,7 @@
10195
10198
  });
10196
10199
  }
10197
10200
  _sceneFunc(context) {
10198
- var points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier(), tp, len, n;
10201
+ let points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier(), tp, len, n;
10199
10202
  if (!length) {
10200
10203
  return;
10201
10204
  }
@@ -10251,7 +10254,7 @@
10251
10254
  }
10252
10255
  }
10253
10256
  _getTensionPointsClosed() {
10254
- var p = this.points(), len = p.length, tension = this.tension(), firstControlPoints = getControlPoints(p[len - 2], p[len - 1], p[0], p[1], p[2], p[3], tension), lastControlPoints = getControlPoints(p[len - 4], p[len - 3], p[len - 2], p[len - 1], p[0], p[1], tension), middle = expandPoints(p, tension), tp = [firstControlPoints[2], firstControlPoints[3]]
10257
+ const p = this.points(), len = p.length, tension = this.tension(), firstControlPoints = getControlPoints(p[len - 2], p[len - 1], p[0], p[1], p[2], p[3], tension), lastControlPoints = getControlPoints(p[len - 4], p[len - 3], p[len - 2], p[len - 1], p[0], p[1], tension), middle = expandPoints(p, tension), tp = [firstControlPoints[2], firstControlPoints[3]]
10255
10258
  .concat(middle)
10256
10259
  .concat([
10257
10260
  lastControlPoints[0],
@@ -10275,7 +10278,7 @@
10275
10278
  }
10276
10279
  // overload size detection
10277
10280
  getSelfRect() {
10278
- var points = this.points();
10281
+ let points = this.points();
10279
10282
  if (points.length < 4) {
10280
10283
  return {
10281
10284
  x: points[0] || 0,
@@ -10296,12 +10299,12 @@
10296
10299
  else {
10297
10300
  points = this.points();
10298
10301
  }
10299
- var minX = points[0];
10300
- var maxX = points[0];
10301
- var minY = points[1];
10302
- var maxY = points[1];
10303
- var x, y;
10304
- for (var i = 0; i < points.length / 2; i++) {
10302
+ let minX = points[0];
10303
+ let maxX = points[0];
10304
+ let minY = points[1];
10305
+ let maxY = points[1];
10306
+ let x, y;
10307
+ for (let i = 0; i < points.length / 2; i++) {
10305
10308
  x = points[i * 2];
10306
10309
  y = points[i * 2 + 1];
10307
10310
  minX = Math.min(minX, x);
@@ -11074,14 +11077,13 @@
11074
11077
  // LUT for binomial coefficient arrays per curve order 'n'
11075
11078
  const binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
11076
11079
  const getCubicArcLength = (xs, ys, t) => {
11077
- let z;
11078
11080
  let sum;
11079
11081
  let correctedT;
11080
11082
  /*if (xs.length >= tValues.length) {
11081
11083
  throw new Error('too high n bezier');
11082
11084
  }*/
11083
11085
  const n = 20;
11084
- z = t / 2;
11086
+ const z = t / 2;
11085
11087
  sum = 0;
11086
11088
  for (let i = 0; i < n; i++) {
11087
11089
  correctedT = z * tValues[n][i] + z;
@@ -11291,13 +11293,13 @@
11291
11293
  this.pathLength = Path.getPathLength(this.dataArray);
11292
11294
  }
11293
11295
  _sceneFunc(context) {
11294
- var ca = this.dataArray;
11296
+ const ca = this.dataArray;
11295
11297
  // context position
11296
11298
  context.beginPath();
11297
- var isClosed = false;
11298
- for (var n = 0; n < ca.length; n++) {
11299
- var c = ca[n].command;
11300
- var p = ca[n].points;
11299
+ let isClosed = false;
11300
+ for (let n = 0; n < ca.length; n++) {
11301
+ const c = ca[n].command;
11302
+ const p = ca[n].points;
11301
11303
  switch (c) {
11302
11304
  case 'L':
11303
11305
  context.lineTo(p[0], p[1]);
@@ -11338,16 +11340,16 @@
11338
11340
  }
11339
11341
  }
11340
11342
  getSelfRect() {
11341
- var points = [];
11343
+ let points = [];
11342
11344
  this.dataArray.forEach(function (data) {
11343
11345
  if (data.command === 'A') {
11344
11346
  // Approximates by breaking curve into line segments
11345
- var start = data.points[4];
11347
+ const start = data.points[4];
11346
11348
  // 4 = theta
11347
- var dTheta = data.points[5];
11349
+ const dTheta = data.points[5];
11348
11350
  // 5 = dTheta
11349
- var end = data.points[4] + dTheta;
11350
- var inc = Math.PI / 180.0;
11351
+ const end = data.points[4] + dTheta;
11352
+ let inc = Math.PI / 180.0;
11351
11353
  // 1 degree resolution
11352
11354
  if (Math.abs(start - end) < inc) {
11353
11355
  inc = Math.abs(start - end);
@@ -11379,12 +11381,12 @@
11379
11381
  points = points.concat(data.points);
11380
11382
  }
11381
11383
  });
11382
- var minX = points[0];
11383
- var maxX = points[0];
11384
- var minY = points[1];
11385
- var maxY = points[1];
11386
- var x, y;
11387
- for (var i = 0; i < points.length / 2; i++) {
11384
+ let minX = points[0];
11385
+ let maxX = points[0];
11386
+ let minY = points[1];
11387
+ let maxY = points[1];
11388
+ let x, y;
11389
+ for (let i = 0; i < points.length / 2; i++) {
11388
11390
  x = points[i * 2];
11389
11391
  y = points[i * 2 + 1];
11390
11392
  // skip bad values
@@ -11432,13 +11434,13 @@
11432
11434
  }
11433
11435
  static getPathLength(dataArray) {
11434
11436
  let pathLength = 0;
11435
- for (var i = 0; i < dataArray.length; ++i) {
11437
+ for (let i = 0; i < dataArray.length; ++i) {
11436
11438
  pathLength += dataArray[i].pathLength;
11437
11439
  }
11438
11440
  return pathLength;
11439
11441
  }
11440
11442
  static getPointAtLengthOfDataArray(length, dataArray) {
11441
- var points, i = 0, ii = dataArray.length;
11443
+ let points, i = 0, ii = dataArray.length;
11442
11444
  if (!ii) {
11443
11445
  return null;
11444
11446
  }
@@ -11460,8 +11462,8 @@
11460
11462
  y: points[1],
11461
11463
  };
11462
11464
  }
11463
- var cp = dataArray[i];
11464
- var p = cp.points;
11465
+ const cp = dataArray[i];
11466
+ const p = cp.points;
11465
11467
  switch (cp.command) {
11466
11468
  case 'L':
11467
11469
  return Path.getPointOnLine(length, cp.start.x, cp.start.y, p[0], p[1]);
@@ -11519,8 +11521,8 @@
11519
11521
  function CB4(t) {
11520
11522
  return (1 - t) * (1 - t) * (1 - t);
11521
11523
  }
11522
- var x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);
11523
- var y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);
11524
+ const x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);
11525
+ const y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);
11524
11526
  return {
11525
11527
  x: x,
11526
11528
  y: y,
@@ -11536,16 +11538,16 @@
11536
11538
  function QB3(t) {
11537
11539
  return (1 - t) * (1 - t);
11538
11540
  }
11539
- var x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);
11540
- var y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);
11541
+ const x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);
11542
+ const y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);
11541
11543
  return {
11542
11544
  x: x,
11543
11545
  y: y,
11544
11546
  };
11545
11547
  }
11546
11548
  static getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi) {
11547
- var cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);
11548
- var pt = {
11549
+ const cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);
11550
+ const pt = {
11549
11551
  x: rx * Math.cos(theta),
11550
11552
  y: ry * Math.sin(theta),
11551
11553
  };
@@ -11587,9 +11589,9 @@
11587
11589
  return [];
11588
11590
  }
11589
11591
  // command string
11590
- var cs = data;
11592
+ let cs = data;
11591
11593
  // command chars
11592
- var cc = [
11594
+ const cc = [
11593
11595
  'm',
11594
11596
  'M',
11595
11597
  'l',
@@ -11618,17 +11620,17 @@
11618
11620
  cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
11619
11621
  }
11620
11622
  // create array
11621
- var arr = cs.split('|');
11622
- var ca = [];
11623
- var coords = [];
11623
+ const arr = cs.split('|');
11624
+ const ca = [];
11625
+ const coords = [];
11624
11626
  // init context point
11625
- var cpx = 0;
11626
- var cpy = 0;
11627
- var re = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;
11628
- var match;
11627
+ let cpx = 0;
11628
+ let cpy = 0;
11629
+ const re = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;
11630
+ let match;
11629
11631
  for (n = 1; n < arr.length; n++) {
11630
- var str = arr[n];
11631
- var c = str.charAt(0);
11632
+ let str = arr[n];
11633
+ let c = str.charAt(0);
11632
11634
  str = str.slice(1);
11633
11635
  coords.length = 0;
11634
11636
  while ((match = re.exec(str))) {
@@ -11637,14 +11639,14 @@
11637
11639
  // while ((match = re.exec(str))) {
11638
11640
  // coords.push(match[0]);
11639
11641
  // }
11640
- var p = [];
11641
- for (var j = 0, jlen = coords.length; j < jlen; j++) {
11642
+ const p = [];
11643
+ for (let j = 0, jlen = coords.length; j < jlen; j++) {
11642
11644
  // extra case for merged flags
11643
11645
  if (coords[j] === '00') {
11644
11646
  p.push(0, 0);
11645
11647
  continue;
11646
11648
  }
11647
- var parsed = parseFloat(coords[j]);
11649
+ const parsed = parseFloat(coords[j]);
11648
11650
  if (!isNaN(parsed)) {
11649
11651
  p.push(parsed);
11650
11652
  }
@@ -11657,9 +11659,9 @@
11657
11659
  // case for a trailing comma before next command
11658
11660
  break;
11659
11661
  }
11660
- var cmd = '';
11661
- var points = [];
11662
- var startX = cpx, startY = cpy;
11662
+ let cmd = '';
11663
+ let points = [];
11664
+ const startX = cpx, startY = cpy;
11663
11665
  // Move var from within the switch to up here (jshint)
11664
11666
  var prevCmd, ctlPtx, ctlPty; // Ss, Tt
11665
11667
  var rx, ry, psi, fa, fs, x1, y1; // Aa
@@ -11687,7 +11689,7 @@
11687
11689
  // After closing the path move the current position
11688
11690
  // to the the first point of the path (if any).
11689
11691
  if (ca.length > 2 && ca[ca.length - 1].command === 'z') {
11690
- for (var idx = ca.length - 2; idx >= 0; idx--) {
11692
+ for (let idx = ca.length - 2; idx >= 0; idx--) {
11691
11693
  if (ca[idx].command === 'M') {
11692
11694
  cpx = ca[idx].points[0] + dx;
11693
11695
  cpy = ca[idx].points[1] + dy;
@@ -11856,8 +11858,8 @@
11856
11858
  return ca;
11857
11859
  }
11858
11860
  static calcLength(x, y, cmd, points) {
11859
- var len, p1, p2, t;
11860
- var path = Path;
11861
+ let len, p1, p2, t;
11862
+ const path = Path;
11861
11863
  switch (cmd) {
11862
11864
  case 'L':
11863
11865
  return path.getLineLength(x, y, points[0], points[1]);
@@ -11904,16 +11906,16 @@
11904
11906
  }
11905
11907
  static convertEndpointToCenterParameterization(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg) {
11906
11908
  // Derived from: http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
11907
- var psi = psiDeg * (Math.PI / 180.0);
11908
- var xp = (Math.cos(psi) * (x1 - x2)) / 2.0 + (Math.sin(psi) * (y1 - y2)) / 2.0;
11909
- var yp = (-1 * Math.sin(psi) * (x1 - x2)) / 2.0 +
11909
+ const psi = psiDeg * (Math.PI / 180.0);
11910
+ const xp = (Math.cos(psi) * (x1 - x2)) / 2.0 + (Math.sin(psi) * (y1 - y2)) / 2.0;
11911
+ const yp = (-1 * Math.sin(psi) * (x1 - x2)) / 2.0 +
11910
11912
  (Math.cos(psi) * (y1 - y2)) / 2.0;
11911
- var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
11913
+ const lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
11912
11914
  if (lambda > 1) {
11913
11915
  rx *= Math.sqrt(lambda);
11914
11916
  ry *= Math.sqrt(lambda);
11915
11917
  }
11916
- var f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) /
11918
+ let f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) /
11917
11919
  (rx * rx * (yp * yp) + ry * ry * (xp * xp)));
11918
11920
  if (fa === fs) {
11919
11921
  f *= -1;
@@ -11921,23 +11923,23 @@
11921
11923
  if (isNaN(f)) {
11922
11924
  f = 0;
11923
11925
  }
11924
- var cxp = (f * rx * yp) / ry;
11925
- var cyp = (f * -ry * xp) / rx;
11926
- var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;
11927
- var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;
11928
- var vMag = function (v) {
11926
+ const cxp = (f * rx * yp) / ry;
11927
+ const cyp = (f * -ry * xp) / rx;
11928
+ const cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;
11929
+ const cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;
11930
+ const vMag = function (v) {
11929
11931
  return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
11930
11932
  };
11931
- var vRatio = function (u, v) {
11933
+ const vRatio = function (u, v) {
11932
11934
  return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
11933
11935
  };
11934
- var vAngle = function (u, v) {
11936
+ const vAngle = function (u, v) {
11935
11937
  return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));
11936
11938
  };
11937
- var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
11938
- var u = [(xp - cxp) / rx, (yp - cyp) / ry];
11939
- var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
11940
- var dTheta = vAngle(u, v);
11939
+ const theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
11940
+ const u = [(xp - cxp) / rx, (yp - cyp) / ry];
11941
+ const v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
11942
+ let dTheta = vAngle(u, v);
11941
11943
  if (vRatio(u, v) <= -1) {
11942
11944
  dTheta = Math.PI;
11943
11945
  }
@@ -12073,16 +12075,16 @@
12073
12075
  class Arrow extends Line {
12074
12076
  _sceneFunc(ctx) {
12075
12077
  super._sceneFunc(ctx);
12076
- var PI2 = Math.PI * 2;
12077
- var points = this.points();
12078
- var tp = points;
12079
- var fromTension = this.tension() !== 0 && points.length > 4;
12078
+ const PI2 = Math.PI * 2;
12079
+ const points = this.points();
12080
+ let tp = points;
12081
+ const fromTension = this.tension() !== 0 && points.length > 4;
12080
12082
  if (fromTension) {
12081
12083
  tp = this.getTensionPoints();
12082
12084
  }
12083
- var length = this.pointerLength();
12084
- var n = points.length;
12085
- var dx, dy;
12085
+ const length = this.pointerLength();
12086
+ const n = points.length;
12087
+ let dx, dy;
12086
12088
  if (fromTension) {
12087
12089
  const lp = [
12088
12090
  tp[tp.length - 4],
@@ -12101,8 +12103,8 @@
12101
12103
  dx = points[n - 2] - points[n - 4];
12102
12104
  dy = points[n - 1] - points[n - 3];
12103
12105
  }
12104
- var radians = (Math.atan2(dy, dx) + PI2) % PI2;
12105
- var width = this.pointerWidth();
12106
+ const radians = (Math.atan2(dy, dx) + PI2) % PI2;
12107
+ const width = this.pointerWidth();
12106
12108
  if (this.pointerAtEnding()) {
12107
12109
  ctx.save();
12108
12110
  ctx.beginPath();
@@ -12139,7 +12141,7 @@
12139
12141
  __fillStroke(ctx) {
12140
12142
  // here is a tricky part
12141
12143
  // we need to disable dash for arrow pointers
12142
- var isDashEnabled = this.dashEnabled();
12144
+ const isDashEnabled = this.dashEnabled();
12143
12145
  if (isDashEnabled) {
12144
12146
  // manually disable dash for head
12145
12147
  // it is better not to use setter here,
@@ -12449,7 +12451,7 @@
12449
12451
  */
12450
12452
  class Ellipse extends Shape {
12451
12453
  _sceneFunc(context) {
12452
- var rx = this.radiusX(), ry = this.radiusY();
12454
+ const rx = this.radiusX(), ry = this.radiusY();
12453
12455
  context.beginPath();
12454
12456
  context.save();
12455
12457
  if (rx !== ry) {
@@ -12696,7 +12698,7 @@
12696
12698
  // If you need to draw later, you need to execute save/restore
12697
12699
  }
12698
12700
  _hitFunc(context) {
12699
- var width = this.width(), height = this.height(), cornerRadius = this.cornerRadius();
12701
+ const width = this.width(), height = this.height(), cornerRadius = this.cornerRadius();
12700
12702
  context.beginPath();
12701
12703
  if (!cornerRadius) {
12702
12704
  context.rect(0, 0, width, height);
@@ -12730,9 +12732,9 @@
12730
12732
  * });
12731
12733
  */
12732
12734
  static fromURL(url, callback, onError = null) {
12733
- var img = Util.createImageElement();
12735
+ const img = Util.createImageElement();
12734
12736
  img.onload = function () {
12735
- var image = new Image({
12737
+ const image = new Image({
12736
12738
  image: img,
12737
12739
  });
12738
12740
  callback(image);
@@ -12857,7 +12859,7 @@
12857
12859
  */
12858
12860
 
12859
12861
  // constants
12860
- var ATTR_CHANGE_LIST$2 = [
12862
+ const ATTR_CHANGE_LIST$2 = [
12861
12863
  'fontFamily',
12862
12864
  'fontSize',
12863
12865
  'fontStyle',
@@ -12958,8 +12960,8 @@
12958
12960
  return this.find('Tag')[0];
12959
12961
  }
12960
12962
  _addListeners(text) {
12961
- var that = this, n;
12962
- var func = function () {
12963
+ let that = this, n;
12964
+ const func = function () {
12963
12965
  that._sync();
12964
12966
  };
12965
12967
  // update text data for certain attr changes
@@ -12974,7 +12976,7 @@
12974
12976
  return this.getText().height();
12975
12977
  }
12976
12978
  _sync() {
12977
- var text = this.getText(), tag = this.getTag(), width, height, pointerDirection, pointerWidth, x, y, pointerHeight;
12979
+ let text = this.getText(), tag = this.getTag(), width, height, pointerDirection, pointerWidth, x, y, pointerHeight;
12978
12980
  if (text && tag) {
12979
12981
  width = text.width();
12980
12982
  height = text.height();
@@ -13030,7 +13032,7 @@
13030
13032
  */
13031
13033
  class Tag extends Shape {
13032
13034
  _sceneFunc(context) {
13033
- var width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = this.cornerRadius();
13035
+ const width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = this.cornerRadius();
13034
13036
  let topLeft = 0;
13035
13037
  let topRight = 0;
13036
13038
  let bottomLeft = 0;
@@ -13082,7 +13084,7 @@
13082
13084
  context.fillStrokeShape(this);
13083
13085
  }
13084
13086
  getSelfRect() {
13085
- var x = 0, y = 0, pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), direction = this.pointerDirection(), width = this.width(), height = this.height();
13087
+ let x = 0, y = 0, pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), direction = this.pointerDirection(), width = this.width(), height = this.height();
13086
13088
  if (direction === UP) {
13087
13089
  y -= pointerHeight;
13088
13090
  height += pointerHeight;
@@ -13245,7 +13247,7 @@
13245
13247
  */
13246
13248
  class Rect extends Shape {
13247
13249
  _sceneFunc(context) {
13248
- var cornerRadius = this.cornerRadius(), width = this.width(), height = this.height();
13250
+ const cornerRadius = this.cornerRadius(), width = this.width(), height = this.height();
13249
13251
  context.beginPath();
13250
13252
  if (!cornerRadius) {
13251
13253
  // simple rect - don't bother doing all that complicated maths stuff.
@@ -13377,7 +13379,7 @@
13377
13379
  const points = this._getPoints();
13378
13380
  context.beginPath();
13379
13381
  context.moveTo(points[0].x, points[0].y);
13380
- for (var n = 1; n < points.length; n++) {
13382
+ for (let n = 1; n < points.length; n++) {
13381
13383
  context.lineTo(points[n].x, points[n].y);
13382
13384
  }
13383
13385
  context.closePath();
@@ -13387,7 +13389,7 @@
13387
13389
  const sides = this.attrs.sides;
13388
13390
  const radius = this.attrs.radius || 0;
13389
13391
  const points = [];
13390
- for (var n = 0; n < sides; n++) {
13392
+ for (let n = 0; n < sides; n++) {
13391
13393
  points.push({
13392
13394
  x: radius * Math.sin((n * 2 * Math.PI) / sides),
13393
13395
  y: -1 * radius * Math.cos((n * 2 * Math.PI) / sides),
@@ -13397,10 +13399,10 @@
13397
13399
  }
13398
13400
  getSelfRect() {
13399
13401
  const points = this._getPoints();
13400
- var minX = points[0].x;
13401
- var maxX = points[0].y;
13402
- var minY = points[0].x;
13403
- var maxY = points[0].y;
13402
+ let minX = points[0].x;
13403
+ let maxX = points[0].y;
13404
+ let minY = points[0].x;
13405
+ let maxY = points[0].y;
13404
13406
  points.forEach((point) => {
13405
13407
  minX = Math.min(minX, point.x);
13406
13408
  maxX = Math.max(maxX, point.x);
@@ -13460,7 +13462,7 @@
13460
13462
  */
13461
13463
  Factory.addGetterSetter(RegularPolygon, 'sides', 0, getNumberValidator());
13462
13464
 
13463
- var PIx2 = Math.PI * 2;
13465
+ const PIx2 = Math.PI * 2;
13464
13466
  /**
13465
13467
  * Ring constructor
13466
13468
  * @constructor
@@ -13732,7 +13734,7 @@
13732
13734
  this._updated = true;
13733
13735
  this.anim = new Animation(() => {
13734
13736
  // if we don't need to redraw layer we should return false
13735
- var updated = this._updated;
13737
+ const updated = this._updated;
13736
13738
  this._updated = false;
13737
13739
  return updated;
13738
13740
  });
@@ -13753,7 +13755,7 @@
13753
13755
  });
13754
13756
  }
13755
13757
  _sceneFunc(context) {
13756
- var anim = this.animation(), index = this.frameIndex(), ix4 = index * 4, set = this.animations()[anim], offsets = this.frameOffsets(), x = set[ix4 + 0], y = set[ix4 + 1], width = set[ix4 + 2], height = set[ix4 + 3], image = this.image();
13758
+ const anim = this.animation(), index = this.frameIndex(), ix4 = index * 4, set = this.animations()[anim], offsets = this.frameOffsets(), x = set[ix4 + 0], y = set[ix4 + 1], width = set[ix4 + 2], height = set[ix4 + 3], image = this.image();
13757
13759
  if (this.hasFill() || this.hasStroke()) {
13758
13760
  context.beginPath();
13759
13761
  context.rect(0, 0, width, height);
@@ -13762,7 +13764,7 @@
13762
13764
  }
13763
13765
  if (image) {
13764
13766
  if (offsets) {
13765
- var offset = offsets[anim], ix2 = index * 2;
13767
+ const offset = offsets[anim], ix2 = index * 2;
13766
13768
  context.drawImage(image, x, y, width, height, offset[ix2 + 0], offset[ix2 + 1], width, height);
13767
13769
  }
13768
13770
  else {
@@ -13771,11 +13773,11 @@
13771
13773
  }
13772
13774
  }
13773
13775
  _hitFunc(context) {
13774
- var anim = this.animation(), index = this.frameIndex(), ix4 = index * 4, set = this.animations()[anim], offsets = this.frameOffsets(), width = set[ix4 + 2], height = set[ix4 + 3];
13776
+ const anim = this.animation(), index = this.frameIndex(), ix4 = index * 4, set = this.animations()[anim], offsets = this.frameOffsets(), width = set[ix4 + 2], height = set[ix4 + 3];
13775
13777
  context.beginPath();
13776
13778
  if (offsets) {
13777
- var offset = offsets[anim];
13778
- var ix2 = index * 2;
13779
+ const offset = offsets[anim];
13780
+ const ix2 = index * 2;
13779
13781
  context.rect(offset[ix2 + 0], offset[ix2 + 1], width, height);
13780
13782
  }
13781
13783
  else {
@@ -13788,7 +13790,7 @@
13788
13790
  return super._useBufferCanvas(true);
13789
13791
  }
13790
13792
  _setInterval() {
13791
- var that = this;
13793
+ const that = this;
13792
13794
  this.interval = setInterval(function () {
13793
13795
  that._updateIndex();
13794
13796
  }, 1000 / this.frameRate());
@@ -13802,7 +13804,7 @@
13802
13804
  if (this.isRunning()) {
13803
13805
  return;
13804
13806
  }
13805
- var layer = this.getLayer();
13807
+ const layer = this.getLayer();
13806
13808
  /*
13807
13809
  * animation object has no executable function because
13808
13810
  * the updates are done with a fixed FPS with the setInterval
@@ -13832,7 +13834,7 @@
13832
13834
  return this.anim.isRunning();
13833
13835
  }
13834
13836
  _updateIndex() {
13835
- var index = this.frameIndex(), animation = this.animation(), animations = this.animations(), anim = animations[animation], len = anim.length / 4;
13837
+ const index = this.frameIndex(), animation = this.animation(), animations = this.animations(), anim = animations[animation], len = anim.length / 4;
13836
13838
  if (index < len - 1) {
13837
13839
  this.frameIndex(index + 1);
13838
13840
  }
@@ -14071,13 +14073,13 @@
14071
14073
  */
14072
14074
  class Star extends Shape {
14073
14075
  _sceneFunc(context) {
14074
- var innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();
14076
+ const innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();
14075
14077
  context.beginPath();
14076
14078
  context.moveTo(0, 0 - outerRadius);
14077
- for (var n = 1; n < numPoints * 2; n++) {
14078
- var radius = n % 2 === 0 ? outerRadius : innerRadius;
14079
- var x = radius * Math.sin((n * Math.PI) / numPoints);
14080
- var y = -1 * radius * Math.cos((n * Math.PI) / numPoints);
14079
+ for (let n = 1; n < numPoints * 2; n++) {
14080
+ const radius = n % 2 === 0 ? outerRadius : innerRadius;
14081
+ const x = radius * Math.sin((n * Math.PI) / numPoints);
14082
+ const y = -1 * radius * Math.cos((n * Math.PI) / numPoints);
14081
14083
  context.lineTo(x, y);
14082
14084
  }
14083
14085
  context.closePath();
@@ -14166,7 +14168,7 @@
14166
14168
  }, []);
14167
14169
  }
14168
14170
  // constants
14169
- var AUTO = 'auto',
14171
+ const AUTO = 'auto',
14170
14172
  //CANVAS = 'canvas',
14171
14173
  CENTER = 'center', INHERIT = 'inherit', JUSTIFY = 'justify', CHANGE_KONVA = 'Change.konva', CONTEXT_2D = '2d', DASH = '-', LEFT = 'left', TEXT = 'text', TEXT_UPPER = 'Text', TOP = 'top', BOTTOM = 'bottom', MIDDLE = 'middle', NORMAL$1 = 'normal', PX_SPACE = 'px ', SPACE = ' ', RIGHT = 'right', RTL = 'rtl', WORD = 'word', CHAR = 'char', NONE = 'none', ELLIPSIS = '…', ATTR_CHANGE_LIST$1 = [
14172
14174
  'direction',
@@ -14201,7 +14203,7 @@
14201
14203
  })
14202
14204
  .join(', ');
14203
14205
  }
14204
- var dummyContext;
14206
+ let dummyContext;
14205
14207
  function getDummyContext() {
14206
14208
  if (dummyContext) {
14207
14209
  return dummyContext;
@@ -14335,22 +14337,22 @@
14335
14337
  this._partialTextX = 0;
14336
14338
  this._partialTextY = 0;
14337
14339
  // update text data for certain attr changes
14338
- for (var n = 0; n < attrChangeListLen; n++) {
14340
+ for (let n = 0; n < attrChangeListLen; n++) {
14339
14341
  this.on(ATTR_CHANGE_LIST$1[n] + CHANGE_KONVA, this._setTextData);
14340
14342
  }
14341
14343
  this._setTextData();
14342
14344
  }
14343
14345
  _sceneFunc(context) {
14344
- var textArr = this.textArr, textArrLen = textArr.length;
14346
+ const textArr = this.textArr, textArrLen = textArr.length;
14345
14347
  if (!this.text()) {
14346
14348
  return;
14347
14349
  }
14348
- var padding = this.padding(), fontSize = this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, verticalAlign = this.verticalAlign(), direction = this.direction(), alignY = 0, align = this.align(), totalWidth = this.getWidth(), letterSpacing = this.letterSpacing(), fill = this.fill(), textDecoration = this.textDecoration(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n;
14350
+ let padding = this.padding(), fontSize = this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, verticalAlign = this.verticalAlign(), direction = this.direction(), alignY = 0, align = this.align(), totalWidth = this.getWidth(), letterSpacing = this.letterSpacing(), fill = this.fill(), textDecoration = this.textDecoration(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n;
14349
14351
  direction = direction === INHERIT ? context.direction : direction;
14350
- var translateY = lineHeightPx / 2;
14351
- var baseline = MIDDLE;
14352
+ let translateY = lineHeightPx / 2;
14353
+ let baseline = MIDDLE;
14352
14354
  if (Konva$2._fixTextRendering) {
14353
- var metrics = this.measureSize('M'); // Use a sample character to get the ascent
14355
+ const metrics = this.measureSize('M'); // Use a sample character to get the ascent
14354
14356
  baseline = 'alphabetic';
14355
14357
  translateY =
14356
14358
  (metrics.fontBoundingBoxAscent - metrics.fontBoundingBoxDescent) / 2 +
@@ -14388,7 +14390,7 @@
14388
14390
  if (shouldUnderline) {
14389
14391
  context.save();
14390
14392
  context.beginPath();
14391
- let yOffset = Konva$2._fixTextRendering
14393
+ const yOffset = Konva$2._fixTextRendering
14392
14394
  ? Math.round(fontSize / 4)
14393
14395
  : Math.round(fontSize / 2);
14394
14396
  const x = lineTranslateX;
@@ -14410,7 +14412,7 @@
14410
14412
  if (shouldLineThrough) {
14411
14413
  context.save();
14412
14414
  context.beginPath();
14413
- let yOffset = Konva$2._fixTextRendering ? -Math.round(fontSize / 4) : 0;
14415
+ const yOffset = Konva$2._fixTextRendering ? -Math.round(fontSize / 4) : 0;
14414
14416
  context.moveTo(lineTranslateX, translateY + lineTranslateY + yOffset);
14415
14417
  spacesNumber = text.split(' ').length - 1;
14416
14418
  oneWord = spacesNumber === 0;
@@ -14431,9 +14433,9 @@
14431
14433
  if (direction !== RTL && (letterSpacing !== 0 || align === JUSTIFY)) {
14432
14434
  // var words = text.split(' ');
14433
14435
  spacesNumber = text.split(' ').length - 1;
14434
- var array = stringToArray(text);
14435
- for (var li = 0; li < array.length; li++) {
14436
- var letter = array[li];
14436
+ const array = stringToArray(text);
14437
+ for (let li = 0; li < array.length; li++) {
14438
+ const letter = array[li];
14437
14439
  // skip justify for the last line
14438
14440
  if (letter === ' ' && !lastLine && align === JUSTIFY) {
14439
14441
  lineTranslateX += (totalWidth - padding * 2 - width) / spacesNumber;
@@ -14465,14 +14467,14 @@
14465
14467
  }
14466
14468
  }
14467
14469
  _hitFunc(context) {
14468
- var width = this.getWidth(), height = this.getHeight();
14470
+ const width = this.getWidth(), height = this.getHeight();
14469
14471
  context.beginPath();
14470
14472
  context.rect(0, 0, width, height);
14471
14473
  context.closePath();
14472
14474
  context.fillStrokeShape(this);
14473
14475
  }
14474
14476
  setText(text) {
14475
- var str = Util._isString(text)
14477
+ const str = Util._isString(text)
14476
14478
  ? text
14477
14479
  : text === null || text === undefined
14478
14480
  ? ''
@@ -14481,11 +14483,11 @@
14481
14483
  return this;
14482
14484
  }
14483
14485
  getWidth() {
14484
- var isAuto = this.attrs.width === AUTO || this.attrs.width === undefined;
14486
+ const isAuto = this.attrs.width === AUTO || this.attrs.width === undefined;
14485
14487
  return isAuto ? this.getTextWidth() + this.padding() * 2 : this.attrs.width;
14486
14488
  }
14487
14489
  getHeight() {
14488
- var isAuto = this.attrs.height === AUTO || this.attrs.height === undefined;
14490
+ const isAuto = this.attrs.height === AUTO || this.attrs.height === undefined;
14489
14491
  return isAuto
14490
14492
  ? this.fontSize() * this.textArr.length * this.lineHeight() +
14491
14493
  this.padding() * 2
@@ -14514,7 +14516,7 @@
14514
14516
  */
14515
14517
  measureSize(text) {
14516
14518
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
14517
- var _context = getDummyContext(), fontSize = this.fontSize(), metrics;
14519
+ let _context = getDummyContext(), fontSize = this.fontSize(), metrics;
14518
14520
  _context.save();
14519
14521
  _context.font = this._getContextFont();
14520
14522
  metrics = _context.measureText(text);
@@ -14552,7 +14554,7 @@
14552
14554
  if (align === JUSTIFY) {
14553
14555
  line = line.trim();
14554
14556
  }
14555
- var width = this._getTextWidth(line);
14557
+ const width = this._getTextWidth(line);
14556
14558
  return this.textArr.push({
14557
14559
  text: line,
14558
14560
  width: width,
@@ -14560,21 +14562,21 @@
14560
14562
  });
14561
14563
  }
14562
14564
  _getTextWidth(text) {
14563
- var letterSpacing = this.letterSpacing();
14564
- var length = text.length;
14565
+ const letterSpacing = this.letterSpacing();
14566
+ const length = text.length;
14565
14567
  return (getDummyContext().measureText(text).width +
14566
14568
  (length ? letterSpacing * (length - 1) : 0));
14567
14569
  }
14568
14570
  _setTextData() {
14569
- var lines = this.text().split('\n'), fontSize = +this.fontSize(), textWidth = 0, lineHeightPx = this.lineHeight() * fontSize, width = this.attrs.width, height = this.attrs.height, fixedWidth = width !== AUTO && width !== undefined, fixedHeight = height !== AUTO && height !== undefined, padding = this.padding(), maxWidth = width - padding * 2, maxHeightPx = height - padding * 2, currentHeightPx = 0, wrap = this.wrap(),
14571
+ let lines = this.text().split('\n'), fontSize = +this.fontSize(), textWidth = 0, lineHeightPx = this.lineHeight() * fontSize, width = this.attrs.width, height = this.attrs.height, fixedWidth = width !== AUTO && width !== undefined, fixedHeight = height !== AUTO && height !== undefined, padding = this.padding(), maxWidth = width - padding * 2, maxHeightPx = height - padding * 2, currentHeightPx = 0, wrap = this.wrap(),
14570
14572
  // align = this.align(),
14571
14573
  shouldWrap = wrap !== NONE, wrapAtWord = wrap !== CHAR && shouldWrap, shouldAddEllipsis = this.ellipsis();
14572
14574
  this.textArr = [];
14573
14575
  getDummyContext().font = this._getContextFont();
14574
- var additionalWidth = shouldAddEllipsis ? this._getTextWidth(ELLIPSIS) : 0;
14575
- for (var i = 0, max = lines.length; i < max; ++i) {
14576
- var line = lines[i];
14577
- var lineWidth = this._getTextWidth(line);
14576
+ const additionalWidth = shouldAddEllipsis ? this._getTextWidth(ELLIPSIS) : 0;
14577
+ for (let i = 0, max = lines.length; i < max; ++i) {
14578
+ let line = lines[i];
14579
+ let lineWidth = this._getTextWidth(line);
14578
14580
  if (fixedWidth && lineWidth > maxWidth) {
14579
14581
  /*
14580
14582
  * if width is fixed and line does not fit entirely
@@ -14585,9 +14587,9 @@
14585
14587
  * use binary search to find the longest substring that
14586
14588
  * that would fit in the specified width
14587
14589
  */
14588
- var low = 0, high = line.length, match = '', matchWidth = 0;
14590
+ let low = 0, high = line.length, match = '', matchWidth = 0;
14589
14591
  while (low < high) {
14590
- var mid = (low + high) >>> 1, substr = line.slice(0, mid + 1), substrWidth = this._getTextWidth(substr) + additionalWidth;
14592
+ const mid = (low + high) >>> 1, substr = line.slice(0, mid + 1), substrWidth = this._getTextWidth(substr) + additionalWidth;
14591
14593
  if (substrWidth <= maxWidth) {
14592
14594
  low = mid + 1;
14593
14595
  match = substr;
@@ -14607,8 +14609,8 @@
14607
14609
  if (wrapAtWord) {
14608
14610
  // try to find a space or dash where wrapping could be done
14609
14611
  var wrapIndex;
14610
- var nextChar = line[match.length];
14611
- var nextIsSpaceOrDash = nextChar === SPACE || nextChar === DASH;
14612
+ const nextChar = line[match.length];
14613
+ const nextIsSpaceOrDash = nextChar === SPACE || nextChar === DASH;
14612
14614
  if (nextIsSpaceOrDash && matchWidth <= maxWidth) {
14613
14615
  wrapIndex = match.length;
14614
14616
  }
@@ -14630,7 +14632,7 @@
14630
14632
  this._addTextLine(match);
14631
14633
  textWidth = Math.max(textWidth, matchWidth);
14632
14634
  currentHeightPx += lineHeightPx;
14633
- var shouldHandleEllipsis = this._shouldHandleEllipsis(currentHeightPx);
14635
+ const shouldHandleEllipsis = this._shouldHandleEllipsis(currentHeightPx);
14634
14636
  if (shouldHandleEllipsis) {
14635
14637
  this._tryToAddEllipsisToLastLine();
14636
14638
  /*
@@ -14691,18 +14693,18 @@
14691
14693
  * @returns
14692
14694
  */
14693
14695
  _shouldHandleEllipsis(currentHeightPx) {
14694
- var fontSize = +this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, height = this.attrs.height, fixedHeight = height !== AUTO && height !== undefined, padding = this.padding(), maxHeightPx = height - padding * 2, wrap = this.wrap(), shouldWrap = wrap !== NONE;
14696
+ const fontSize = +this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, height = this.attrs.height, fixedHeight = height !== AUTO && height !== undefined, padding = this.padding(), maxHeightPx = height - padding * 2, wrap = this.wrap(), shouldWrap = wrap !== NONE;
14695
14697
  return (!shouldWrap ||
14696
14698
  (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx));
14697
14699
  }
14698
14700
  _tryToAddEllipsisToLastLine() {
14699
- var width = this.attrs.width, fixedWidth = width !== AUTO && width !== undefined, padding = this.padding(), maxWidth = width - padding * 2, shouldAddEllipsis = this.ellipsis();
14700
- var lastLine = this.textArr[this.textArr.length - 1];
14701
+ const width = this.attrs.width, fixedWidth = width !== AUTO && width !== undefined, padding = this.padding(), maxWidth = width - padding * 2, shouldAddEllipsis = this.ellipsis();
14702
+ const lastLine = this.textArr[this.textArr.length - 1];
14701
14703
  if (!lastLine || !shouldAddEllipsis) {
14702
14704
  return;
14703
14705
  }
14704
14706
  if (fixedWidth) {
14705
- var haveSpace = this._getTextWidth(lastLine.text + ELLIPSIS) < maxWidth;
14707
+ const haveSpace = this._getTextWidth(lastLine.text + ELLIPSIS) < maxWidth;
14706
14708
  if (!haveSpace) {
14707
14709
  lastLine.text = lastLine.text.slice(0, lastLine.text.length - 3);
14708
14710
  }
@@ -14976,7 +14978,7 @@
14976
14978
  */
14977
14979
  Factory.addGetterSetter(Text, 'textDecoration', '');
14978
14980
 
14979
- var EMPTY_STRING = '', NORMAL = 'normal';
14981
+ const EMPTY_STRING = '', NORMAL = 'normal';
14980
14982
  function _fillFunc(context) {
14981
14983
  context.fillText(this.partialText, 0, 0);
14982
14984
  }
@@ -15138,16 +15140,16 @@
15138
15140
  context.setAttr('textBaseline', this.textBaseline());
15139
15141
  context.setAttr('textAlign', 'left');
15140
15142
  context.save();
15141
- var textDecoration = this.textDecoration();
15142
- var fill = this.fill();
15143
- var fontSize = this.fontSize();
15144
- var glyphInfo = this.glyphInfo;
15143
+ const textDecoration = this.textDecoration();
15144
+ const fill = this.fill();
15145
+ const fontSize = this.fontSize();
15146
+ const glyphInfo = this.glyphInfo;
15145
15147
  if (textDecoration === 'underline') {
15146
15148
  context.beginPath();
15147
15149
  }
15148
- for (var i = 0; i < glyphInfo.length; i++) {
15150
+ for (let i = 0; i < glyphInfo.length; i++) {
15149
15151
  context.save();
15150
- var p0 = glyphInfo[i].p0;
15152
+ const p0 = glyphInfo[i].p0;
15151
15153
  context.translate(p0.x, p0.y);
15152
15154
  context.rotate(glyphInfo[i].rotation);
15153
15155
  this.partialText = glyphInfo[i].text;
@@ -15177,13 +15179,13 @@
15177
15179
  }
15178
15180
  _hitFunc(context) {
15179
15181
  context.beginPath();
15180
- var glyphInfo = this.glyphInfo;
15182
+ const glyphInfo = this.glyphInfo;
15181
15183
  if (glyphInfo.length >= 1) {
15182
- var p0 = glyphInfo[0].p0;
15184
+ const p0 = glyphInfo[0].p0;
15183
15185
  context.moveTo(p0.x, p0.y);
15184
15186
  }
15185
- for (var i = 0; i < glyphInfo.length; i++) {
15186
- var p1 = glyphInfo[i].p1;
15187
+ for (let i = 0; i < glyphInfo.length; i++) {
15188
+ const p1 = glyphInfo[i].p1;
15187
15189
  context.lineTo(p1.x, p1.y);
15188
15190
  }
15189
15191
  context.setAttr('lineWidth', this.fontSize());
@@ -15209,11 +15211,11 @@
15209
15211
  return Text.prototype._getContextFont.call(this);
15210
15212
  }
15211
15213
  _getTextSize(text) {
15212
- var dummyCanvas = this.dummyCanvas;
15213
- var _context = dummyCanvas.getContext('2d');
15214
+ const dummyCanvas = this.dummyCanvas;
15215
+ const _context = dummyCanvas.getContext('2d');
15214
15216
  _context.save();
15215
15217
  _context.font = this._getContextFont();
15216
- var metrics = _context.measureText(text);
15218
+ const metrics = _context.measureText(text);
15217
15219
  _context.restore();
15218
15220
  return {
15219
15221
  width: metrics.width,
@@ -15247,7 +15249,7 @@
15247
15249
  // 3. Calculate the rotation, width, and midpoint of the glyph using the start and end points,
15248
15250
  // 4. Add glyph width to the offsetToGlyph and repeat
15249
15251
  let offsetToGlyph = offset;
15250
- for (var i = 0; i < charArr.length; i++) {
15252
+ for (let i = 0; i < charArr.length; i++) {
15251
15253
  const charStartPoint = this._getPointAtLength(offsetToGlyph);
15252
15254
  if (!charStartPoint)
15253
15255
  return;
@@ -15295,19 +15297,19 @@
15295
15297
  height: 0,
15296
15298
  };
15297
15299
  }
15298
- var points = [];
15300
+ const points = [];
15299
15301
  this.glyphInfo.forEach(function (info) {
15300
15302
  points.push(info.p0.x);
15301
15303
  points.push(info.p0.y);
15302
15304
  points.push(info.p1.x);
15303
15305
  points.push(info.p1.y);
15304
15306
  });
15305
- var minX = points[0] || 0;
15306
- var maxX = points[0] || 0;
15307
- var minY = points[1] || 0;
15308
- var maxY = points[1] || 0;
15309
- var x, y;
15310
- for (var i = 0; i < points.length / 2; i++) {
15307
+ let minX = points[0] || 0;
15308
+ let maxX = points[0] || 0;
15309
+ let minY = points[1] || 0;
15310
+ let maxY = points[1] || 0;
15311
+ let x, y;
15312
+ for (let i = 0; i < points.length / 2; i++) {
15311
15313
  x = points[i * 2];
15312
15314
  y = points[i * 2 + 1];
15313
15315
  minX = Math.min(minX, x);
@@ -15315,7 +15317,7 @@
15315
15317
  minY = Math.min(minY, y);
15316
15318
  maxY = Math.max(maxY, y);
15317
15319
  }
15318
- var fontSize = this.fontSize();
15320
+ const fontSize = this.fontSize();
15319
15321
  return {
15320
15322
  x: minX - fontSize / 2,
15321
15323
  y: minY - fontSize / 2,
@@ -15498,8 +15500,8 @@
15498
15500
  */
15499
15501
  Factory.addGetterSetter(TextPath, 'kerningFunc', null);
15500
15502
 
15501
- var EVENTS_NAME = 'tr-konva';
15502
- var ATTR_CHANGE_LIST = [
15503
+ const EVENTS_NAME = 'tr-konva';
15504
+ const ATTR_CHANGE_LIST = [
15503
15505
  'resizeEnabledChange',
15504
15506
  'rotateAnchorOffsetChange',
15505
15507
  'rotateEnabledChange',
@@ -15518,8 +15520,8 @@
15518
15520
  ]
15519
15521
  .map((e) => e + `.${EVENTS_NAME}`)
15520
15522
  .join(' ');
15521
- var NODES_RECT = 'nodesRect';
15522
- var TRANSFORM_CHANGE_STR = [
15523
+ const NODES_RECT = 'nodesRect';
15524
+ const TRANSFORM_CHANGE_STR = [
15523
15525
  'widthChange',
15524
15526
  'heightChange',
15525
15527
  'scaleXChange',
@@ -15532,7 +15534,7 @@
15532
15534
  'transformsEnabledChange',
15533
15535
  'strokeWidthChange',
15534
15536
  ];
15535
- var ANGLES = {
15537
+ const ANGLES = {
15536
15538
  'top-left': -45,
15537
15539
  'top-center': 0,
15538
15540
  'top-right': 45,
@@ -15548,7 +15550,7 @@
15548
15550
  return rotateCursor;
15549
15551
  }
15550
15552
  rad += Util.degToRad(ANGLES[anchorName] || 0);
15551
- var angle = ((Util.radToDeg(rad) % 360) + 360) % 360;
15553
+ const angle = ((Util.radToDeg(rad) % 360) + 360) % 360;
15552
15554
  if (Util._inRange(angle, 315 + 22.5, 360) || Util._inRange(angle, 0, 22.5)) {
15553
15555
  // TOP
15554
15556
  return 'ns-resize';
@@ -15587,7 +15589,7 @@
15587
15589
  return 'pointer';
15588
15590
  }
15589
15591
  }
15590
- var ANCHORS_NAMES = [
15592
+ const ANCHORS_NAMES = [
15591
15593
  'top-left',
15592
15594
  'top-center',
15593
15595
  'top-right',
@@ -15597,7 +15599,7 @@
15597
15599
  'bottom-center',
15598
15600
  'bottom-right',
15599
15601
  ];
15600
- var MAX_SAFE_INTEGER = 100000000;
15602
+ const MAX_SAFE_INTEGER = 100000000;
15601
15603
  function getCenter(shape) {
15602
15604
  return {
15603
15605
  x: shape.x +
@@ -15759,7 +15761,7 @@
15759
15761
  this._resetTransformCache();
15760
15762
  // we may need it if we set node in initial props
15761
15763
  // so elements are not defined yet
15762
- var elementsCreated = !!this.findOne('.top-left');
15764
+ const elementsCreated = !!this.findOne('.top-left');
15763
15765
  if (elementsCreated) {
15764
15766
  this.update();
15765
15767
  }
@@ -15854,15 +15856,15 @@
15854
15856
  }
15855
15857
  // return absolute rotated bounding rectangle
15856
15858
  __getNodeShape(node, rot = this.rotation(), relative) {
15857
- var rect = node.getClientRect({
15859
+ const rect = node.getClientRect({
15858
15860
  skipTransform: true,
15859
15861
  skipShadow: true,
15860
15862
  skipStroke: this.ignoreStroke(),
15861
15863
  });
15862
- var absScale = node.getAbsoluteScale(relative);
15863
- var absPos = node.getAbsolutePosition(relative);
15864
- var dx = rect.x * absScale.x - node.offsetX() * absScale.x;
15865
- var dy = rect.y * absScale.y - node.offsetY() * absScale.y;
15864
+ const absScale = node.getAbsoluteScale(relative);
15865
+ const absPos = node.getAbsolutePosition(relative);
15866
+ const dx = rect.x * absScale.x - node.offsetX() * absScale.x;
15867
+ const dy = rect.y * absScale.y - node.offsetY() * absScale.y;
15866
15868
  const rotation = (Konva$2.getAngle(node.getAbsoluteRotation()) + Math.PI * 2) %
15867
15869
  (Math.PI * 2);
15868
15870
  const box = {
@@ -15879,7 +15881,7 @@
15879
15881
  }
15880
15882
  // returns box + rotation of all shapes
15881
15883
  __getNodeRect() {
15882
- var node = this.getNode();
15884
+ const node = this.getNode();
15883
15885
  if (!node) {
15884
15886
  return {
15885
15887
  x: -MAX_SAFE_INTEGER,
@@ -15896,23 +15898,23 @@
15896
15898
  skipShadow: true,
15897
15899
  skipStroke: this.ignoreStroke(),
15898
15900
  });
15899
- var points = [
15901
+ const points = [
15900
15902
  { x: box.x, y: box.y },
15901
15903
  { x: box.x + box.width, y: box.y },
15902
15904
  { x: box.x + box.width, y: box.y + box.height },
15903
15905
  { x: box.x, y: box.y + box.height },
15904
15906
  ];
15905
- var trans = node.getAbsoluteTransform();
15907
+ const trans = node.getAbsoluteTransform();
15906
15908
  points.forEach(function (point) {
15907
- var transformed = trans.point(point);
15909
+ const transformed = trans.point(point);
15908
15910
  totalPoints.push(transformed);
15909
15911
  });
15910
15912
  });
15911
15913
  const tr = new Transform();
15912
15914
  tr.rotate(-Konva$2.getAngle(this.rotation()));
15913
- var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
15915
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
15914
15916
  totalPoints.forEach(function (point) {
15915
- var transformed = tr.point(point);
15917
+ const transformed = tr.point(point);
15916
15918
  if (minX === undefined) {
15917
15919
  minX = maxX = transformed.x;
15918
15920
  minY = maxY = transformed.y;
@@ -15960,7 +15962,7 @@
15960
15962
  this._createAnchor('rotater');
15961
15963
  }
15962
15964
  _createAnchor(name) {
15963
- var anchor = new Rect({
15965
+ const anchor = new Rect({
15964
15966
  stroke: 'rgb(0, 161, 255)',
15965
15967
  fill: 'white',
15966
15968
  strokeWidth: 1,
@@ -15971,7 +15973,7 @@
15971
15973
  draggable: true,
15972
15974
  hitStrokeWidth: TOUCH_DEVICE ? 10 : 'auto',
15973
15975
  });
15974
- var self = this;
15976
+ const self = this;
15975
15977
  anchor.on('mousedown touchstart', function (e) {
15976
15978
  self._handleMouseDown(e);
15977
15979
  });
@@ -15984,9 +15986,9 @@
15984
15986
  });
15985
15987
  // add hover styling
15986
15988
  anchor.on('mouseenter', () => {
15987
- var rad = Konva$2.getAngle(this.rotation());
15988
- var rotateCursor = this.rotateAnchorCursor();
15989
- var cursor = getCursor(name, rad, rotateCursor);
15989
+ const rad = Konva$2.getAngle(this.rotation());
15990
+ const rotateCursor = this.rotateAnchorCursor();
15991
+ const cursor = getCursor(name, rad, rotateCursor);
15990
15992
  anchor.getStage().content &&
15991
15993
  (anchor.getStage().content.style.cursor = cursor);
15992
15994
  this._cursorChange = true;
@@ -15999,14 +16001,14 @@
15999
16001
  this.add(anchor);
16000
16002
  }
16001
16003
  _createBack() {
16002
- var back = new Shape({
16004
+ const back = new Shape({
16003
16005
  name: 'back',
16004
16006
  width: 0,
16005
16007
  height: 0,
16006
16008
  draggable: true,
16007
16009
  sceneFunc(ctx, shape) {
16008
- var tr = shape.getParent();
16009
- var padding = tr.padding();
16010
+ const tr = shape.getParent();
16011
+ const padding = tr.padding();
16010
16012
  ctx.beginPath();
16011
16013
  ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);
16012
16014
  ctx.moveTo(shape.width() / 2, -padding);
@@ -16019,7 +16021,7 @@
16019
16021
  if (!this.shouldOverdrawWholeArea()) {
16020
16022
  return;
16021
16023
  }
16022
- var padding = this.padding();
16024
+ const padding = this.padding();
16023
16025
  ctx.beginPath();
16024
16026
  ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);
16025
16027
  ctx.fillStrokeShape(shape);
@@ -16051,10 +16053,10 @@
16051
16053
  return;
16052
16054
  }
16053
16055
  this._movingAnchorName = e.target.name().split(' ')[0];
16054
- var attrs = this._getNodeRect();
16055
- var width = attrs.width;
16056
- var height = attrs.height;
16057
- var hypotenuse = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
16056
+ const attrs = this._getNodeRect();
16057
+ const width = attrs.width;
16058
+ const height = attrs.height;
16059
+ const hypotenuse = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
16058
16060
  this.sin = Math.abs(height / hypotenuse);
16059
16061
  this.cos = Math.abs(width / hypotenuse);
16060
16062
  if (typeof window !== 'undefined') {
@@ -16064,8 +16066,8 @@
16064
16066
  window.addEventListener('touchend', this._handleMouseUp, true);
16065
16067
  }
16066
16068
  this._transforming = true;
16067
- var ap = e.target.getAbsolutePosition();
16068
- var pos = e.target.getStage().getPointerPosition();
16069
+ const ap = e.target.getAbsolutePosition();
16070
+ const pos = e.target.getStage().getPointerPosition();
16069
16071
  this._anchorDragOffset = {
16070
16072
  x: pos.x - ap.x,
16071
16073
  y: pos.y - ap.y,
@@ -16077,9 +16079,9 @@
16077
16079
  });
16078
16080
  }
16079
16081
  _handleMouseMove(e) {
16080
- var x, y, newHypotenuse;
16081
- var anchorNode = this.findOne('.' + this._movingAnchorName);
16082
- var stage = anchorNode.getStage();
16082
+ let x, y, newHypotenuse;
16083
+ const anchorNode = this.findOne('.' + this._movingAnchorName);
16084
+ const stage = anchorNode.getStage();
16083
16085
  stage.setPointersPositions(e);
16084
16086
  const pp = stage.getPointerPosition();
16085
16087
  let newNodePos = {
@@ -16098,7 +16100,7 @@
16098
16100
  }
16099
16101
  // rotater is working very differently, so do it first
16100
16102
  if (this._movingAnchorName === 'rotater') {
16101
- var attrs = this._getNodeRect();
16103
+ const attrs = this._getNodeRect();
16102
16104
  x = anchorNode.x() - attrs.width / 2;
16103
16105
  y = -anchorNode.y() + attrs.height / 2;
16104
16106
  // hor angle is changed?
@@ -16106,7 +16108,7 @@
16106
16108
  if (attrs.height < 0) {
16107
16109
  delta -= Math.PI;
16108
16110
  }
16109
- var oldRotation = Konva$2.getAngle(this.rotation());
16111
+ const oldRotation = Konva$2.getAngle(this.rotation());
16110
16112
  const newRotation = oldRotation + delta;
16111
16113
  const tol = Konva$2.getAngle(this.rotationSnapTolerance());
16112
16114
  const snappedRot = getSnap(this.rotationSnaps(), newRotation, tol);
@@ -16115,8 +16117,8 @@
16115
16117
  this._fitNodesInto(shape, e);
16116
16118
  return;
16117
16119
  }
16118
- var shiftBehavior = this.shiftBehavior();
16119
- var keepProportion;
16120
+ const shiftBehavior = this.shiftBehavior();
16121
+ let keepProportion;
16120
16122
  if (shiftBehavior === 'inverted') {
16121
16123
  keepProportion = this.keepRatio() && !e.shiftKey;
16122
16124
  }
@@ -16235,12 +16237,12 @@
16235
16237
  }
16236
16238
  var centeredScaling = this.centeredScaling() || e.altKey;
16237
16239
  if (centeredScaling) {
16238
- var topLeft = this.findOne('.top-left');
16239
- var bottomRight = this.findOne('.bottom-right');
16240
- var topOffsetX = topLeft.x();
16241
- var topOffsetY = topLeft.y();
16242
- var bottomOffsetX = this.getWidth() - bottomRight.x();
16243
- var bottomOffsetY = this.getHeight() - bottomRight.y();
16240
+ const topLeft = this.findOne('.top-left');
16241
+ const bottomRight = this.findOne('.bottom-right');
16242
+ const topOffsetX = topLeft.x();
16243
+ const topOffsetY = topLeft.y();
16244
+ const bottomOffsetX = this.getWidth() - bottomRight.x();
16245
+ const bottomOffsetY = this.getHeight() - bottomRight.y();
16244
16246
  bottomRight.move({
16245
16247
  x: -topOffsetX,
16246
16248
  y: -topOffsetY,
@@ -16250,11 +16252,11 @@
16250
16252
  y: bottomOffsetY,
16251
16253
  });
16252
16254
  }
16253
- var absPos = this.findOne('.top-left').getAbsolutePosition();
16255
+ const absPos = this.findOne('.top-left').getAbsolutePosition();
16254
16256
  x = absPos.x;
16255
16257
  y = absPos.y;
16256
- var width = this.findOne('.bottom-right').x() - this.findOne('.top-left').x();
16257
- var height = this.findOne('.bottom-right').y() - this.findOne('.top-left').y();
16258
+ const width = this.findOne('.bottom-right').x() - this.findOne('.top-left').x();
16259
+ const height = this.findOne('.bottom-right').y() - this.findOne('.top-left').y();
16258
16260
  this._fitNodesInto({
16259
16261
  x: x,
16260
16262
  y: y,
@@ -16279,7 +16281,7 @@
16279
16281
  window.removeEventListener('mouseup', this._handleMouseUp, true);
16280
16282
  window.removeEventListener('touchend', this._handleMouseUp, true);
16281
16283
  }
16282
- var node = this.getNode();
16284
+ const node = this.getNode();
16283
16285
  activeTransformersCount--;
16284
16286
  this._fire('transformend', { evt: e, target: node });
16285
16287
  // redraw layer to restore hit graph
@@ -16296,7 +16298,7 @@
16296
16298
  }
16297
16299
  }
16298
16300
  _fitNodesInto(newAttrs, evt) {
16299
- var oldAttrs = this._getNodeRect();
16301
+ const oldAttrs = this._getNodeRect();
16300
16302
  const minSize = 1;
16301
16303
  if (Util._inRange(newAttrs.width, -this.padding() * 2 - minSize, minSize)) {
16302
16304
  this.update();
@@ -16306,7 +16308,7 @@
16306
16308
  this.update();
16307
16309
  return;
16308
16310
  }
16309
- var t = new Transform();
16311
+ const t = new Transform();
16310
16312
  t.rotate(Konva$2.getAngle(this.rotation()));
16311
16313
  if (this._movingAnchorName &&
16312
16314
  newAttrs.width < 0 &&
@@ -16446,14 +16448,14 @@
16446
16448
  }
16447
16449
  update() {
16448
16450
  var _a;
16449
- var attrs = this._getNodeRect();
16451
+ const attrs = this._getNodeRect();
16450
16452
  this.rotation(Util._getRotation(attrs.rotation));
16451
- var width = attrs.width;
16452
- var height = attrs.height;
16453
- var enabledAnchors = this.enabledAnchors();
16454
- var resizeEnabled = this.resizeEnabled();
16455
- var padding = this.padding();
16456
- var anchorSize = this.anchorSize();
16453
+ const width = attrs.width;
16454
+ const height = attrs.height;
16455
+ const enabledAnchors = this.enabledAnchors();
16456
+ const resizeEnabled = this.resizeEnabled();
16457
+ const padding = this.padding();
16458
+ const anchorSize = this.anchorSize();
16457
16459
  const anchors = this.find('._anchor');
16458
16460
  anchors.forEach((node) => {
16459
16461
  node.setAttrs({
@@ -16560,7 +16562,7 @@
16560
16562
  stopTransform() {
16561
16563
  if (this._transforming) {
16562
16564
  this._removeEvents();
16563
- var anchorNode = this.findOne('.' + this._movingAnchorName);
16565
+ const anchorNode = this.findOne('.' + this._movingAnchorName);
16564
16566
  if (anchorNode) {
16565
16567
  anchorNode.stopDrag();
16566
16568
  }
@@ -16582,7 +16584,7 @@
16582
16584
  }
16583
16585
  // overwrite clone to NOT use method from Container
16584
16586
  clone(obj) {
16585
- var node = Node.prototype.clone.call(this, obj);
16587
+ const node = Node.prototype.clone.call(this, obj);
16586
16588
  return node;
16587
16589
  }
16588
16590
  getClientRect() {
@@ -17280,7 +17282,7 @@
17280
17282
  this.a = 0;
17281
17283
  this.next = null;
17282
17284
  }
17283
- var mul_table = [
17285
+ const mul_table = [
17284
17286
  512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292,
17285
17287
  512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292,
17286
17288
  273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259,
@@ -17299,7 +17301,7 @@
17299
17301
  329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,
17300
17302
  289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259,
17301
17303
  ];
17302
- var shg_table = [
17304
+ const shg_table = [
17303
17305
  9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17,
17304
17306
  17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
17305
17307
  19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
@@ -17316,9 +17318,9 @@
17316
17318
  24, 24, 24, 24, 24, 24, 24,
17317
17319
  ];
17318
17320
  function filterGaussBlurRGBA(imageData, radius) {
17319
- var pixels = imageData.data, width = imageData.width, height = imageData.height;
17320
- var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
17321
- var div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), stackEnd = null, stack = stackStart, stackIn = null, stackOut = null, mul_sum = mul_table[radius], shg_sum = shg_table[radius];
17321
+ const pixels = imageData.data, width = imageData.width, height = imageData.height;
17322
+ let x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
17323
+ let div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), stackEnd = null, stack = stackStart, stackIn = null, stackOut = null, mul_sum = mul_table[radius], shg_sum = shg_table[radius];
17322
17324
  for (i = 1; i < div; i++) {
17323
17325
  stack = stack.next = new BlurStack();
17324
17326
  if (i === radiusPlus1) {
@@ -17509,7 +17511,7 @@
17509
17511
  * node.blurRadius(10);
17510
17512
  */
17511
17513
  const Blur = function Blur(imageData) {
17512
- var radius = Math.round(this.blurRadius());
17514
+ const radius = Math.round(this.blurRadius());
17513
17515
  if (radius > 0) {
17514
17516
  filterGaussBlurRGBA(imageData, radius);
17515
17517
  }
@@ -17534,7 +17536,7 @@
17534
17536
  * node.brightness(0.8);
17535
17537
  */
17536
17538
  const Brighten = function (imageData) {
17537
- var brightness = this.brightness() * 255, data = imageData.data, len = data.length, i;
17539
+ let brightness = this.brightness() * 255, data = imageData.data, len = data.length, i;
17538
17540
  for (i = 0; i < len; i += 4) {
17539
17541
  // red
17540
17542
  data[i] += brightness;
@@ -17566,8 +17568,8 @@
17566
17568
  * node.contrast(10);
17567
17569
  */
17568
17570
  const Contrast = function (imageData) {
17569
- var adjust = Math.pow((this.contrast() + 100) / 100, 2);
17570
- var data = imageData.data, nPixels = data.length, red = 150, green = 150, blue = 150, i;
17571
+ const adjust = Math.pow((this.contrast() + 100) / 100, 2);
17572
+ let data = imageData.data, nPixels = data.length, red = 150, green = 150, blue = 150, i;
17571
17573
  for (i = 0; i < nPixels; i += 4) {
17572
17574
  red = data[i];
17573
17575
  green = data[i + 1];
@@ -17629,7 +17631,7 @@
17629
17631
  // pixastic greyLevel is between 0 and 255. I want it between 0 and 1. Also,
17630
17632
  // a max value of greyLevel yields a white emboss, and the min value yields a black
17631
17633
  // emboss. Therefore, I changed greyLevel to whiteLevel
17632
- var strength = this.embossStrength() * 10, greyLevel = this.embossWhiteLevel() * 255, direction = this.embossDirection(), blend = this.embossBlend(), dirY = 0, dirX = 0, data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4, y = h;
17634
+ let strength = this.embossStrength() * 10, greyLevel = this.embossWhiteLevel() * 255, direction = this.embossDirection(), blend = this.embossBlend(), dirY = 0, dirX = 0, data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4, y = h;
17633
17635
  switch (direction) {
17634
17636
  case 'top-left':
17635
17637
  dirY = -1;
@@ -17667,33 +17669,33 @@
17667
17669
  Util.error('Unknown emboss direction: ' + direction);
17668
17670
  }
17669
17671
  do {
17670
- var offsetY = (y - 1) * w4;
17671
- var otherY = dirY;
17672
+ const offsetY = (y - 1) * w4;
17673
+ let otherY = dirY;
17672
17674
  if (y + otherY < 1) {
17673
17675
  otherY = 0;
17674
17676
  }
17675
17677
  if (y + otherY > h) {
17676
17678
  otherY = 0;
17677
17679
  }
17678
- var offsetYOther = (y - 1 + otherY) * w * 4;
17679
- var x = w;
17680
+ const offsetYOther = (y - 1 + otherY) * w * 4;
17681
+ let x = w;
17680
17682
  do {
17681
- var offset = offsetY + (x - 1) * 4;
17682
- var otherX = dirX;
17683
+ const offset = offsetY + (x - 1) * 4;
17684
+ let otherX = dirX;
17683
17685
  if (x + otherX < 1) {
17684
17686
  otherX = 0;
17685
17687
  }
17686
17688
  if (x + otherX > w) {
17687
17689
  otherX = 0;
17688
17690
  }
17689
- var offsetOther = offsetYOther + (x - 1 + otherX) * 4;
17690
- var dR = data[offset] - data[offsetOther];
17691
- var dG = data[offset + 1] - data[offsetOther + 1];
17692
- var dB = data[offset + 2] - data[offsetOther + 2];
17693
- var dif = dR;
17694
- var absDif = dif > 0 ? dif : -dif;
17695
- var absG = dG > 0 ? dG : -dG;
17696
- var absB = dB > 0 ? dB : -dB;
17691
+ const offsetOther = offsetYOther + (x - 1 + otherX) * 4;
17692
+ const dR = data[offset] - data[offsetOther];
17693
+ const dG = data[offset + 1] - data[offsetOther + 1];
17694
+ const dB = data[offset + 2] - data[offsetOther + 2];
17695
+ let dif = dR;
17696
+ const absDif = dif > 0 ? dif : -dif;
17697
+ const absG = dG > 0 ? dG : -dG;
17698
+ const absB = dB > 0 ? dB : -dB;
17697
17699
  if (absG > absDif) {
17698
17700
  dif = dG;
17699
17701
  }
@@ -17702,15 +17704,15 @@
17702
17704
  }
17703
17705
  dif *= strength;
17704
17706
  if (blend) {
17705
- var r = data[offset] + dif;
17706
- var g = data[offset + 1] + dif;
17707
- var b = data[offset + 2] + dif;
17707
+ const r = data[offset] + dif;
17708
+ const g = data[offset + 1] + dif;
17709
+ const b = data[offset + 2] + dif;
17708
17710
  data[offset] = r > 255 ? 255 : r < 0 ? 0 : r;
17709
17711
  data[offset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
17710
17712
  data[offset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
17711
17713
  }
17712
17714
  else {
17713
- var grey = greyLevel - dif;
17715
+ let grey = greyLevel - dif;
17714
17716
  if (grey < 0) {
17715
17717
  grey = 0;
17716
17718
  }
@@ -17758,7 +17760,7 @@
17758
17760
 
17759
17761
  function remap(fromValue, fromMin, fromMax, toMin, toMax) {
17760
17762
  // Compute the range of the data
17761
- var fromRange = fromMax - fromMin, toRange = toMax - toMin, toValue;
17763
+ let fromRange = fromMax - fromMin, toRange = toMax - toMin, toValue;
17762
17764
  // If either range is 0, then the value can only be mapped to 1 value
17763
17765
  if (fromRange === 0) {
17764
17766
  return toMin + toRange / 2;
@@ -17786,9 +17788,9 @@
17786
17788
  * node.enhance(0.4);
17787
17789
  */
17788
17790
  const Enhance = function (imageData) {
17789
- var data = imageData.data, nSubPixels = data.length, rMin = data[0], rMax = rMin, r, gMin = data[1], gMax = gMin, g, bMin = data[2], bMax = bMin, b, i;
17791
+ let data = imageData.data, nSubPixels = data.length, rMin = data[0], rMax = rMin, r, gMin = data[1], gMax = gMin, g, bMin = data[2], bMax = bMin, b, i;
17790
17792
  // If we are not enhancing anything - don't do any computation
17791
- var enhanceAmount = this.enhance();
17793
+ const enhanceAmount = this.enhance();
17792
17794
  if (enhanceAmount === 0) {
17793
17795
  return;
17794
17796
  }
@@ -17832,7 +17834,7 @@
17832
17834
  bMax = 255;
17833
17835
  bMin = 0;
17834
17836
  }
17835
- var rMid, rGoalMax, rGoalMin, gMid, gGoalMax, gGoalMin, bMid, bGoalMax, bGoalMin;
17837
+ let rMid, rGoalMax, rGoalMin, gMid, gGoalMax, gGoalMin, bMid, bGoalMax, bGoalMin;
17836
17838
  // If the enhancement is positive - stretch the histogram
17837
17839
  if (enhanceAmount > 0) {
17838
17840
  rGoalMax = rMax + enhanceAmount * (255 - rMax);
@@ -17881,7 +17883,7 @@
17881
17883
  * node.filters([Konva.Filters.Grayscale]);
17882
17884
  */
17883
17885
  const Grayscale = function (imageData) {
17884
- var data = imageData.data, len = data.length, i, brightness;
17886
+ let data = imageData.data, len = data.length, i, brightness;
17885
17887
  for (i = 0; i < len; i += 4) {
17886
17888
  brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2];
17887
17889
  // red
@@ -17928,7 +17930,7 @@
17928
17930
  * image.luminance(0.2);
17929
17931
  */
17930
17932
  const HSL = function (imageData) {
17931
- var data = imageData.data, nPixels = data.length, v = 1, s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360, l = this.luminance() * 127, i;
17933
+ let data = imageData.data, nPixels = data.length, v = 1, s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360, l = this.luminance() * 127, i;
17932
17934
  // Basis for the technique used:
17933
17935
  // http://beesbuzz.biz/code/hsv_color_transforms.php
17934
17936
  // V is the value multiplier (1 for none, 2 for double, 0.5 for half)
@@ -17940,12 +17942,12 @@
17940
17942
  //[ .299V-.299vsu-.328vsw .587V+.413vsu+.035vsw .114V-.114vsu+.292vsw ]*[G]
17941
17943
  //[ .299V-.300vsu+1.25vsw .587V-.588vsu-1.05vsw .114V+.886vsu-.203vsw ] [B]
17942
17944
  // Precompute the values in the matrix:
17943
- var vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);
17945
+ const vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);
17944
17946
  // (result spot)(source spot)
17945
- var rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
17946
- var gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;
17947
- var br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;
17948
- var r, g, b, a;
17947
+ const rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
17948
+ const gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;
17949
+ const br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;
17950
+ let r, g, b, a;
17949
17951
  for (i = 0; i < nPixels; i += 4) {
17950
17952
  r = data[i + 0];
17951
17953
  g = data[i + 1];
@@ -17970,7 +17972,7 @@
17970
17972
  * image.value(200);
17971
17973
  */
17972
17974
  const HSV = function (imageData) {
17973
- var data = imageData.data, nPixels = data.length, v = Math.pow(2, this.value()), s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360, i;
17975
+ const data = imageData.data, nPixels = data.length, v = Math.pow(2, this.value()), s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360;
17974
17976
  // Basis for the technique used:
17975
17977
  // http://beesbuzz.biz/code/hsv_color_transforms.php
17976
17978
  // V is the value multiplier (1 for none, 2 for double, 0.5 for half)
@@ -17982,13 +17984,13 @@
17982
17984
  //[ .299V-.299vsu-.328vsw .587V+.413vsu+.035vsw .114V-.114vsu+.292vsw ]*[G]
17983
17985
  //[ .299V-.300vsu+1.25vsw .587V-.588vsu-1.05vsw .114V+.886vsu-.203vsw ] [B]
17984
17986
  // Precompute the values in the matrix:
17985
- var vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);
17987
+ const vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);
17986
17988
  // (result spot)(source spot)
17987
- var rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
17988
- var gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;
17989
- var br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;
17990
- var r, g, b, a;
17991
- for (i = 0; i < nPixels; i += 4) {
17989
+ const rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
17990
+ const gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;
17991
+ const br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;
17992
+ let r, g, b, a;
17993
+ for (let i = 0; i < nPixels; i += 4) {
17992
17994
  r = data[i + 0];
17993
17995
  g = data[i + 1];
17994
17996
  b = data[i + 2];
@@ -18034,7 +18036,7 @@
18034
18036
  * node.filters([Konva.Filters.Invert]);
18035
18037
  */
18036
18038
  const Invert = function (imageData) {
18037
- var data = imageData.data, len = data.length, i;
18039
+ let data = imageData.data, len = data.length, i;
18038
18040
  for (i = 0; i < len; i += 4) {
18039
18041
  // red
18040
18042
  data[i] = 255 - data[i];
@@ -18060,19 +18062,19 @@
18060
18062
  * @param {Number} [opt.polarCenterY] vertical location for the center of the circle,
18061
18063
  * default is in the middle
18062
18064
  */
18063
- var ToPolar = function (src, dst, opt) {
18064
- var srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2, i, x, y, r = 0, g = 0, b = 0, a = 0;
18065
+ const ToPolar = function (src, dst, opt) {
18066
+ let srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2, i, x, y, r = 0, g = 0, b = 0, a = 0;
18065
18067
  // Find the largest radius
18066
- var rad, rMax = Math.sqrt(xMid * xMid + yMid * yMid);
18068
+ let rad, rMax = Math.sqrt(xMid * xMid + yMid * yMid);
18067
18069
  x = xSize - xMid;
18068
18070
  y = ySize - yMid;
18069
18071
  rad = Math.sqrt(x * x + y * y);
18070
18072
  rMax = rad > rMax ? rad : rMax;
18071
18073
  // We'll be uisng y as the radius, and x as the angle (theta=t)
18072
- var rSize = ySize, tSize = xSize, radius, theta;
18074
+ let rSize = ySize, tSize = xSize, radius, theta;
18073
18075
  // We want to cover all angles (0-360) and we need to convert to
18074
18076
  // radians (*PI/180)
18075
- var conversion = ((360 / tSize) * Math.PI) / 180, sin, cos;
18077
+ let conversion = ((360 / tSize) * Math.PI) / 180, sin, cos;
18076
18078
  // var x1, x2, x1i, x2i, y1, y2, y1i, y2i, scale;
18077
18079
  for (theta = 0; theta < tSize; theta += 1) {
18078
18080
  sin = Math.sin(theta * conversion);
@@ -18111,21 +18113,21 @@
18111
18113
  * @param {Number} [opt.polarRotation] amount to rotate the image counterclockwis,
18112
18114
  * 0 is no rotation, 360 degrees is a full rotation
18113
18115
  */
18114
- var FromPolar = function (src, dst, opt) {
18115
- var srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2, i, x, y, dx, dy, r = 0, g = 0, b = 0, a = 0;
18116
+ const FromPolar = function (src, dst, opt) {
18117
+ let srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2, i, x, y, dx, dy, r = 0, g = 0, b = 0, a = 0;
18116
18118
  // Find the largest radius
18117
- var rad, rMax = Math.sqrt(xMid * xMid + yMid * yMid);
18119
+ let rad, rMax = Math.sqrt(xMid * xMid + yMid * yMid);
18118
18120
  x = xSize - xMid;
18119
18121
  y = ySize - yMid;
18120
18122
  rad = Math.sqrt(x * x + y * y);
18121
18123
  rMax = rad > rMax ? rad : rMax;
18122
18124
  // We'll be uisng x as the radius, and y as the angle (theta=t)
18123
- var rSize = ySize, tSize = xSize, radius, theta, phaseShift = 0;
18125
+ let rSize = ySize, tSize = xSize, radius, theta, phaseShift = 0;
18124
18126
  // We need to convert to degrees and we need to make sure
18125
18127
  // it's between (0-360)
18126
18128
  // var conversion = tSize/360*180/Math.PI;
18127
18129
  //var conversion = tSize/360*180/Math.PI;
18128
- var x1, y1;
18130
+ let x1, y1;
18129
18131
  for (x = 0; x < xSize; x += 1) {
18130
18132
  for (y = 0; y < ySize; y += 1) {
18131
18133
  dx = x - xMid;
@@ -18165,19 +18167,19 @@
18165
18167
  * node.kaleidoscopeAngle(45);
18166
18168
  */
18167
18169
  const Kaleidoscope = function (imageData) {
18168
- var xSize = imageData.width, ySize = imageData.height;
18169
- var x, y, xoff, i, r, g, b, a, srcPos, dstPos;
18170
- var power = Math.round(this.kaleidoscopePower());
18171
- var angle = Math.round(this.kaleidoscopeAngle());
18172
- var offset = Math.floor((xSize * (angle % 360)) / 360);
18170
+ const xSize = imageData.width, ySize = imageData.height;
18171
+ let x, y, xoff, i, r, g, b, a, srcPos, dstPos;
18172
+ let power = Math.round(this.kaleidoscopePower());
18173
+ const angle = Math.round(this.kaleidoscopeAngle());
18174
+ const offset = Math.floor((xSize * (angle % 360)) / 360);
18173
18175
  if (power < 1) {
18174
18176
  return;
18175
18177
  }
18176
18178
  // Work with our shared buffer canvas
18177
- var tempCanvas = Util.createCanvasElement();
18179
+ const tempCanvas = Util.createCanvasElement();
18178
18180
  tempCanvas.width = xSize;
18179
18181
  tempCanvas.height = ySize;
18180
- var scratchData = tempCanvas
18182
+ const scratchData = tempCanvas
18181
18183
  .getContext('2d')
18182
18184
  .getImageData(0, 0, xSize, ySize);
18183
18185
  Util.releaseCanvas(tempCanvas);
@@ -18188,17 +18190,17 @@
18188
18190
  });
18189
18191
  // Determine how big each section will be, if it's too small
18190
18192
  // make it bigger
18191
- var minSectionSize = xSize / Math.pow(2, power);
18193
+ let minSectionSize = xSize / Math.pow(2, power);
18192
18194
  while (minSectionSize <= 8) {
18193
18195
  minSectionSize = minSectionSize * 2;
18194
18196
  power -= 1;
18195
18197
  }
18196
18198
  minSectionSize = Math.ceil(minSectionSize);
18197
- var sectionSize = minSectionSize;
18199
+ let sectionSize = minSectionSize;
18198
18200
  // Copy the offset region to 0
18199
18201
  // Depending on the size of filter and location of the offset we may need
18200
18202
  // to copy the section backwards to prevent it from rewriting itself
18201
- var xStart = 0, xEnd = sectionSize, xDelta = 1;
18203
+ let xStart = 0, xEnd = sectionSize, xDelta = 1;
18202
18204
  if (offset + minSectionSize > xSize) {
18203
18205
  xStart = sectionSize;
18204
18206
  xEnd = 0;
@@ -18259,8 +18261,8 @@
18259
18261
  Factory.addGetterSetter(Node, 'kaleidoscopeAngle', 0, getNumberValidator(), Factory.afterSetFilter);
18260
18262
 
18261
18263
  function pixelAt(idata, x, y) {
18262
- var idx = (y * idata.width + x) * 4;
18263
- var d = [];
18264
+ let idx = (y * idata.width + x) * 4;
18265
+ const d = [];
18264
18266
  d.push(idata.data[idx++], idata.data[idx++], idata.data[idx++], idata.data[idx++]);
18265
18267
  return d;
18266
18268
  }
@@ -18270,8 +18272,8 @@
18270
18272
  Math.pow(p1[2] - p2[2], 2));
18271
18273
  }
18272
18274
  function rgbMean(pTab) {
18273
- var m = [0, 0, 0];
18274
- for (var i = 0; i < pTab.length; i++) {
18275
+ const m = [0, 0, 0];
18276
+ for (let i = 0; i < pTab.length; i++) {
18275
18277
  m[0] += pTab[i][0];
18276
18278
  m[1] += pTab[i][1];
18277
18279
  m[2] += pTab[i][2];
@@ -18282,21 +18284,21 @@
18282
18284
  return m;
18283
18285
  }
18284
18286
  function backgroundMask(idata, threshold) {
18285
- var rgbv_no = pixelAt(idata, 0, 0);
18286
- var rgbv_ne = pixelAt(idata, idata.width - 1, 0);
18287
- var rgbv_so = pixelAt(idata, 0, idata.height - 1);
18288
- var rgbv_se = pixelAt(idata, idata.width - 1, idata.height - 1);
18289
- var thres = threshold || 10;
18287
+ const rgbv_no = pixelAt(idata, 0, 0);
18288
+ const rgbv_ne = pixelAt(idata, idata.width - 1, 0);
18289
+ const rgbv_so = pixelAt(idata, 0, idata.height - 1);
18290
+ const rgbv_se = pixelAt(idata, idata.width - 1, idata.height - 1);
18291
+ const thres = threshold || 10;
18290
18292
  if (rgbDistance(rgbv_no, rgbv_ne) < thres &&
18291
18293
  rgbDistance(rgbv_ne, rgbv_se) < thres &&
18292
18294
  rgbDistance(rgbv_se, rgbv_so) < thres &&
18293
18295
  rgbDistance(rgbv_so, rgbv_no) < thres) {
18294
18296
  // Mean color
18295
- var mean = rgbMean([rgbv_ne, rgbv_no, rgbv_se, rgbv_so]);
18297
+ const mean = rgbMean([rgbv_ne, rgbv_no, rgbv_se, rgbv_so]);
18296
18298
  // Mask based on color distance
18297
- var mask = [];
18298
- for (var i = 0; i < idata.width * idata.height; i++) {
18299
- var d = rgbDistance(mean, [
18299
+ const mask = [];
18300
+ for (let i = 0; i < idata.width * idata.height; i++) {
18301
+ const d = rgbDistance(mean, [
18300
18302
  idata.data[i * 4],
18301
18303
  idata.data[i * 4 + 1],
18302
18304
  idata.data[i * 4 + 2],
@@ -18307,26 +18309,26 @@
18307
18309
  }
18308
18310
  }
18309
18311
  function applyMask(idata, mask) {
18310
- for (var i = 0; i < idata.width * idata.height; i++) {
18312
+ for (let i = 0; i < idata.width * idata.height; i++) {
18311
18313
  idata.data[4 * i + 3] = mask[i];
18312
18314
  }
18313
18315
  }
18314
18316
  function erodeMask(mask, sw, sh) {
18315
- var weights = [1, 1, 1, 1, 0, 1, 1, 1, 1];
18316
- var side = Math.round(Math.sqrt(weights.length));
18317
- var halfSide = Math.floor(side / 2);
18318
- var maskResult = [];
18319
- for (var y = 0; y < sh; y++) {
18320
- for (var x = 0; x < sw; x++) {
18321
- var so = y * sw + x;
18322
- var a = 0;
18323
- for (var cy = 0; cy < side; cy++) {
18324
- for (var cx = 0; cx < side; cx++) {
18325
- var scy = y + cy - halfSide;
18326
- var scx = x + cx - halfSide;
18317
+ const weights = [1, 1, 1, 1, 0, 1, 1, 1, 1];
18318
+ const side = Math.round(Math.sqrt(weights.length));
18319
+ const halfSide = Math.floor(side / 2);
18320
+ const maskResult = [];
18321
+ for (let y = 0; y < sh; y++) {
18322
+ for (let x = 0; x < sw; x++) {
18323
+ const so = y * sw + x;
18324
+ let a = 0;
18325
+ for (let cy = 0; cy < side; cy++) {
18326
+ for (let cx = 0; cx < side; cx++) {
18327
+ const scy = y + cy - halfSide;
18328
+ const scx = x + cx - halfSide;
18327
18329
  if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {
18328
- var srcOff = scy * sw + scx;
18329
- var wt = weights[cy * side + cx];
18330
+ const srcOff = scy * sw + scx;
18331
+ const wt = weights[cy * side + cx];
18330
18332
  a += mask[srcOff] * wt;
18331
18333
  }
18332
18334
  }
@@ -18337,21 +18339,21 @@
18337
18339
  return maskResult;
18338
18340
  }
18339
18341
  function dilateMask(mask, sw, sh) {
18340
- var weights = [1, 1, 1, 1, 1, 1, 1, 1, 1];
18341
- var side = Math.round(Math.sqrt(weights.length));
18342
- var halfSide = Math.floor(side / 2);
18343
- var maskResult = [];
18344
- for (var y = 0; y < sh; y++) {
18345
- for (var x = 0; x < sw; x++) {
18346
- var so = y * sw + x;
18347
- var a = 0;
18348
- for (var cy = 0; cy < side; cy++) {
18349
- for (var cx = 0; cx < side; cx++) {
18350
- var scy = y + cy - halfSide;
18351
- var scx = x + cx - halfSide;
18342
+ const weights = [1, 1, 1, 1, 1, 1, 1, 1, 1];
18343
+ const side = Math.round(Math.sqrt(weights.length));
18344
+ const halfSide = Math.floor(side / 2);
18345
+ const maskResult = [];
18346
+ for (let y = 0; y < sh; y++) {
18347
+ for (let x = 0; x < sw; x++) {
18348
+ const so = y * sw + x;
18349
+ let a = 0;
18350
+ for (let cy = 0; cy < side; cy++) {
18351
+ for (let cx = 0; cx < side; cx++) {
18352
+ const scy = y + cy - halfSide;
18353
+ const scx = x + cx - halfSide;
18352
18354
  if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {
18353
- var srcOff = scy * sw + scx;
18354
- var wt = weights[cy * side + cx];
18355
+ const srcOff = scy * sw + scx;
18356
+ const wt = weights[cy * side + cx];
18355
18357
  a += mask[srcOff] * wt;
18356
18358
  }
18357
18359
  }
@@ -18362,21 +18364,21 @@
18362
18364
  return maskResult;
18363
18365
  }
18364
18366
  function smoothEdgeMask(mask, sw, sh) {
18365
- var weights = [1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9];
18366
- var side = Math.round(Math.sqrt(weights.length));
18367
- var halfSide = Math.floor(side / 2);
18368
- var maskResult = [];
18369
- for (var y = 0; y < sh; y++) {
18370
- for (var x = 0; x < sw; x++) {
18371
- var so = y * sw + x;
18372
- var a = 0;
18373
- for (var cy = 0; cy < side; cy++) {
18374
- for (var cx = 0; cx < side; cx++) {
18375
- var scy = y + cy - halfSide;
18376
- var scx = x + cx - halfSide;
18367
+ const weights = [1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9];
18368
+ const side = Math.round(Math.sqrt(weights.length));
18369
+ const halfSide = Math.floor(side / 2);
18370
+ const maskResult = [];
18371
+ for (let y = 0; y < sh; y++) {
18372
+ for (let x = 0; x < sw; x++) {
18373
+ const so = y * sw + x;
18374
+ let a = 0;
18375
+ for (let cy = 0; cy < side; cy++) {
18376
+ for (let cx = 0; cx < side; cx++) {
18377
+ const scy = y + cy - halfSide;
18378
+ const scx = x + cx - halfSide;
18377
18379
  if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {
18378
- var srcOff = scy * sw + scx;
18379
- var wt = weights[cy * side + cx];
18380
+ const srcOff = scy * sw + scx;
18381
+ const wt = weights[cy * side + cx];
18380
18382
  a += mask[srcOff] * wt;
18381
18383
  }
18382
18384
  }
@@ -18399,7 +18401,7 @@
18399
18401
  */
18400
18402
  const Mask = function (imageData) {
18401
18403
  // Detect pixels close to the background color
18402
- var threshold = this.threshold(), mask = backgroundMask(imageData, threshold);
18404
+ let threshold = this.threshold(), mask = backgroundMask(imageData, threshold);
18403
18405
  if (mask) {
18404
18406
  // Erode
18405
18407
  mask = erodeMask(mask, imageData.width, imageData.height);
@@ -18427,8 +18429,8 @@
18427
18429
  * node.noise(0.8);
18428
18430
  */
18429
18431
  const Noise = function (imageData) {
18430
- var amount = this.noise() * 255, data = imageData.data, nPixels = data.length, half = amount / 2, i;
18431
- for (i = 0; i < nPixels; i += 4) {
18432
+ const amount = this.noise() * 255, data = imageData.data, nPixels = data.length, half = amount / 2;
18433
+ for (let i = 0; i < nPixels; i += 4) {
18432
18434
  data[i + 0] += half - 2 * half * Math.random();
18433
18435
  data[i + 1] += half - 2 * half * Math.random();
18434
18436
  data[i + 2] += half - 2 * half * Math.random();
@@ -18443,7 +18445,6 @@
18443
18445
  * @returns {Number}
18444
18446
  */
18445
18447
 
18446
- /*eslint-disable max-depth */
18447
18448
  /**
18448
18449
  * Pixelate Filter. Averages groups of pixels and redraws
18449
18450
  * them as larger pixels
@@ -18458,7 +18459,7 @@
18458
18459
  * node.pixelSize(10);
18459
18460
  */
18460
18461
  const Pixelate = function (imageData) {
18461
- var pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, x, y, i,
18462
+ let pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, x, y, i,
18462
18463
  //pixelsPerBin = pixelSize * pixelSize,
18463
18464
  red, green, blue, alpha, nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), xBinStart, xBinEnd, yBinStart, yBinEnd, xBin, yBin, pixelsInBin, data = imageData.data;
18464
18465
  if (pixelSize <= 0) {
@@ -18544,7 +18545,7 @@
18544
18545
  */
18545
18546
  const Posterize = function (imageData) {
18546
18547
  // level must be between 1 and 255
18547
- var levels = Math.round(this.levels() * 254) + 1, data = imageData.data, len = data.length, scale = 255 / levels, i;
18548
+ let levels = Math.round(this.levels() * 254) + 1, data = imageData.data, len = data.length, scale = 255 / levels, i;
18548
18549
  for (i = 0; i < len; i += 1) {
18549
18550
  data[i] = Math.floor(data[i] / scale) * scale;
18550
18551
  }
@@ -18572,7 +18573,7 @@
18572
18573
  * node.green(200);
18573
18574
  */
18574
18575
  const RGB = function (imageData) {
18575
- var data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), i, brightness;
18576
+ let data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), i, brightness;
18576
18577
  for (i = 0; i < nPixels; i += 4) {
18577
18578
  brightness =
18578
18579
  (0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]) / 255;
@@ -18647,9 +18648,9 @@
18647
18648
  * node.alpha(0.3);
18648
18649
  */
18649
18650
  const RGBA = function (imageData) {
18650
- var data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), alpha = this.alpha(), i, ia;
18651
- for (i = 0; i < nPixels; i += 4) {
18652
- ia = 1 - alpha;
18651
+ const data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), alpha = this.alpha();
18652
+ for (let i = 0; i < nPixels; i += 4) {
18653
+ const ia = 1 - alpha;
18653
18654
  data[i] = red * alpha + data[i] * ia; // r
18654
18655
  data[i + 1] = green * alpha + data[i + 1] * ia; // g
18655
18656
  data[i + 2] = blue * alpha + data[i + 2] * ia; // b
@@ -18736,7 +18737,7 @@
18736
18737
  * node.filters([Konva.Filters.Sepia]);
18737
18738
  */
18738
18739
  const Sepia = function (imageData) {
18739
- var data = imageData.data, nPixels = data.length, i, r, g, b;
18740
+ let data = imageData.data, nPixels = data.length, i, r, g, b;
18740
18741
  for (i = 0; i < nPixels; i += 4) {
18741
18742
  r = data[i + 0];
18742
18743
  g = data[i + 1];
@@ -18761,15 +18762,16 @@
18761
18762
  * node.filters([Konva.Filters.Solarize]);
18762
18763
  */
18763
18764
  const Solarize = function (imageData) {
18764
- var data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4, y = h;
18765
+ const data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4;
18766
+ let y = h;
18765
18767
  do {
18766
- var offsetY = (y - 1) * w4;
18767
- var x = w;
18768
+ const offsetY = (y - 1) * w4;
18769
+ let x = w;
18768
18770
  do {
18769
- var offset = offsetY + (x - 1) * 4;
18770
- var r = data[offset];
18771
- var g = data[offset + 1];
18772
- var b = data[offset + 2];
18771
+ const offset = offsetY + (x - 1) * 4;
18772
+ let r = data[offset];
18773
+ let g = data[offset + 1];
18774
+ let b = data[offset + 2];
18773
18775
  if (r > 127) {
18774
18776
  r = 255 - r;
18775
18777
  }
@@ -18801,8 +18803,8 @@
18801
18803
  * node.threshold(0.1);
18802
18804
  */
18803
18805
  const Threshold = function (imageData) {
18804
- var level = this.threshold() * 255, data = imageData.data, len = data.length, i;
18805
- for (i = 0; i < len; i += 1) {
18806
+ const level = this.threshold() * 255, data = imageData.data, len = data.length;
18807
+ for (let i = 0; i < len; i += 1) {
18806
18808
  data[i] = data[i] < level ? 0 : 255;
18807
18809
  }
18808
18810
  };