konva 9.2.0 → 9.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/konva.js CHANGED
@@ -5,17 +5,17 @@
5
5
  })(this, (function () { 'use strict';
6
6
 
7
7
  /*
8
- * Konva JavaScript Framework v9.2.0
8
+ * Konva JavaScript Framework v9.2.2
9
9
  * http://konvajs.org/
10
10
  * Licensed under the MIT
11
- * Date: Mon Jun 05 2023
11
+ * Date: Mon Oct 09 2023
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)
15
15
  *
16
16
  * @license
17
17
  */
18
- var PI_OVER_180 = Math.PI / 180;
18
+ const PI_OVER_180 = Math.PI / 180;
19
19
  /**
20
20
  * @namespace Konva
21
21
  */
@@ -35,7 +35,7 @@
35
35
  : {};
36
36
  const Konva$2 = {
37
37
  _global: glob,
38
- version: '9.2.0',
38
+ version: '9.2.2',
39
39
  isBrowser: detectBrowser(),
40
40
  isUnminified: /param/.test(function (param) { }.toString()),
41
41
  dblClickWindow: 400,
@@ -1109,7 +1109,7 @@
1109
1109
  releaseCanvas(...canvases) {
1110
1110
  if (!Konva$2.releaseCanvasOnDestroy)
1111
1111
  return;
1112
- canvases.forEach(c => {
1112
+ canvases.forEach((c) => {
1113
1113
  c.width = 0;
1114
1114
  c.height = 0;
1115
1115
  });
@@ -1120,7 +1120,11 @@
1120
1120
  let bottomLeft = 0;
1121
1121
  let bottomRight = 0;
1122
1122
  if (typeof cornerRadius === 'number') {
1123
- topLeft = topRight = bottomLeft = bottomRight = Math.min(cornerRadius, width / 2, height / 2);
1123
+ topLeft =
1124
+ topRight =
1125
+ bottomLeft =
1126
+ bottomRight =
1127
+ Math.min(cornerRadius, width / 2, height / 2);
1124
1128
  }
1125
1129
  else {
1126
1130
  topLeft = Math.min(cornerRadius[0] || 0, width / 2, height / 2);
@@ -1137,7 +1141,7 @@
1137
1141
  context.arc(bottomLeft, height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);
1138
1142
  context.lineTo(0, topLeft);
1139
1143
  context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);
1140
- }
1144
+ },
1141
1145
  };
1142
1146
 
1143
1147
  function _formatValue(val) {
@@ -1481,11 +1485,13 @@
1481
1485
  'shadowBlur',
1482
1486
  'shadowOffsetX',
1483
1487
  'shadowOffsetY',
1488
+ 'letterSpacing',
1484
1489
  'lineCap',
1485
1490
  'lineDashOffset',
1486
1491
  'lineJoin',
1487
1492
  'lineWidth',
1488
1493
  'miterLimit',
1494
+ 'direction',
1489
1495
  'font',
1490
1496
  'textAlign',
1491
1497
  'textBaseline',
@@ -1677,16 +1683,17 @@
1677
1683
  * @method
1678
1684
  * @name Konva.Context#arc
1679
1685
  */
1680
- arc(a0, a1, a2, a3, a4, a5) {
1681
- this._context.arc(a0, a1, a2, a3, a4, a5);
1686
+ arc(x, y, radius, startAngle, endAngle, counterClockwise) {
1687
+ this._context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
1682
1688
  }
1683
1689
  /**
1684
1690
  * arcTo function.
1685
1691
  * @method
1686
1692
  * @name Konva.Context#arcTo
1693
+ *
1687
1694
  */
1688
- arcTo(a0, a1, a2, a3, a4) {
1689
- this._context.arcTo(a0, a1, a2, a3, a4);
1695
+ arcTo(x1, y1, x2, y2, radius) {
1696
+ this._context.arcTo(x1, y1, x2, y2, radius);
1690
1697
  }
1691
1698
  /**
1692
1699
  * beginPath function.
@@ -1701,16 +1708,16 @@
1701
1708
  * @method
1702
1709
  * @name Konva.Context#bezierCurveTo
1703
1710
  */
1704
- bezierCurveTo(a0, a1, a2, a3, a4, a5) {
1705
- this._context.bezierCurveTo(a0, a1, a2, a3, a4, a5);
1711
+ bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
1712
+ this._context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
1706
1713
  }
1707
1714
  /**
1708
1715
  * clearRect function.
1709
1716
  * @method
1710
1717
  * @name Konva.Context#clearRect
1711
1718
  */
1712
- clearRect(a0, a1, a2, a3) {
1713
- this._context.clearRect(a0, a1, a2, a3);
1719
+ clearRect(x, y, width, height) {
1720
+ this._context.clearRect(x, y, width, height);
1714
1721
  }
1715
1722
  clip(...args) {
1716
1723
  this._context.clip.apply(this._context, args);
@@ -1728,13 +1735,13 @@
1728
1735
  * @method
1729
1736
  * @name Konva.Context#createImageData
1730
1737
  */
1731
- createImageData(a0, a1) {
1738
+ createImageData(width, height) {
1732
1739
  var a = arguments;
1733
1740
  if (a.length === 2) {
1734
- return this._context.createImageData(a0, a1);
1741
+ return this._context.createImageData(width, height);
1735
1742
  }
1736
1743
  else if (a.length === 1) {
1737
- return this._context.createImageData(a0);
1744
+ return this._context.createImageData(width);
1738
1745
  }
1739
1746
  }
1740
1747
  /**
@@ -1742,41 +1749,41 @@
1742
1749
  * @method
1743
1750
  * @name Konva.Context#createLinearGradient
1744
1751
  */
1745
- createLinearGradient(a0, a1, a2, a3) {
1746
- return this._context.createLinearGradient(a0, a1, a2, a3);
1752
+ createLinearGradient(x0, y0, x1, y1) {
1753
+ return this._context.createLinearGradient(x0, y0, x1, y1);
1747
1754
  }
1748
1755
  /**
1749
1756
  * createPattern function.
1750
1757
  * @method
1751
1758
  * @name Konva.Context#createPattern
1752
1759
  */
1753
- createPattern(a0, a1) {
1754
- return this._context.createPattern(a0, a1);
1760
+ createPattern(image, repetition) {
1761
+ return this._context.createPattern(image, repetition);
1755
1762
  }
1756
1763
  /**
1757
1764
  * createRadialGradient function.
1758
1765
  * @method
1759
1766
  * @name Konva.Context#createRadialGradient
1760
1767
  */
1761
- createRadialGradient(a0, a1, a2, a3, a4, a5) {
1762
- return this._context.createRadialGradient(a0, a1, a2, a3, a4, a5);
1768
+ createRadialGradient(x0, y0, r0, x1, y1, r1) {
1769
+ return this._context.createRadialGradient(x0, y0, r0, x1, y1, r1);
1763
1770
  }
1764
1771
  /**
1765
1772
  * drawImage function.
1766
1773
  * @method
1767
1774
  * @name Konva.Context#drawImage
1768
1775
  */
1769
- drawImage(a0, a1, a2, a3, a4, a5, a6, a7, a8) {
1776
+ drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {
1770
1777
  // this._context.drawImage(...arguments);
1771
1778
  var a = arguments, _context = this._context;
1772
1779
  if (a.length === 3) {
1773
- _context.drawImage(a0, a1, a2);
1780
+ _context.drawImage(image, sx, sy);
1774
1781
  }
1775
1782
  else if (a.length === 5) {
1776
- _context.drawImage(a0, a1, a2, a3, a4);
1783
+ _context.drawImage(image, sx, sy, sWidth, sHeight);
1777
1784
  }
1778
1785
  else if (a.length === 9) {
1779
- _context.drawImage(a0, a1, a2, a3, a4, a5, a6, a7, a8);
1786
+ _context.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
1780
1787
  }
1781
1788
  }
1782
1789
  /**
@@ -1784,8 +1791,8 @@
1784
1791
  * @method
1785
1792
  * @name Konva.Context#ellipse
1786
1793
  */
1787
- ellipse(a0, a1, a2, a3, a4, a5, a6, a7) {
1788
- this._context.ellipse(a0, a1, a2, a3, a4, a5, a6, a7);
1794
+ ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
1795
+ this._context.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise);
1789
1796
  }
1790
1797
  /**
1791
1798
  * isPointInPath function.
@@ -1844,48 +1851,48 @@
1844
1851
  * @method
1845
1852
  * @name Konva.Context#getImageData
1846
1853
  */
1847
- getImageData(a0, a1, a2, a3) {
1848
- return this._context.getImageData(a0, a1, a2, a3);
1854
+ getImageData(sx, sy, sw, sh) {
1855
+ return this._context.getImageData(sx, sy, sw, sh);
1849
1856
  }
1850
1857
  /**
1851
1858
  * lineTo function.
1852
1859
  * @method
1853
1860
  * @name Konva.Context#lineTo
1854
1861
  */
1855
- lineTo(a0, a1) {
1856
- this._context.lineTo(a0, a1);
1862
+ lineTo(x, y) {
1863
+ this._context.lineTo(x, y);
1857
1864
  }
1858
1865
  /**
1859
1866
  * moveTo function.
1860
1867
  * @method
1861
1868
  * @name Konva.Context#moveTo
1862
1869
  */
1863
- moveTo(a0, a1) {
1864
- this._context.moveTo(a0, a1);
1870
+ moveTo(x, y) {
1871
+ this._context.moveTo(x, y);
1865
1872
  }
1866
1873
  /**
1867
1874
  * rect function.
1868
1875
  * @method
1869
1876
  * @name Konva.Context#rect
1870
1877
  */
1871
- rect(a0, a1, a2, a3) {
1872
- this._context.rect(a0, a1, a2, a3);
1878
+ rect(x, y, width, height) {
1879
+ this._context.rect(x, y, width, height);
1873
1880
  }
1874
1881
  /**
1875
1882
  * putImageData function.
1876
1883
  * @method
1877
1884
  * @name Konva.Context#putImageData
1878
1885
  */
1879
- putImageData(a0, a1, a2) {
1880
- this._context.putImageData(a0, a1, a2);
1886
+ putImageData(imageData, dx, dy) {
1887
+ this._context.putImageData(imageData, dx, dy);
1881
1888
  }
1882
1889
  /**
1883
1890
  * quadraticCurveTo function.
1884
1891
  * @method
1885
1892
  * @name Konva.Context#quadraticCurveTo
1886
1893
  */
1887
- quadraticCurveTo(a0, a1, a2, a3) {
1888
- this._context.quadraticCurveTo(a0, a1, a2, a3);
1894
+ quadraticCurveTo(cpx, cpy, x, y) {
1895
+ this._context.quadraticCurveTo(cpx, cpy, x, y);
1889
1896
  }
1890
1897
  /**
1891
1898
  * restore function.
@@ -1900,8 +1907,8 @@
1900
1907
  * @method
1901
1908
  * @name Konva.Context#rotate
1902
1909
  */
1903
- rotate(a0) {
1904
- this._context.rotate(a0);
1910
+ rotate(angle) {
1911
+ this._context.rotate(angle);
1905
1912
  }
1906
1913
  /**
1907
1914
  * save function.
@@ -1916,26 +1923,26 @@
1916
1923
  * @method
1917
1924
  * @name Konva.Context#scale
1918
1925
  */
1919
- scale(a0, a1) {
1920
- this._context.scale(a0, a1);
1926
+ scale(x, y) {
1927
+ this._context.scale(x, y);
1921
1928
  }
1922
1929
  /**
1923
1930
  * setLineDash function.
1924
1931
  * @method
1925
1932
  * @name Konva.Context#setLineDash
1926
1933
  */
1927
- setLineDash(a0) {
1934
+ setLineDash(segments) {
1928
1935
  // works for Chrome and IE11
1929
1936
  if (this._context.setLineDash) {
1930
- this._context.setLineDash(a0);
1937
+ this._context.setLineDash(segments);
1931
1938
  }
1932
1939
  else if ('mozDash' in this._context) {
1933
1940
  // verified that this works in firefox
1934
- this._context['mozDash'] = a0;
1941
+ this._context['mozDash'] = segments;
1935
1942
  }
1936
1943
  else if ('webkitLineDash' in this._context) {
1937
1944
  // does not currently work for Safari
1938
- this._context['webkitLineDash'] = a0;
1945
+ this._context['webkitLineDash'] = segments;
1939
1946
  }
1940
1947
  // no support for IE9 and IE10
1941
1948
  }
@@ -1952,8 +1959,8 @@
1952
1959
  * @method
1953
1960
  * @name Konva.Context#setTransform
1954
1961
  */
1955
- setTransform(a0, a1, a2, a3, a4, a5) {
1956
- this._context.setTransform(a0, a1, a2, a3, a4, a5);
1962
+ setTransform(a, b, c, d, e, f) {
1963
+ this._context.setTransform(a, b, c, d, e, f);
1957
1964
  }
1958
1965
  /**
1959
1966
  * stroke function.
@@ -1973,24 +1980,24 @@
1973
1980
  * @method
1974
1981
  * @name Konva.Context#strokeText
1975
1982
  */
1976
- strokeText(a0, a1, a2, a3) {
1977
- this._context.strokeText(a0, a1, a2, a3);
1983
+ strokeText(text, x, y, maxWidth) {
1984
+ this._context.strokeText(text, x, y, maxWidth);
1978
1985
  }
1979
1986
  /**
1980
1987
  * transform function.
1981
1988
  * @method
1982
1989
  * @name Konva.Context#transform
1983
1990
  */
1984
- transform(a0, a1, a2, a3, a4, a5) {
1985
- this._context.transform(a0, a1, a2, a3, a4, a5);
1991
+ transform(a, b, c, d, e, f) {
1992
+ this._context.transform(a, b, c, d, e, f);
1986
1993
  }
1987
1994
  /**
1988
1995
  * translate function.
1989
1996
  * @method
1990
1997
  * @name Konva.Context#translate
1991
1998
  */
1992
- translate(a0, a1) {
1993
- this._context.translate(a0, a1);
1999
+ translate(x, y) {
2000
+ this._context.translate(x, y);
1994
2001
  }
1995
2002
  _enableTrace() {
1996
2003
  var that = this, len = CONTEXT_METHODS.length, origSetter = this.setAttr, n, args;
@@ -2681,7 +2688,7 @@
2681
2688
  conf.height === undefined) {
2682
2689
  rect = this.getClientRect({
2683
2690
  skipTransform: true,
2684
- relativeTo: this.getParent(),
2691
+ relativeTo: this.getParent() || undefined,
2685
2692
  });
2686
2693
  }
2687
2694
  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;
@@ -2818,7 +2825,7 @@
2818
2825
  { x: rect.x + rect.width, y: rect.y + rect.height },
2819
2826
  { x: rect.x, y: rect.y + rect.height },
2820
2827
  ];
2821
- var minX, minY, maxX, maxY;
2828
+ var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
2822
2829
  var trans = this.getAbsoluteTransform(top);
2823
2830
  points.forEach(function (point) {
2824
2831
  var transformed = trans.point(point);
@@ -3320,8 +3327,9 @@
3320
3327
  addChildren(nodes);
3321
3328
  }
3322
3329
  }
3323
- if (that.nodeType !== UPPER_STAGE) {
3324
- addChildren(that.getStage().getChildren());
3330
+ const stage = this.getStage();
3331
+ if (that.nodeType !== UPPER_STAGE && stage) {
3332
+ addChildren(stage.getChildren());
3325
3333
  }
3326
3334
  return index;
3327
3335
  }
@@ -3381,11 +3389,12 @@
3381
3389
  * rect.getRelativePointerPosition();
3382
3390
  */
3383
3391
  getRelativePointerPosition() {
3384
- if (!this.getStage()) {
3392
+ const stage = this.getStage();
3393
+ if (!stage) {
3385
3394
  return null;
3386
3395
  }
3387
3396
  // get pointer (say mouse or touch) position
3388
- var pos = this.getStage().getPointerPosition();
3397
+ var pos = stage.getPointerPosition();
3389
3398
  if (!pos) {
3390
3399
  return null;
3391
3400
  }
@@ -3432,12 +3441,10 @@
3432
3441
  return absoluteTransform.getTranslation();
3433
3442
  }
3434
3443
  setAbsolutePosition(pos) {
3435
- var origTrans = this._clearTransform();
3444
+ const { x, y, ...origTrans } = this._clearTransform();
3436
3445
  // don't clear translation
3437
- this.attrs.x = origTrans.x;
3438
- this.attrs.y = origTrans.y;
3439
- delete origTrans.x;
3440
- delete origTrans.y;
3446
+ this.attrs.x = x;
3447
+ this.attrs.y = y;
3441
3448
  // important, use non cached value
3442
3449
  this._clearCache(TRANSFORM);
3443
3450
  var it = this._getAbsoluteTransform().copy();
@@ -3831,7 +3838,7 @@
3831
3838
  return parent.getStage();
3832
3839
  }
3833
3840
  else {
3834
- return undefined;
3841
+ return null;
3835
3842
  }
3836
3843
  }
3837
3844
  /**
@@ -4488,6 +4495,9 @@
4488
4495
  var pointerId = evt ? evt.pointerId : undefined;
4489
4496
  var stage = this.getStage();
4490
4497
  var ap = this.getAbsolutePosition();
4498
+ if (!stage) {
4499
+ return;
4500
+ }
4491
4501
  var pos = stage._getPointerById(pointerId) ||
4492
4502
  stage._changedPointerPositions[0] ||
4493
4503
  ap;
@@ -5534,7 +5544,7 @@
5534
5544
  */
5535
5545
  getAllIntersections(pos) {
5536
5546
  var arr = [];
5537
- this.find('Shape').forEach(function (shape) {
5547
+ this.find('Shape').forEach((shape) => {
5538
5548
  if (shape.isVisible() && shape.intersects(pos)) {
5539
5549
  arr.push(shape);
5540
5550
  }
@@ -5635,9 +5645,8 @@
5635
5645
  context.restore();
5636
5646
  }
5637
5647
  }
5638
- getClientRect(config) {
5648
+ getClientRect(config = {}) {
5639
5649
  var _a;
5640
- config = config || {};
5641
5650
  var skipTransform = config.skipTransform;
5642
5651
  var relativeTo = config.relativeTo;
5643
5652
  var minX, minY, maxX, maxY;
@@ -6231,20 +6240,24 @@
6231
6240
  _pointerenter(evt) {
6232
6241
  this.setPointersPositions(evt);
6233
6242
  const events = getEventsMap(evt.type);
6234
- this._fire(events.pointerenter, {
6235
- evt: evt,
6236
- target: this,
6237
- currentTarget: this,
6238
- });
6243
+ if (events) {
6244
+ this._fire(events.pointerenter, {
6245
+ evt: evt,
6246
+ target: this,
6247
+ currentTarget: this,
6248
+ });
6249
+ }
6239
6250
  }
6240
6251
  _pointerover(evt) {
6241
6252
  this.setPointersPositions(evt);
6242
6253
  const events = getEventsMap(evt.type);
6243
- this._fire(events.pointerover, {
6244
- evt: evt,
6245
- target: this,
6246
- currentTarget: this,
6247
- });
6254
+ if (events) {
6255
+ this._fire(events.pointerover, {
6256
+ evt: evt,
6257
+ target: this,
6258
+ currentTarget: this,
6259
+ });
6260
+ }
6248
6261
  }
6249
6262
  _getTargetShape(evenType) {
6250
6263
  let shape = this[evenType + 'targetShape'];
@@ -6284,7 +6297,7 @@
6284
6297
  currentTarget: this,
6285
6298
  });
6286
6299
  }
6287
- this.pointerPos = undefined;
6300
+ this.pointerPos = null;
6288
6301
  this._pointerPositions = [];
6289
6302
  }
6290
6303
  _pointerdown(evt) {
@@ -6301,8 +6314,7 @@
6301
6314
  // probably we are staring a click
6302
6315
  Konva$2['_' + eventType + 'ListenClick'] = true;
6303
6316
  // no shape detected? do nothing
6304
- const hasShape = shape && shape.isListening();
6305
- if (!hasShape) {
6317
+ if (!shape || !shape.isListening()) {
6306
6318
  return;
6307
6319
  }
6308
6320
  if (Konva$2.capturePointerEventsEnabled) {
@@ -6356,8 +6368,8 @@
6356
6368
  const event = { evt: evt, pointerId };
6357
6369
  var differentTarget = targetShape !== shape;
6358
6370
  if (differentTarget && targetShape) {
6359
- targetShape._fireAndBubble(events.pointerout, Object.assign({}, event), shape);
6360
- targetShape._fireAndBubble(events.pointerleave, Object.assign({}, event), shape);
6371
+ targetShape._fireAndBubble(events.pointerout, { ...event }, shape);
6372
+ targetShape._fireAndBubble(events.pointerleave, { ...event }, shape);
6361
6373
  }
6362
6374
  if (shape) {
6363
6375
  if (processedShapesIds[shape._id]) {
@@ -6368,11 +6380,11 @@
6368
6380
  if (shape && shape.isListening()) {
6369
6381
  triggeredOnShape = true;
6370
6382
  if (differentTarget) {
6371
- shape._fireAndBubble(events.pointerover, Object.assign({}, event), targetShape);
6372
- shape._fireAndBubble(events.pointerenter, Object.assign({}, event), targetShape);
6383
+ shape._fireAndBubble(events.pointerover, { ...event }, targetShape);
6384
+ shape._fireAndBubble(events.pointerenter, { ...event }, targetShape);
6373
6385
  this[eventType + 'targetShape'] = shape;
6374
6386
  }
6375
- shape._fireAndBubble(events.pointermove, Object.assign({}, event));
6387
+ shape._fireAndBubble(events.pointermove, { ...event });
6376
6388
  }
6377
6389
  else {
6378
6390
  if (targetShape) {
@@ -6434,14 +6446,14 @@
6434
6446
  if (shape && shape.isListening()) {
6435
6447
  triggeredOnShape = true;
6436
6448
  this[eventType + 'ClickEndShape'] = shape;
6437
- shape._fireAndBubble(events.pointerup, Object.assign({}, event));
6449
+ shape._fireAndBubble(events.pointerup, { ...event });
6438
6450
  // detect if click or double click occurred
6439
6451
  if (Konva$2['_' + eventType + 'ListenClick'] &&
6440
6452
  clickStartShape &&
6441
6453
  clickStartShape === shape) {
6442
- shape._fireAndBubble(events.pointerclick, Object.assign({}, event));
6454
+ shape._fireAndBubble(events.pointerclick, { ...event });
6443
6455
  if (fireDblClick && clickEndShape && clickEndShape === shape) {
6444
- shape._fireAndBubble(events.pointerdblclick, Object.assign({}, event));
6456
+ shape._fireAndBubble(events.pointerdblclick, { ...event });
6445
6457
  }
6446
6458
  }
6447
6459
  }
@@ -7012,10 +7024,14 @@
7012
7024
  * @returns {Boolean}
7013
7025
  */
7014
7026
  intersects(point) {
7015
- var stage = this.getStage(), bufferHitCanvas = stage.bufferHitCanvas, p;
7027
+ var stage = this.getStage();
7028
+ if (!stage) {
7029
+ return false;
7030
+ }
7031
+ const bufferHitCanvas = stage.bufferHitCanvas;
7016
7032
  bufferHitCanvas.getContext().clear();
7017
- this.drawHit(bufferHitCanvas, null, true);
7018
- p = bufferHitCanvas.context.getImageData(Math.round(point.x), Math.round(point.y), 1, 1).data;
7033
+ this.drawHit(bufferHitCanvas, undefined, true);
7034
+ const p = bufferHitCanvas.context.getImageData(Math.round(point.x), Math.round(point.y), 1, 1).data;
7019
7035
  return p[3] > 0;
7020
7036
  }
7021
7037
  destroy() {
@@ -7128,7 +7144,8 @@
7128
7144
  // 1 - simple drawing when nothing is cached.
7129
7145
  // 2 - when we are caching current
7130
7146
  // 3 - when node is cached and we need to draw it into layer
7131
- var layer = this.getLayer(), canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferCanvas, bufferContext;
7147
+ var layer = this.getLayer();
7148
+ var canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferCanvas, bufferContext;
7132
7149
  var skipBuffer = canvas.isCache;
7133
7150
  var cachingSelf = top === this;
7134
7151
  if (!this.isVisible() && !cachingSelf) {
@@ -8276,7 +8293,7 @@
8276
8293
  * var fillRule = shape.fillRule();
8277
8294
  *
8278
8295
  * // set fill rule
8279
- * shape.fillRule('evenodd);
8296
+ * shape.fillRule('evenodd');
8280
8297
  */
8281
8298
  Factory.backCompat(Shape, {
8282
8299
  dashArray: 'dash',
@@ -8854,7 +8871,7 @@
8854
8871
  Group.prototype.nodeType = 'Group';
8855
8872
  _registerNode(Group);
8856
8873
 
8857
- var now = (function () {
8874
+ const now = (function () {
8858
8875
  if (glob.performance && glob.performance.now) {
8859
8876
  return function () {
8860
8877
  return glob.performance.now();
@@ -8906,20 +8923,10 @@
8906
8923
  * @return {Konva.Animation} this
8907
8924
  */
8908
8925
  setLayers(layers) {
8909
- var lays = [];
8926
+ let lays = [];
8910
8927
  // if passing in no layers
8911
- if (!layers) {
8912
- lays = [];
8913
- }
8914
- else if (layers.length > 0) {
8915
- // if passing in an array of Layers
8916
- // NOTE: layers could be an array. for simplicity, I'm just inspecting
8917
- // the length property to check for both cases
8918
- lays = layers;
8919
- }
8920
- else {
8921
- // if passing in a Layer
8922
- lays = [layers];
8928
+ if (layers) {
8929
+ lays = Array.isArray(layers) ? layers : [layers];
8923
8930
  }
8924
8931
  this.layers = lays;
8925
8932
  return this;
@@ -8941,9 +8948,10 @@
8941
8948
  * @return {Bool} true if layer is added to animation, otherwise false
8942
8949
  */
8943
8950
  addLayer(layer) {
8944
- var layers = this.layers, len = layers.length, n;
8951
+ const layers = this.layers;
8952
+ const len = layers.length;
8945
8953
  // don't add the layer if it already exists
8946
- for (n = 0; n < len; n++) {
8954
+ for (let n = 0; n < len; n++) {
8947
8955
  if (layers[n]._id === layer._id) {
8948
8956
  return false;
8949
8957
  }
@@ -8958,8 +8966,10 @@
8958
8966
  * @return {Bool} is animation running?
8959
8967
  */
8960
8968
  isRunning() {
8961
- var a = Animation, animations = a.animations, len = animations.length, n;
8962
- for (n = 0; n < len; n++) {
8969
+ const a = Animation;
8970
+ const animations = a.animations;
8971
+ const len = animations.length;
8972
+ for (let n = 0; n < len; n++) {
8963
8973
  if (animations[n].id === this.id) {
8964
8974
  return true;
8965
8975
  }
@@ -9000,8 +9010,10 @@
9000
9010
  this._handleAnimation();
9001
9011
  }
9002
9012
  static _removeAnimation(anim) {
9003
- var id = anim.id, animations = this.animations, len = animations.length, n;
9004
- for (n = 0; n < len; n++) {
9013
+ const id = anim.id;
9014
+ const animations = this.animations;
9015
+ const len = animations.length;
9016
+ for (let n = 0; n < len; n++) {
9005
9017
  if (animations[n].id === id) {
9006
9018
  this.animations.splice(n, 1);
9007
9019
  break;
@@ -9009,7 +9021,8 @@
9009
9021
  }
9010
9022
  }
9011
9023
  static _runFrames() {
9012
- var layerHash = {}, animations = this.animations, anim, layers, func, n, i, layersLen, layer, key, needRedraw;
9024
+ const layerHash = {};
9025
+ const animations = this.animations;
9013
9026
  /*
9014
9027
  * loop through all animations and execute animation
9015
9028
  * function. if the animation object has specified node,
@@ -9021,13 +9034,14 @@
9021
9034
  * WARNING: don't cache animations.length because it could change while
9022
9035
  * the for loop is running, causing a JS error
9023
9036
  */
9024
- for (n = 0; n < animations.length; n++) {
9025
- anim = animations[n];
9026
- layers = anim.layers;
9027
- func = anim.func;
9037
+ for (let n = 0; n < animations.length; n++) {
9038
+ const anim = animations[n];
9039
+ const layers = anim.layers;
9040
+ const func = anim.func;
9028
9041
  anim._updateFrameObject(now());
9029
- layersLen = layers.length;
9042
+ const layersLen = layers.length;
9030
9043
  // if animation object has a function, execute it
9044
+ let needRedraw;
9031
9045
  if (func) {
9032
9046
  // allow anim bypassing drawing
9033
9047
  needRedraw = func.call(anim, anim.frame) !== false;
@@ -9038,14 +9052,14 @@
9038
9052
  if (!needRedraw) {
9039
9053
  continue;
9040
9054
  }
9041
- for (i = 0; i < layersLen; i++) {
9042
- layer = layers[i];
9055
+ for (let i = 0; i < layersLen; i++) {
9056
+ const layer = layers[i];
9043
9057
  if (layer._id !== undefined) {
9044
9058
  layerHash[layer._id] = layer;
9045
9059
  }
9046
9060
  }
9047
9061
  }
9048
- for (key in layerHash) {
9062
+ for (let key in layerHash) {
9049
9063
  if (!layerHash.hasOwnProperty(key)) {
9050
9064
  continue;
9051
9065
  }
@@ -9053,7 +9067,7 @@
9053
9067
  }
9054
9068
  }
9055
9069
  static _animationLoop() {
9056
- var Anim = Animation;
9070
+ const Anim = Animation;
9057
9071
  if (Anim.animations.length) {
9058
9072
  Anim._runFrames();
9059
9073
  Util.requestAnimFrame(Anim._animationLoop);
@@ -11610,7 +11624,7 @@
11610
11624
  // case for a trailing comma before next command
11611
11625
  break;
11612
11626
  }
11613
- var cmd = null;
11627
+ var cmd = '';
11614
11628
  var points = [];
11615
11629
  var startX = cpx, startY = cpy;
11616
11630
  // Move var from within the switch to up here (jshint)
@@ -14101,7 +14115,8 @@
14101
14115
  // constants
14102
14116
  var AUTO = 'auto',
14103
14117
  //CANVAS = 'canvas',
14104
- CENTER = 'center', 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', WORD = 'word', CHAR = 'char', NONE = 'none', ELLIPSIS = '…', ATTR_CHANGE_LIST$1 = [
14118
+ 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 = [
14119
+ 'direction',
14105
14120
  'fontFamily',
14106
14121
  'fontSize',
14107
14122
  'fontStyle',
@@ -14164,9 +14179,10 @@
14164
14179
  * @memberof Konva
14165
14180
  * @augments Konva.Shape
14166
14181
  * @param {Object} config
14182
+ * @param {String} [config.direction] default is inherit
14167
14183
  * @param {String} [config.fontFamily] default is Arial
14168
14184
  * @param {Number} [config.fontSize] in pixels. Default is 12
14169
- * @param {String} [config.fontStyle] can be 'normal', 'bold', 'italic' or even 'italic bold'. Default is 'normal'
14185
+ * @param {String} [config.fontStyle] can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.
14170
14186
  * @param {String} [config.fontVariant] can be normal or small-caps. Default is normal
14171
14187
  * @param {String} [config.textDecoration] can be line-through, underline or empty string. Default is empty string.
14172
14188
  * @param {String} config.text
@@ -14276,11 +14292,15 @@
14276
14292
  if (!this.text()) {
14277
14293
  return;
14278
14294
  }
14279
- var padding = this.padding(), fontSize = this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, verticalAlign = this.verticalAlign(), 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;
14295
+ 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;
14296
+ direction = direction === INHERIT ? context.direction : direction;
14280
14297
  var translateY = 0;
14281
14298
  var translateY = lineHeightPx / 2;
14282
14299
  var lineTranslateX = 0;
14283
14300
  var lineTranslateY = 0;
14301
+ if (direction === RTL) {
14302
+ context.setAttr('direction', direction);
14303
+ }
14284
14304
  context.setAttr('font', this._getContextFont());
14285
14305
  context.setAttr('textBaseline', MIDDLE);
14286
14306
  context.setAttr('textAlign', LEFT);
@@ -14339,7 +14359,10 @@
14339
14359
  context.stroke();
14340
14360
  context.restore();
14341
14361
  }
14342
- if (letterSpacing !== 0 || align === JUSTIFY) {
14362
+ // As `letterSpacing` isn't supported on Safari, we use this polyfill.
14363
+ // The exception is for RTL text, which we rely on native as it cannot
14364
+ // be supported otherwise.
14365
+ if (direction !== RTL && (letterSpacing !== 0 || align === JUSTIFY)) {
14343
14366
  // var words = text.split(' ');
14344
14367
  spacesNumber = text.split(' ').length - 1;
14345
14368
  var array = stringToArray(text);
@@ -14361,6 +14384,9 @@
14361
14384
  }
14362
14385
  }
14363
14386
  else {
14387
+ if (letterSpacing !== 0) {
14388
+ context.setAttr('letterSpacing', `${letterSpacing}px`);
14389
+ }
14364
14390
  this._partialTextX = lineTranslateX;
14365
14391
  this._partialTextY = translateY + lineTranslateY;
14366
14392
  this._partialText = text;
@@ -14608,6 +14634,15 @@
14608
14634
  getStrokeScaleEnabled() {
14609
14635
  return true;
14610
14636
  }
14637
+ _useBufferCanvas() {
14638
+ const hasLine = this.textDecoration().indexOf('underline') !== -1 ||
14639
+ this.textDecoration().indexOf('line-through') !== -1;
14640
+ const hasShadow = this.hasShadow();
14641
+ if (hasLine && hasShadow) {
14642
+ return true;
14643
+ }
14644
+ return super._useBufferCanvas();
14645
+ }
14611
14646
  }
14612
14647
  Text.prototype._fillFunc = _fillFunc$1;
14613
14648
  Text.prototype._strokeFunc = _strokeFunc$1;
@@ -14657,6 +14692,20 @@
14657
14692
  * text.height() // will return calculated height, and not "auto"
14658
14693
  */
14659
14694
  Factory.overWriteSetter(Text, 'height', getNumberOrAutoValidator());
14695
+ /**
14696
+ * get/set direction
14697
+ * @name Konva.Text#direction
14698
+ * @method
14699
+ * @param {String} direction
14700
+ * @returns {String}
14701
+ * @example
14702
+ * // get direction
14703
+ * var direction = text.direction();
14704
+ *
14705
+ * // set direction
14706
+ * text.direction('rtl');
14707
+ */
14708
+ Factory.addGetterSetter(Text, 'direction', INHERIT);
14660
14709
  /**
14661
14710
  * get/set font family
14662
14711
  * @name Konva.Text#fontFamily
@@ -14686,7 +14735,7 @@
14686
14735
  */
14687
14736
  Factory.addGetterSetter(Text, 'fontSize', 12, getNumberValidator());
14688
14737
  /**
14689
- * get/set font style. Can be 'normal', 'italic', or 'bold' or even 'italic bold'. 'normal' is the default.
14738
+ * get/set font style. Can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.
14690
14739
  * @name Konva.Text#fontStyle
14691
14740
  * @method
14692
14741
  * @param {String} fontStyle
@@ -14862,7 +14911,7 @@
14862
14911
  * @param {Object} config
14863
14912
  * @param {String} [config.fontFamily] default is Arial
14864
14913
  * @param {Number} [config.fontSize] default is 12
14865
- * @param {String} [config.fontStyle] can be normal, bold, or italic. Default is normal
14914
+ * @param {String} [config.fontStyle] Can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.
14866
14915
  * @param {String} [config.fontVariant] can be normal or small-caps. Default is normal
14867
14916
  * @param {String} [config.textBaseline] Can be 'top', 'bottom', 'middle', 'alphabetic', 'hanging'. Default is middle
14868
14917
  * @param {String} config.text
@@ -15251,7 +15300,7 @@
15251
15300
  */
15252
15301
  Factory.addGetterSetter(TextPath, 'fontSize', 12, getNumberValidator());
15253
15302
  /**
15254
- * get/set font style. Can be 'normal', 'italic', or 'bold'. 'normal' is the default.
15303
+ * get/set font style. Can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.
15255
15304
  * @name Konva.TextPath#fontStyle
15256
15305
  * @method
15257
15306
  * @param {String} fontStyle
@@ -15413,9 +15462,9 @@
15413
15462
  'bottom-right': 135,
15414
15463
  };
15415
15464
  const TOUCH_DEVICE = 'ontouchstart' in Konva$2._global;
15416
- function getCursor(anchorName, rad) {
15465
+ function getCursor(anchorName, rad, rotateCursor) {
15417
15466
  if (anchorName === 'rotater') {
15418
- return 'crosshair';
15467
+ return rotateCursor;
15419
15468
  }
15420
15469
  rad += Util.degToRad(ANGLES[anchorName] || 0);
15421
15470
  var angle = ((Util.radToDeg(rad) % 360) + 360) % 360;
@@ -15485,8 +15534,12 @@
15485
15534
  const y = point.y +
15486
15535
  (shape.x - point.x) * Math.sin(angleRad) +
15487
15536
  (shape.y - point.y) * Math.cos(angleRad);
15488
- return Object.assign(Object.assign({}, shape), { rotation: shape.rotation + angleRad, x,
15489
- y });
15537
+ return {
15538
+ ...shape,
15539
+ rotation: shape.rotation + angleRad,
15540
+ x,
15541
+ y,
15542
+ };
15490
15543
  }
15491
15544
  function rotateAroundCenter(shape, deltaRad) {
15492
15545
  const center = getCenter(shape);
@@ -15516,6 +15569,7 @@
15516
15569
  * @param {Array} [config.rotationSnaps] Array of angles for rotation snaps. Default is []
15517
15570
  * @param {Number} [config.rotationSnapTolerance] Snapping tolerance. If closer than this it will snap. Default is 5
15518
15571
  * @param {Number} [config.rotateAnchorOffset] Default is 50
15572
+ * @param {String} [config.rotateAnchorCursor] Default is crosshair
15519
15573
  * @param {Number} [config.padding] Default is 0
15520
15574
  * @param {Boolean} [config.borderEnabled] Should we draw border? Default is true
15521
15575
  * @param {String} [config.borderStroke] Border stroke color
@@ -15547,6 +15601,7 @@
15547
15601
  constructor(config) {
15548
15602
  // call super constructor
15549
15603
  super(config);
15604
+ this._movingAnchorName = null;
15550
15605
  this._transforming = false;
15551
15606
  this._createElements();
15552
15607
  // bindings
@@ -15772,7 +15827,7 @@
15772
15827
  });
15773
15828
  const tr = new Transform();
15774
15829
  tr.rotate(-Konva$2.getAngle(this.rotation()));
15775
- var minX, minY, maxX, maxY;
15830
+ var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
15776
15831
  totalPoints.forEach(function (point) {
15777
15832
  var transformed = tr.point(point);
15778
15833
  if (minX === undefined) {
@@ -15816,9 +15871,9 @@
15816
15871
  }
15817
15872
  _createElements() {
15818
15873
  this._createBack();
15819
- ANCHORS_NAMES.forEach(function (name) {
15874
+ ANCHORS_NAMES.forEach((name) => {
15820
15875
  this._createAnchor(name);
15821
- }.bind(this));
15876
+ });
15822
15877
  this._createAnchor('rotater');
15823
15878
  }
15824
15879
  _createAnchor(name) {
@@ -15847,7 +15902,8 @@
15847
15902
  // add hover styling
15848
15903
  anchor.on('mouseenter', () => {
15849
15904
  var rad = Konva$2.getAngle(this.rotation());
15850
- var cursor = getCursor(name, rad);
15905
+ var rotateCursor = this.rotateAnchorCursor();
15906
+ var cursor = getCursor(name, rad, rotateCursor);
15851
15907
  anchor.getStage().content &&
15852
15908
  (anchor.getStage().content.style.cursor = cursor);
15853
15909
  this._cursorChange = true;
@@ -15865,16 +15921,16 @@
15865
15921
  width: 0,
15866
15922
  height: 0,
15867
15923
  draggable: true,
15868
- sceneFunc(ctx) {
15869
- var tr = this.getParent();
15924
+ sceneFunc(ctx, shape) {
15925
+ var tr = shape.getParent();
15870
15926
  var padding = tr.padding();
15871
15927
  ctx.beginPath();
15872
- ctx.rect(-padding, -padding, this.width() + padding * 2, this.height() + padding * 2);
15873
- ctx.moveTo(this.width() / 2, -padding);
15928
+ ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);
15929
+ ctx.moveTo(shape.width() / 2, -padding);
15874
15930
  if (tr.rotateEnabled()) {
15875
- ctx.lineTo(this.width() / 2, -tr.rotateAnchorOffset() * Util._sign(this.height()) - padding);
15931
+ ctx.lineTo(shape.width() / 2, -tr.rotateAnchorOffset() * Util._sign(shape.height()) - padding);
15876
15932
  }
15877
- ctx.fillStrokeShape(this);
15933
+ ctx.fillStrokeShape(shape);
15878
15934
  },
15879
15935
  hitFunc: (ctx, shape) => {
15880
15936
  if (!this.shouldOverdrawWholeArea()) {
@@ -16564,6 +16620,20 @@
16564
16620
  * transformer.rotateAnchorOffset(100);
16565
16621
  */
16566
16622
  Factory.addGetterSetter(Transformer, 'rotateAnchorOffset', 50, getNumberValidator());
16623
+ /**
16624
+ * get/set rotation anchor cursor
16625
+ * @name Konva.Transformer#rotateAnchorCursor
16626
+ * @method
16627
+ * @param {String} cursorName
16628
+ * @returns {String}
16629
+ * @example
16630
+ * // get
16631
+ * var currentRotationAnchorCursor = transformer.rotateAnchorCursor();
16632
+ *
16633
+ * // set
16634
+ * transformer.rotateAnchorCursor('grab');
16635
+ */
16636
+ Factory.addGetterSetter(Transformer, 'rotateAnchorCursor', 'crosshair');
16567
16637
  /**
16568
16638
  * get/set distance for rotation tolerance
16569
16639
  * @name Konva.Transformer#rotationSnapTolerance
@@ -17102,518 +17172,39 @@
17102
17172
  this.next = null;
17103
17173
  }
17104
17174
  var mul_table = [
17105
- 512,
17106
- 512,
17107
- 456,
17108
- 512,
17109
- 328,
17110
- 456,
17111
- 335,
17112
- 512,
17113
- 405,
17114
- 328,
17115
- 271,
17116
- 456,
17117
- 388,
17118
- 335,
17119
- 292,
17120
- 512,
17121
- 454,
17122
- 405,
17123
- 364,
17124
- 328,
17125
- 298,
17126
- 271,
17127
- 496,
17128
- 456,
17129
- 420,
17130
- 388,
17131
- 360,
17132
- 335,
17133
- 312,
17134
- 292,
17135
- 273,
17136
- 512,
17137
- 482,
17138
- 454,
17139
- 428,
17140
- 405,
17141
- 383,
17142
- 364,
17143
- 345,
17144
- 328,
17145
- 312,
17146
- 298,
17147
- 284,
17148
- 271,
17149
- 259,
17150
- 496,
17151
- 475,
17152
- 456,
17153
- 437,
17154
- 420,
17155
- 404,
17156
- 388,
17157
- 374,
17158
- 360,
17159
- 347,
17160
- 335,
17161
- 323,
17162
- 312,
17163
- 302,
17164
- 292,
17165
- 282,
17166
- 273,
17167
- 265,
17168
- 512,
17169
- 497,
17170
- 482,
17171
- 468,
17172
- 454,
17173
- 441,
17174
- 428,
17175
- 417,
17176
- 405,
17177
- 394,
17178
- 383,
17179
- 373,
17180
- 364,
17181
- 354,
17182
- 345,
17183
- 337,
17184
- 328,
17185
- 320,
17186
- 312,
17187
- 305,
17188
- 298,
17189
- 291,
17190
- 284,
17191
- 278,
17192
- 271,
17193
- 265,
17194
- 259,
17195
- 507,
17196
- 496,
17197
- 485,
17198
- 475,
17199
- 465,
17200
- 456,
17201
- 446,
17202
- 437,
17203
- 428,
17204
- 420,
17205
- 412,
17206
- 404,
17207
- 396,
17208
- 388,
17209
- 381,
17210
- 374,
17211
- 367,
17212
- 360,
17213
- 354,
17214
- 347,
17215
- 341,
17216
- 335,
17217
- 329,
17218
- 323,
17219
- 318,
17220
- 312,
17221
- 307,
17222
- 302,
17223
- 297,
17224
- 292,
17225
- 287,
17226
- 282,
17227
- 278,
17228
- 273,
17229
- 269,
17230
- 265,
17231
- 261,
17232
- 512,
17233
- 505,
17234
- 497,
17235
- 489,
17236
- 482,
17237
- 475,
17238
- 468,
17239
- 461,
17240
- 454,
17241
- 447,
17242
- 441,
17243
- 435,
17244
- 428,
17245
- 422,
17246
- 417,
17247
- 411,
17248
- 405,
17249
- 399,
17250
- 394,
17251
- 389,
17252
- 383,
17253
- 378,
17254
- 373,
17255
- 368,
17256
- 364,
17257
- 359,
17258
- 354,
17259
- 350,
17260
- 345,
17261
- 341,
17262
- 337,
17263
- 332,
17264
- 328,
17265
- 324,
17266
- 320,
17267
- 316,
17268
- 312,
17269
- 309,
17270
- 305,
17271
- 301,
17272
- 298,
17273
- 294,
17274
- 291,
17275
- 287,
17276
- 284,
17277
- 281,
17278
- 278,
17279
- 274,
17280
- 271,
17281
- 268,
17282
- 265,
17283
- 262,
17284
- 259,
17285
- 257,
17286
- 507,
17287
- 501,
17288
- 496,
17289
- 491,
17290
- 485,
17291
- 480,
17292
- 475,
17293
- 470,
17294
- 465,
17295
- 460,
17296
- 456,
17297
- 451,
17298
- 446,
17299
- 442,
17300
- 437,
17301
- 433,
17302
- 428,
17303
- 424,
17304
- 420,
17305
- 416,
17306
- 412,
17307
- 408,
17308
- 404,
17309
- 400,
17310
- 396,
17311
- 392,
17312
- 388,
17313
- 385,
17314
- 381,
17315
- 377,
17316
- 374,
17317
- 370,
17318
- 367,
17319
- 363,
17320
- 360,
17321
- 357,
17322
- 354,
17323
- 350,
17324
- 347,
17325
- 344,
17326
- 341,
17327
- 338,
17328
- 335,
17329
- 332,
17330
- 329,
17331
- 326,
17332
- 323,
17333
- 320,
17334
- 318,
17335
- 315,
17336
- 312,
17337
- 310,
17338
- 307,
17339
- 304,
17340
- 302,
17341
- 299,
17342
- 297,
17343
- 294,
17344
- 292,
17345
- 289,
17346
- 287,
17347
- 285,
17348
- 282,
17349
- 280,
17350
- 278,
17351
- 275,
17352
- 273,
17353
- 271,
17354
- 269,
17355
- 267,
17356
- 265,
17357
- 263,
17358
- 261,
17359
- 259,
17175
+ 512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292,
17176
+ 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292,
17177
+ 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259,
17178
+ 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292,
17179
+ 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373,
17180
+ 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259,
17181
+ 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381,
17182
+ 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292,
17183
+ 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461,
17184
+ 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373,
17185
+ 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309,
17186
+ 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259,
17187
+ 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442,
17188
+ 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381,
17189
+ 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332,
17190
+ 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,
17191
+ 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259,
17360
17192
  ];
17361
17193
  var shg_table = [
17362
- 9,
17363
- 11,
17364
- 12,
17365
- 13,
17366
- 13,
17367
- 14,
17368
- 14,
17369
- 15,
17370
- 15,
17371
- 15,
17372
- 15,
17373
- 16,
17374
- 16,
17375
- 16,
17376
- 16,
17377
- 17,
17378
- 17,
17379
- 17,
17380
- 17,
17381
- 17,
17382
- 17,
17383
- 17,
17384
- 18,
17385
- 18,
17386
- 18,
17387
- 18,
17388
- 18,
17389
- 18,
17390
- 18,
17391
- 18,
17392
- 18,
17393
- 19,
17394
- 19,
17395
- 19,
17396
- 19,
17397
- 19,
17398
- 19,
17399
- 19,
17400
- 19,
17401
- 19,
17402
- 19,
17403
- 19,
17404
- 19,
17405
- 19,
17406
- 19,
17407
- 20,
17408
- 20,
17409
- 20,
17410
- 20,
17411
- 20,
17412
- 20,
17413
- 20,
17414
- 20,
17415
- 20,
17416
- 20,
17417
- 20,
17418
- 20,
17419
- 20,
17420
- 20,
17421
- 20,
17422
- 20,
17423
- 20,
17424
- 20,
17425
- 21,
17426
- 21,
17427
- 21,
17428
- 21,
17429
- 21,
17430
- 21,
17431
- 21,
17432
- 21,
17433
- 21,
17434
- 21,
17435
- 21,
17436
- 21,
17437
- 21,
17438
- 21,
17439
- 21,
17440
- 21,
17441
- 21,
17442
- 21,
17443
- 21,
17444
- 21,
17445
- 21,
17446
- 21,
17447
- 21,
17448
- 21,
17449
- 21,
17450
- 21,
17451
- 21,
17452
- 22,
17453
- 22,
17454
- 22,
17455
- 22,
17456
- 22,
17457
- 22,
17458
- 22,
17459
- 22,
17460
- 22,
17461
- 22,
17462
- 22,
17463
- 22,
17464
- 22,
17465
- 22,
17466
- 22,
17467
- 22,
17468
- 22,
17469
- 22,
17470
- 22,
17471
- 22,
17472
- 22,
17473
- 22,
17474
- 22,
17475
- 22,
17476
- 22,
17477
- 22,
17478
- 22,
17479
- 22,
17480
- 22,
17481
- 22,
17482
- 22,
17483
- 22,
17484
- 22,
17485
- 22,
17486
- 22,
17487
- 22,
17488
- 22,
17489
- 23,
17490
- 23,
17491
- 23,
17492
- 23,
17493
- 23,
17494
- 23,
17495
- 23,
17496
- 23,
17497
- 23,
17498
- 23,
17499
- 23,
17500
- 23,
17501
- 23,
17502
- 23,
17503
- 23,
17504
- 23,
17505
- 23,
17506
- 23,
17507
- 23,
17508
- 23,
17509
- 23,
17510
- 23,
17511
- 23,
17512
- 23,
17513
- 23,
17514
- 23,
17515
- 23,
17516
- 23,
17517
- 23,
17518
- 23,
17519
- 23,
17520
- 23,
17521
- 23,
17522
- 23,
17523
- 23,
17524
- 23,
17525
- 23,
17526
- 23,
17527
- 23,
17528
- 23,
17529
- 23,
17530
- 23,
17531
- 23,
17532
- 23,
17533
- 23,
17534
- 23,
17535
- 23,
17536
- 23,
17537
- 23,
17538
- 23,
17539
- 23,
17540
- 23,
17541
- 23,
17542
- 23,
17543
- 24,
17544
- 24,
17545
- 24,
17546
- 24,
17547
- 24,
17548
- 24,
17549
- 24,
17550
- 24,
17551
- 24,
17552
- 24,
17553
- 24,
17554
- 24,
17555
- 24,
17556
- 24,
17557
- 24,
17558
- 24,
17559
- 24,
17560
- 24,
17561
- 24,
17562
- 24,
17563
- 24,
17564
- 24,
17565
- 24,
17566
- 24,
17567
- 24,
17568
- 24,
17569
- 24,
17570
- 24,
17571
- 24,
17572
- 24,
17573
- 24,
17574
- 24,
17575
- 24,
17576
- 24,
17577
- 24,
17578
- 24,
17579
- 24,
17580
- 24,
17581
- 24,
17582
- 24,
17583
- 24,
17584
- 24,
17585
- 24,
17586
- 24,
17587
- 24,
17588
- 24,
17589
- 24,
17590
- 24,
17591
- 24,
17592
- 24,
17593
- 24,
17594
- 24,
17595
- 24,
17596
- 24,
17597
- 24,
17598
- 24,
17599
- 24,
17600
- 24,
17601
- 24,
17602
- 24,
17603
- 24,
17604
- 24,
17605
- 24,
17606
- 24,
17607
- 24,
17608
- 24,
17609
- 24,
17610
- 24,
17611
- 24,
17612
- 24,
17613
- 24,
17614
- 24,
17615
- 24,
17616
- 24,
17194
+ 9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17,
17195
+ 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
17196
+ 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
17197
+ 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
17198
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
17199
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
17200
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23,
17201
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
17202
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
17203
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
17204
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
17205
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
17206
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
17207
+ 24, 24, 24, 24, 24, 24, 24,
17617
17208
  ];
17618
17209
  function filterGaussBlurRGBA(imageData, radius) {
17619
17210
  var pixels = imageData.data, width = imageData.width, height = imageData.height;
@@ -17628,7 +17219,15 @@
17628
17219
  stack.next = stackStart;
17629
17220
  yw = yi = 0;
17630
17221
  for (y = 0; y < height; y++) {
17631
- r_in_sum = g_in_sum = b_in_sum = a_in_sum = r_sum = g_sum = b_sum = a_sum = 0;
17222
+ r_in_sum =
17223
+ g_in_sum =
17224
+ b_in_sum =
17225
+ a_in_sum =
17226
+ r_sum =
17227
+ g_sum =
17228
+ b_sum =
17229
+ a_sum =
17230
+ 0;
17632
17231
  r_out_sum = radiusPlus1 * (pr = pixels[yi]);
17633
17232
  g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
17634
17233
  b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
@@ -17702,7 +17301,15 @@
17702
17301
  yw += width;
17703
17302
  }
17704
17303
  for (x = 0; x < width; x++) {
17705
- g_in_sum = b_in_sum = a_in_sum = r_in_sum = g_sum = b_sum = a_sum = r_sum = 0;
17304
+ g_in_sum =
17305
+ b_in_sum =
17306
+ a_in_sum =
17307
+ r_in_sum =
17308
+ g_sum =
17309
+ b_sum =
17310
+ a_sum =
17311
+ r_sum =
17312
+ 0;
17706
17313
  yi = x << 2;
17707
17314
  r_out_sum = radiusPlus1 * (pr = pixels[yi]);
17708
17315
  g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);