konva 9.3.14 → 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 (68) hide show
  1. package/konva.js +754 -737
  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 +4 -4
  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 +3 -3
  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.d.ts +8 -8
  56. package/lib/shapes/Path.js +68 -68
  57. package/lib/shapes/Rect.js +1 -1
  58. package/lib/shapes/RegularPolygon.js +6 -6
  59. package/lib/shapes/Ring.js +1 -1
  60. package/lib/shapes/Sprite.js +9 -9
  61. package/lib/shapes/Star.js +5 -5
  62. package/lib/shapes/Text.d.ts +13 -13
  63. package/lib/shapes/Text.js +52 -38
  64. package/lib/shapes/TextPath.d.ts +2 -2
  65. package/lib/shapes/TextPath.js +23 -23
  66. package/lib/shapes/Transformer.d.ts +1 -1
  67. package/lib/shapes/Transformer.js +63 -63
  68. package/package.json +2 -5
@@ -6,7 +6,7 @@ const Shape_1 = require("../Shape");
6
6
  const Group_1 = require("../Group");
7
7
  const Validators_1 = require("../Validators");
8
8
  const Global_1 = require("../Global");
9
- var ATTR_CHANGE_LIST = [
9
+ const ATTR_CHANGE_LIST = [
10
10
  'fontFamily',
11
11
  'fontSize',
12
12
  'fontStyle',
@@ -34,8 +34,8 @@ class Label extends Group_1.Group {
34
34
  return this.find('Tag')[0];
35
35
  }
36
36
  _addListeners(text) {
37
- var that = this, n;
38
- var func = function () {
37
+ let that = this, n;
38
+ const func = function () {
39
39
  that._sync();
40
40
  };
41
41
  for (n = 0; n < attrChangeListLen; n++) {
@@ -49,7 +49,7 @@ class Label extends Group_1.Group {
49
49
  return this.getText().height();
50
50
  }
51
51
  _sync() {
52
- var text = this.getText(), tag = this.getTag(), width, height, pointerDirection, pointerWidth, x, y, pointerHeight;
52
+ let text = this.getText(), tag = this.getTag(), width, height, pointerDirection, pointerWidth, x, y, pointerHeight;
53
53
  if (text && tag) {
54
54
  width = text.width();
55
55
  height = text.height();
@@ -94,7 +94,7 @@ Label.prototype.className = 'Label';
94
94
  (0, Global_1._registerNode)(Label);
95
95
  class Tag extends Shape_1.Shape {
96
96
  _sceneFunc(context) {
97
- var width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = this.cornerRadius();
97
+ const width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = this.cornerRadius();
98
98
  let topLeft = 0;
99
99
  let topRight = 0;
100
100
  let bottomLeft = 0;
@@ -146,7 +146,7 @@ class Tag extends Shape_1.Shape {
146
146
  context.fillStrokeShape(this);
147
147
  }
148
148
  getSelfRect() {
149
- var x = 0, y = 0, pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), direction = this.pointerDirection(), width = this.width(), height = this.height();
149
+ let x = 0, y = 0, pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), direction = this.pointerDirection(), width = this.width(), height = this.height();
150
150
  if (direction === UP) {
151
151
  y -= pointerHeight;
152
152
  height += pointerHeight;
@@ -1,6 +1,6 @@
1
1
  import { Shape, ShapeConfig } from '../Shape.js';
2
- import { GetSet } from '../types.js';
3
2
  import { Context } from '../Context.js';
3
+ import { GetSet } from '../types.js';
4
4
  export interface LineConfig extends ShapeConfig {
5
5
  points?: number[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
6
6
  tension?: number;
@@ -2,17 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Line = void 0;
4
4
  const Factory_1 = require("../Factory");
5
+ const Global_1 = require("../Global");
5
6
  const Shape_1 = require("../Shape");
6
7
  const Validators_1 = require("../Validators");
7
- const Global_1 = require("../Global");
8
8
  function getControlPoints(x0, y0, x1, y1, x2, y2, t) {
9
- 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);
9
+ 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);
10
10
  return [p1x, p1y, p2x, p2y];
11
11
  }
12
12
  function expandPoints(p, tension) {
13
- var len = p.length, allPoints = [], n, cp;
14
- for (n = 2; n < len - 2; n += 2) {
15
- cp = getControlPoints(p[n - 2], p[n - 1], p[n], p[n + 1], p[n + 2], p[n + 3], tension);
13
+ const len = p.length, allPoints = [];
14
+ for (let n = 2; n < len - 2; n += 2) {
15
+ const cp = getControlPoints(p[n - 2], p[n - 1], p[n], p[n + 1], p[n + 2], p[n + 3], tension);
16
16
  if (isNaN(cp[0])) {
17
17
  continue;
18
18
  }
@@ -33,7 +33,7 @@ class Line extends Shape_1.Shape {
33
33
  });
34
34
  }
35
35
  _sceneFunc(context) {
36
- var points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier(), tp, len, n;
36
+ let points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier(), tp, len, n;
37
37
  if (!length) {
38
38
  return;
39
39
  }
@@ -84,7 +84,7 @@ class Line extends Shape_1.Shape {
84
84
  }
85
85
  }
86
86
  _getTensionPointsClosed() {
87
- 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]]
87
+ 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]]
88
88
  .concat(middle)
89
89
  .concat([
90
90
  lastControlPoints[0],
@@ -107,7 +107,7 @@ class Line extends Shape_1.Shape {
107
107
  return this.getSelfRect().height;
108
108
  }
109
109
  getSelfRect() {
110
- var points = this.points();
110
+ let points = this.points();
111
111
  if (points.length < 4) {
112
112
  return {
113
113
  x: points[0] || 0,
@@ -128,12 +128,12 @@ class Line extends Shape_1.Shape {
128
128
  else {
129
129
  points = this.points();
130
130
  }
131
- var minX = points[0];
132
- var maxX = points[0];
133
- var minY = points[1];
134
- var maxY = points[1];
135
- var x, y;
136
- for (var i = 0; i < points.length / 2; i++) {
131
+ let minX = points[0];
132
+ let maxX = points[0];
133
+ let minY = points[1];
134
+ let maxY = points[1];
135
+ let x, y;
136
+ for (let i = 0; i < points.length / 2; i++) {
137
137
  x = points[i * 2];
138
138
  y = points[i * 2 + 1];
139
139
  minX = Math.min(minX, x);
@@ -17,19 +17,19 @@ export declare class Path extends Shape<PathConfig> {
17
17
  };
18
18
  getLength(): number;
19
19
  getPointAtLength(length: any): {
20
- x: any;
21
- y: any;
20
+ x: number;
21
+ y: number;
22
22
  } | null;
23
23
  data: GetSet<string, this>;
24
24
  static getLineLength(x1: any, y1: any, x2: any, y2: any): number;
25
25
  static getPathLength(dataArray: PathSegment[]): number;
26
- static getPointAtLengthOfDataArray(length: number, dataArray: any): {
27
- x: any;
28
- y: any;
26
+ static getPointAtLengthOfDataArray(length: number, dataArray: PathSegment[]): {
27
+ x: number;
28
+ y: number;
29
29
  } | null;
30
- static getPointOnLine(dist: any, P1x: any, P1y: any, P2x: any, P2y: any, fromX?: any, fromY?: any): {
31
- x: any;
32
- y: any;
30
+ static getPointOnLine(dist: number, P1x: number, P1y: number, P2x: number, P2y: number, fromX?: number, fromY?: number): {
31
+ x: number;
32
+ y: number;
33
33
  };
34
34
  static getPointOnCubicBezier(pct: any, P1x: any, P1y: any, P2x: any, P2y: any, P3x: any, P3y: any, P4x: any, P4y: any): {
35
35
  x: number;
@@ -20,12 +20,12 @@ class Path extends Shape_1.Shape {
20
20
  this.pathLength = Path.getPathLength(this.dataArray);
21
21
  }
22
22
  _sceneFunc(context) {
23
- var ca = this.dataArray;
23
+ const ca = this.dataArray;
24
24
  context.beginPath();
25
- var isClosed = false;
26
- for (var n = 0; n < ca.length; n++) {
27
- var c = ca[n].command;
28
- var p = ca[n].points;
25
+ let isClosed = false;
26
+ for (let n = 0; n < ca.length; n++) {
27
+ const c = ca[n].command;
28
+ const p = ca[n].points;
29
29
  switch (c) {
30
30
  case 'L':
31
31
  context.lineTo(p[0], p[1]);
@@ -66,13 +66,13 @@ class Path extends Shape_1.Shape {
66
66
  }
67
67
  }
68
68
  getSelfRect() {
69
- var points = [];
69
+ let points = [];
70
70
  this.dataArray.forEach(function (data) {
71
71
  if (data.command === 'A') {
72
- var start = data.points[4];
73
- var dTheta = data.points[5];
74
- var end = data.points[4] + dTheta;
75
- var inc = Math.PI / 180.0;
72
+ const start = data.points[4];
73
+ const dTheta = data.points[5];
74
+ const end = data.points[4] + dTheta;
75
+ let inc = Math.PI / 180.0;
76
76
  if (Math.abs(start - end) < inc) {
77
77
  inc = Math.abs(start - end);
78
78
  }
@@ -99,12 +99,12 @@ class Path extends Shape_1.Shape {
99
99
  points = points.concat(data.points);
100
100
  }
101
101
  });
102
- var minX = points[0];
103
- var maxX = points[0];
104
- var minY = points[1];
105
- var maxY = points[1];
106
- var x, y;
107
- for (var i = 0; i < points.length / 2; i++) {
102
+ let minX = points[0];
103
+ let maxX = points[0];
104
+ let minY = points[1];
105
+ let maxY = points[1];
106
+ let x, y;
107
+ for (let i = 0; i < points.length / 2; i++) {
108
108
  x = points[i * 2];
109
109
  y = points[i * 2 + 1];
110
110
  if (!isNaN(x)) {
@@ -134,13 +134,13 @@ class Path extends Shape_1.Shape {
134
134
  }
135
135
  static getPathLength(dataArray) {
136
136
  let pathLength = 0;
137
- for (var i = 0; i < dataArray.length; ++i) {
137
+ for (let i = 0; i < dataArray.length; ++i) {
138
138
  pathLength += dataArray[i].pathLength;
139
139
  }
140
140
  return pathLength;
141
141
  }
142
142
  static getPointAtLengthOfDataArray(length, dataArray) {
143
- var point, i = 0, ii = dataArray.length;
143
+ let points, i = 0, ii = dataArray.length;
144
144
  if (!ii) {
145
145
  return null;
146
146
  }
@@ -149,21 +149,21 @@ class Path extends Shape_1.Shape {
149
149
  ++i;
150
150
  }
151
151
  if (i === ii) {
152
- point = dataArray[i - 1].points.slice(-2);
152
+ points = dataArray[i - 1].points.slice(-2);
153
153
  return {
154
- x: point[0],
155
- y: point[1],
154
+ x: points[0],
155
+ y: points[1],
156
156
  };
157
157
  }
158
158
  if (length < 0.01) {
159
- point = dataArray[i].points.slice(0, 2);
159
+ points = dataArray[i].points.slice(0, 2);
160
160
  return {
161
- x: point[0],
162
- y: point[1],
161
+ x: points[0],
162
+ y: points[1],
163
163
  };
164
164
  }
165
- var cp = dataArray[i];
166
- var p = cp.points;
165
+ const cp = dataArray[i];
166
+ const p = cp.points;
167
167
  switch (cp.command) {
168
168
  case 'L':
169
169
  return Path.getPointOnLine(length, cp.start.x, cp.start.y, p[0], p[1]);
@@ -220,8 +220,8 @@ class Path extends Shape_1.Shape {
220
220
  function CB4(t) {
221
221
  return (1 - t) * (1 - t) * (1 - t);
222
222
  }
223
- var x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);
224
- var y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);
223
+ const x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);
224
+ const y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);
225
225
  return {
226
226
  x: x,
227
227
  y: y,
@@ -237,16 +237,16 @@ class Path extends Shape_1.Shape {
237
237
  function QB3(t) {
238
238
  return (1 - t) * (1 - t);
239
239
  }
240
- var x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);
241
- var y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);
240
+ const x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);
241
+ const y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);
242
242
  return {
243
243
  x: x,
244
244
  y: y,
245
245
  };
246
246
  }
247
247
  static getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi) {
248
- var cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);
249
- var pt = {
248
+ const cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);
249
+ const pt = {
250
250
  x: rx * Math.cos(theta),
251
251
  y: ry * Math.sin(theta),
252
252
  };
@@ -259,8 +259,8 @@ class Path extends Shape_1.Shape {
259
259
  if (!data) {
260
260
  return [];
261
261
  }
262
- var cs = data;
263
- var cc = [
262
+ let cs = data;
263
+ const cc = [
264
264
  'm',
265
265
  'M',
266
266
  'l',
@@ -286,28 +286,28 @@ class Path extends Shape_1.Shape {
286
286
  for (var n = 0; n < cc.length; n++) {
287
287
  cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
288
288
  }
289
- var arr = cs.split('|');
290
- var ca = [];
291
- var coords = [];
292
- var cpx = 0;
293
- var cpy = 0;
294
- var re = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;
295
- var match;
289
+ const arr = cs.split('|');
290
+ const ca = [];
291
+ const coords = [];
292
+ let cpx = 0;
293
+ let cpy = 0;
294
+ const re = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;
295
+ let match;
296
296
  for (n = 1; n < arr.length; n++) {
297
- var str = arr[n];
298
- var c = str.charAt(0);
297
+ let str = arr[n];
298
+ let c = str.charAt(0);
299
299
  str = str.slice(1);
300
300
  coords.length = 0;
301
301
  while ((match = re.exec(str))) {
302
302
  coords.push(match[0]);
303
303
  }
304
- var p = [];
305
- for (var j = 0, jlen = coords.length; j < jlen; j++) {
304
+ const p = [];
305
+ for (let j = 0, jlen = coords.length; j < jlen; j++) {
306
306
  if (coords[j] === '00') {
307
307
  p.push(0, 0);
308
308
  continue;
309
309
  }
310
- var parsed = parseFloat(coords[j]);
310
+ const parsed = parseFloat(coords[j]);
311
311
  if (!isNaN(parsed)) {
312
312
  p.push(parsed);
313
313
  }
@@ -319,9 +319,9 @@ class Path extends Shape_1.Shape {
319
319
  if (isNaN(p[0])) {
320
320
  break;
321
321
  }
322
- var cmd = '';
323
- var points = [];
324
- var startX = cpx, startY = cpy;
322
+ let cmd = '';
323
+ let points = [];
324
+ const startX = cpx, startY = cpy;
325
325
  var prevCmd, ctlPtx, ctlPty;
326
326
  var rx, ry, psi, fa, fs, x1, y1;
327
327
  switch (c) {
@@ -343,7 +343,7 @@ class Path extends Shape_1.Shape {
343
343
  cpy += dy;
344
344
  cmd = 'M';
345
345
  if (ca.length > 2 && ca[ca.length - 1].command === 'z') {
346
- for (var idx = ca.length - 2; idx >= 0; idx--) {
346
+ for (let idx = ca.length - 2; idx >= 0; idx--) {
347
347
  if (ca[idx].command === 'M') {
348
348
  cpx = ca[idx].points[0] + dx;
349
349
  cpy = ca[idx].points[1] + dy;
@@ -510,8 +510,8 @@ class Path extends Shape_1.Shape {
510
510
  return ca;
511
511
  }
512
512
  static calcLength(x, y, cmd, points) {
513
- var len, p1, p2, t;
514
- var path = Path;
513
+ let len, p1, p2, t;
514
+ const path = Path;
515
515
  switch (cmd) {
516
516
  case 'L':
517
517
  return path.getLineLength(x, y, points[0], points[1]);
@@ -550,16 +550,16 @@ class Path extends Shape_1.Shape {
550
550
  return 0;
551
551
  }
552
552
  static convertEndpointToCenterParameterization(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg) {
553
- var psi = psiDeg * (Math.PI / 180.0);
554
- var xp = (Math.cos(psi) * (x1 - x2)) / 2.0 + (Math.sin(psi) * (y1 - y2)) / 2.0;
555
- var yp = (-1 * Math.sin(psi) * (x1 - x2)) / 2.0 +
553
+ const psi = psiDeg * (Math.PI / 180.0);
554
+ const xp = (Math.cos(psi) * (x1 - x2)) / 2.0 + (Math.sin(psi) * (y1 - y2)) / 2.0;
555
+ const yp = (-1 * Math.sin(psi) * (x1 - x2)) / 2.0 +
556
556
  (Math.cos(psi) * (y1 - y2)) / 2.0;
557
- var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
557
+ const lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
558
558
  if (lambda > 1) {
559
559
  rx *= Math.sqrt(lambda);
560
560
  ry *= Math.sqrt(lambda);
561
561
  }
562
- var f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) /
562
+ let f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) /
563
563
  (rx * rx * (yp * yp) + ry * ry * (xp * xp)));
564
564
  if (fa === fs) {
565
565
  f *= -1;
@@ -567,23 +567,23 @@ class Path extends Shape_1.Shape {
567
567
  if (isNaN(f)) {
568
568
  f = 0;
569
569
  }
570
- var cxp = (f * rx * yp) / ry;
571
- var cyp = (f * -ry * xp) / rx;
572
- var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;
573
- var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;
574
- var vMag = function (v) {
570
+ const cxp = (f * rx * yp) / ry;
571
+ const cyp = (f * -ry * xp) / rx;
572
+ const cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;
573
+ const cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;
574
+ const vMag = function (v) {
575
575
  return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
576
576
  };
577
- var vRatio = function (u, v) {
577
+ const vRatio = function (u, v) {
578
578
  return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
579
579
  };
580
- var vAngle = function (u, v) {
580
+ const vAngle = function (u, v) {
581
581
  return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));
582
582
  };
583
- var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
584
- var u = [(xp - cxp) / rx, (yp - cyp) / ry];
585
- var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
586
- var dTheta = vAngle(u, v);
583
+ const theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
584
+ const u = [(xp - cxp) / rx, (yp - cyp) / ry];
585
+ const v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
586
+ let dTheta = vAngle(u, v);
587
587
  if (vRatio(u, v) <= -1) {
588
588
  dTheta = Math.PI;
589
589
  }
@@ -8,7 +8,7 @@ const Util_1 = require("../Util");
8
8
  const Validators_1 = require("../Validators");
9
9
  class Rect extends Shape_1.Shape {
10
10
  _sceneFunc(context) {
11
- var cornerRadius = this.cornerRadius(), width = this.width(), height = this.height();
11
+ const cornerRadius = this.cornerRadius(), width = this.width(), height = this.height();
12
12
  context.beginPath();
13
13
  if (!cornerRadius) {
14
14
  context.rect(0, 0, width, height);
@@ -10,7 +10,7 @@ class RegularPolygon extends Shape_1.Shape {
10
10
  const points = this._getPoints();
11
11
  context.beginPath();
12
12
  context.moveTo(points[0].x, points[0].y);
13
- for (var n = 1; n < points.length; n++) {
13
+ for (let n = 1; n < points.length; n++) {
14
14
  context.lineTo(points[n].x, points[n].y);
15
15
  }
16
16
  context.closePath();
@@ -20,7 +20,7 @@ class RegularPolygon extends Shape_1.Shape {
20
20
  const sides = this.attrs.sides;
21
21
  const radius = this.attrs.radius || 0;
22
22
  const points = [];
23
- for (var n = 0; n < sides; n++) {
23
+ for (let n = 0; n < sides; n++) {
24
24
  points.push({
25
25
  x: radius * Math.sin((n * 2 * Math.PI) / sides),
26
26
  y: -1 * radius * Math.cos((n * 2 * Math.PI) / sides),
@@ -30,10 +30,10 @@ class RegularPolygon extends Shape_1.Shape {
30
30
  }
31
31
  getSelfRect() {
32
32
  const points = this._getPoints();
33
- var minX = points[0].x;
34
- var maxX = points[0].y;
35
- var minY = points[0].x;
36
- var maxY = points[0].y;
33
+ let minX = points[0].x;
34
+ let maxX = points[0].y;
35
+ let minY = points[0].x;
36
+ let maxY = points[0].y;
37
37
  points.forEach((point) => {
38
38
  minX = Math.min(minX, point.x);
39
39
  maxX = Math.max(maxX, point.x);
@@ -5,7 +5,7 @@ const Factory_1 = require("../Factory");
5
5
  const Shape_1 = require("../Shape");
6
6
  const Validators_1 = require("../Validators");
7
7
  const Global_1 = require("../Global");
8
- var PIx2 = Math.PI * 2;
8
+ const PIx2 = Math.PI * 2;
9
9
  class Ring extends Shape_1.Shape {
10
10
  _sceneFunc(context) {
11
11
  context.beginPath();
@@ -11,7 +11,7 @@ class Sprite extends Shape_1.Shape {
11
11
  super(config);
12
12
  this._updated = true;
13
13
  this.anim = new Animation_1.Animation(() => {
14
- var updated = this._updated;
14
+ const updated = this._updated;
15
15
  this._updated = false;
16
16
  return updated;
17
17
  });
@@ -30,7 +30,7 @@ class Sprite extends Shape_1.Shape {
30
30
  });
31
31
  }
32
32
  _sceneFunc(context) {
33
- 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();
33
+ 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();
34
34
  if (this.hasFill() || this.hasStroke()) {
35
35
  context.beginPath();
36
36
  context.rect(0, 0, width, height);
@@ -39,7 +39,7 @@ class Sprite extends Shape_1.Shape {
39
39
  }
40
40
  if (image) {
41
41
  if (offsets) {
42
- var offset = offsets[anim], ix2 = index * 2;
42
+ const offset = offsets[anim], ix2 = index * 2;
43
43
  context.drawImage(image, x, y, width, height, offset[ix2 + 0], offset[ix2 + 1], width, height);
44
44
  }
45
45
  else {
@@ -48,11 +48,11 @@ class Sprite extends Shape_1.Shape {
48
48
  }
49
49
  }
50
50
  _hitFunc(context) {
51
- 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];
51
+ 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];
52
52
  context.beginPath();
53
53
  if (offsets) {
54
- var offset = offsets[anim];
55
- var ix2 = index * 2;
54
+ const offset = offsets[anim];
55
+ const ix2 = index * 2;
56
56
  context.rect(offset[ix2 + 0], offset[ix2 + 1], width, height);
57
57
  }
58
58
  else {
@@ -65,7 +65,7 @@ class Sprite extends Shape_1.Shape {
65
65
  return super._useBufferCanvas(true);
66
66
  }
67
67
  _setInterval() {
68
- var that = this;
68
+ const that = this;
69
69
  this.interval = setInterval(function () {
70
70
  that._updateIndex();
71
71
  }, 1000 / this.frameRate());
@@ -74,7 +74,7 @@ class Sprite extends Shape_1.Shape {
74
74
  if (this.isRunning()) {
75
75
  return;
76
76
  }
77
- var layer = this.getLayer();
77
+ const layer = this.getLayer();
78
78
  this.anim.setLayers(layer);
79
79
  this._setInterval();
80
80
  this.anim.start();
@@ -87,7 +87,7 @@ class Sprite extends Shape_1.Shape {
87
87
  return this.anim.isRunning();
88
88
  }
89
89
  _updateIndex() {
90
- var index = this.frameIndex(), animation = this.animation(), animations = this.animations(), anim = animations[animation], len = anim.length / 4;
90
+ const index = this.frameIndex(), animation = this.animation(), animations = this.animations(), anim = animations[animation], len = anim.length / 4;
91
91
  if (index < len - 1) {
92
92
  this.frameIndex(index + 1);
93
93
  }
@@ -7,13 +7,13 @@ const Validators_1 = require("../Validators");
7
7
  const Global_1 = require("../Global");
8
8
  class Star extends Shape_1.Shape {
9
9
  _sceneFunc(context) {
10
- var innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();
10
+ const innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();
11
11
  context.beginPath();
12
12
  context.moveTo(0, 0 - outerRadius);
13
- for (var n = 1; n < numPoints * 2; n++) {
14
- var radius = n % 2 === 0 ? outerRadius : innerRadius;
15
- var x = radius * Math.sin((n * Math.PI) / numPoints);
16
- var y = -1 * radius * Math.cos((n * Math.PI) / numPoints);
13
+ for (let n = 1; n < numPoints * 2; n++) {
14
+ const radius = n % 2 === 0 ? outerRadius : innerRadius;
15
+ const x = radius * Math.sin((n * Math.PI) / numPoints);
16
+ const y = -1 * radius * Math.cos((n * Math.PI) / numPoints);
17
17
  context.lineTo(x, y);
18
18
  }
19
19
  context.closePath();
@@ -37,19 +37,19 @@ export declare class Text extends Shape<TextConfig> {
37
37
  getHeight(): any;
38
38
  getTextWidth(): number;
39
39
  getTextHeight(): number;
40
- measureSize(text: any): {
41
- actualBoundingBoxAscent: any;
42
- actualBoundingBoxDescent: any;
43
- actualBoundingBoxLeft: any;
44
- actualBoundingBoxRight: any;
45
- alphabeticBaseline: any;
46
- emHeightAscent: any;
47
- emHeightDescent: any;
48
- fontBoundingBoxAscent: any;
49
- fontBoundingBoxDescent: any;
50
- hangingBaseline: any;
51
- ideographicBaseline: any;
52
- width: any;
40
+ measureSize(text: string): {
41
+ actualBoundingBoxAscent: number;
42
+ actualBoundingBoxDescent: number;
43
+ actualBoundingBoxLeft: number;
44
+ actualBoundingBoxRight: number;
45
+ alphabeticBaseline: number;
46
+ emHeightAscent: number;
47
+ emHeightDescent: number;
48
+ fontBoundingBoxAscent: number;
49
+ fontBoundingBoxDescent: number;
50
+ hangingBaseline: number;
51
+ ideographicBaseline: number;
52
+ width: number;
53
53
  height: number;
54
54
  };
55
55
  _getContextFont(): string;