konva 9.3.21 → 10.0.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +1 -1
  2. package/konva.js +664 -226
  3. package/konva.min.js +46 -4
  4. package/lib/Animation.d.ts +2 -2
  5. package/lib/Animation.js +7 -11
  6. package/lib/BezierFunctions.js +9 -15
  7. package/lib/Canvas.d.ts +1 -1
  8. package/lib/Canvas.js +14 -20
  9. package/lib/Container.d.ts +7 -6
  10. package/lib/Container.js +12 -16
  11. package/lib/Context.d.ts +7 -5
  12. package/lib/Context.js +34 -14
  13. package/lib/Core.d.ts +2 -2
  14. package/lib/Core.js +3 -7
  15. package/lib/DragAndDrop.d.ts +3 -3
  16. package/lib/DragAndDrop.js +24 -27
  17. package/lib/Factory.d.ts +2 -2
  18. package/lib/Factory.js +24 -27
  19. package/lib/FastLayer.d.ts +1 -1
  20. package/lib/FastLayer.js +6 -10
  21. package/lib/Global.d.ts +4 -3
  22. package/lib/Global.js +19 -19
  23. package/lib/Group.d.ts +4 -3
  24. package/lib/Group.js +6 -10
  25. package/lib/Layer.d.ts +10 -9
  26. package/lib/Layer.js +33 -37
  27. package/lib/Node.d.ts +16 -13
  28. package/lib/Node.js +207 -123
  29. package/lib/PointerEvents.d.ts +4 -4
  30. package/lib/PointerEvents.js +7 -14
  31. package/lib/Shape.d.ts +7 -4
  32. package/lib/Shape.js +91 -91
  33. package/lib/Stage.d.ts +8 -7
  34. package/lib/Stage.js +66 -56
  35. package/lib/Tween.d.ts +3 -2
  36. package/lib/Tween.js +29 -31
  37. package/lib/Util.d.ts +3 -2
  38. package/lib/Util.js +98 -38
  39. package/lib/Validators.js +44 -57
  40. package/lib/_CoreInternals.d.ts +49 -23
  41. package/lib/_CoreInternals.js +33 -36
  42. package/lib/_FullInternals.d.ts +126 -62
  43. package/lib/_FullInternals.js +77 -78
  44. package/lib/canvas-backend.d.ts +2 -0
  45. package/lib/canvas-backend.js +27 -0
  46. package/lib/filters/Blur.d.ts +1 -1
  47. package/lib/filters/Blur.js +5 -9
  48. package/lib/filters/Brighten.d.ts +1 -1
  49. package/lib/filters/Brighten.js +5 -9
  50. package/lib/filters/Brightness.d.ts +2 -0
  51. package/lib/filters/Brightness.js +8 -0
  52. package/lib/filters/Contrast.d.ts +1 -1
  53. package/lib/filters/Contrast.js +5 -9
  54. package/lib/filters/Emboss.d.ts +1 -1
  55. package/lib/filters/Emboss.js +95 -101
  56. package/lib/filters/Enhance.d.ts +1 -1
  57. package/lib/filters/Enhance.js +5 -9
  58. package/lib/filters/Grayscale.d.ts +1 -1
  59. package/lib/filters/Grayscale.js +1 -5
  60. package/lib/filters/HSL.d.ts +1 -1
  61. package/lib/filters/HSL.js +7 -11
  62. package/lib/filters/HSV.d.ts +1 -1
  63. package/lib/filters/HSV.js +7 -11
  64. package/lib/filters/Invert.d.ts +1 -1
  65. package/lib/filters/Invert.js +1 -5
  66. package/lib/filters/Kaleidoscope.d.ts +1 -1
  67. package/lib/filters/Kaleidoscope.js +9 -13
  68. package/lib/filters/Mask.d.ts +1 -1
  69. package/lib/filters/Mask.js +16 -10
  70. package/lib/filters/Noise.d.ts +1 -1
  71. package/lib/filters/Noise.js +5 -9
  72. package/lib/filters/Pixelate.d.ts +1 -1
  73. package/lib/filters/Pixelate.js +7 -11
  74. package/lib/filters/Posterize.d.ts +1 -1
  75. package/lib/filters/Posterize.js +5 -9
  76. package/lib/filters/RGB.d.ts +1 -1
  77. package/lib/filters/RGB.js +7 -11
  78. package/lib/filters/RGBA.d.ts +1 -1
  79. package/lib/filters/RGBA.js +8 -12
  80. package/lib/filters/Sepia.d.ts +1 -1
  81. package/lib/filters/Sepia.js +1 -5
  82. package/lib/filters/Solarize.d.ts +1 -1
  83. package/lib/filters/Solarize.js +13 -29
  84. package/lib/filters/Threshold.d.ts +1 -1
  85. package/lib/filters/Threshold.js +5 -9
  86. package/lib/index.d.ts +1 -1
  87. package/lib/index.js +2 -4
  88. package/lib/shapes/Arc.d.ts +4 -3
  89. package/lib/shapes/Arc.js +13 -17
  90. package/lib/shapes/Arrow.d.ts +4 -3
  91. package/lib/shapes/Arrow.js +13 -17
  92. package/lib/shapes/Circle.d.ts +4 -3
  93. package/lib/shapes/Circle.js +7 -11
  94. package/lib/shapes/Ellipse.d.ts +4 -3
  95. package/lib/shapes/Ellipse.js +9 -13
  96. package/lib/shapes/Image.d.ts +4 -3
  97. package/lib/shapes/Image.js +17 -21
  98. package/lib/shapes/Label.d.ts +7 -6
  99. package/lib/shapes/Label.js +13 -18
  100. package/lib/shapes/Line.d.ts +4 -3
  101. package/lib/shapes/Line.js +10 -14
  102. package/lib/shapes/Path.d.ts +3 -2
  103. package/lib/shapes/Path.js +83 -23
  104. package/lib/shapes/Rect.d.ts +4 -3
  105. package/lib/shapes/Rect.js +9 -13
  106. package/lib/shapes/RegularPolygon.d.ts +6 -3
  107. package/lib/shapes/RegularPolygon.js +19 -16
  108. package/lib/shapes/Ring.d.ts +4 -3
  109. package/lib/shapes/Ring.js +8 -12
  110. package/lib/shapes/Sprite.d.ts +5 -4
  111. package/lib/shapes/Sprite.js +15 -19
  112. package/lib/shapes/Star.d.ts +4 -3
  113. package/lib/shapes/Star.js +9 -13
  114. package/lib/shapes/Text.d.ts +16 -3
  115. package/lib/shapes/Text.js +73 -53
  116. package/lib/shapes/TextPath.d.ts +5 -4
  117. package/lib/shapes/TextPath.js +48 -41
  118. package/lib/shapes/Transformer.d.ts +8 -8
  119. package/lib/shapes/Transformer.js +90 -90
  120. package/lib/shapes/Wedge.d.ts +4 -3
  121. package/lib/shapes/Wedge.js +12 -16
  122. package/lib/skia-backend.d.ts +2 -0
  123. package/lib/skia-backend.js +24 -0
  124. package/lib/types.d.ts +22 -22
  125. package/lib/types.js +21 -25
  126. package/package.json +53 -25
  127. package/lib/index-node.d.ts +0 -2
  128. package/lib/index-node.js +0 -21
  129. package/lib/index-types.d.ts +0 -181
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Path = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Global_1 = require("../Global");
6
- const Shape_1 = require("../Shape");
7
- const BezierFunctions_1 = require("../BezierFunctions");
8
- class Path extends Shape_1.Shape {
1
+ import { Factory } from "../Factory.js";
2
+ import { _registerNode } from "../Global.js";
3
+ import { Shape } from "../Shape.js";
4
+ import { getCubicArcLength, getQuadraticArcLength, t2length, } from "../BezierFunctions.js";
5
+ export class Path extends Shape {
9
6
  constructor(config) {
10
7
  super(config);
11
8
  this.dataArray = [];
@@ -177,12 +174,12 @@ class Path extends Shape_1.Shape {
177
174
  case 'L':
178
175
  return Path.getPointOnLine(length, cp.start.x, cp.start.y, p[0], p[1]);
179
176
  case 'C':
180
- return Path.getPointOnCubicBezier((0, BezierFunctions_1.t2length)(length, Path.getPathLength(dataArray), (i) => {
181
- return (0, BezierFunctions_1.getCubicArcLength)([cp.start.x, p[0], p[2], p[4]], [cp.start.y, p[1], p[3], p[5]], i);
177
+ return Path.getPointOnCubicBezier(t2length(length, Path.getPathLength(dataArray), (i) => {
178
+ return getCubicArcLength([cp.start.x, p[0], p[2], p[4]], [cp.start.y, p[1], p[3], p[5]], i);
182
179
  }), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3], p[4], p[5]);
183
180
  case 'Q':
184
- return Path.getPointOnQuadraticBezier((0, BezierFunctions_1.t2length)(length, Path.getPathLength(dataArray), (i) => {
185
- return (0, BezierFunctions_1.getQuadraticArcLength)([cp.start.x, p[0], p[2]], [cp.start.y, p[1], p[3]], i);
181
+ return Path.getPointOnQuadraticBezier(t2length(length, Path.getPathLength(dataArray), (i) => {
182
+ return getQuadraticArcLength([cp.start.x, p[0], p[2]], [cp.start.y, p[1], p[3]], i);
186
183
  }), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3]);
187
184
  case 'A':
188
185
  const cx = p[0], cy = p[1], rx = p[2], ry = p[3], dTheta = p[5], psi = p[6];
@@ -305,18 +302,82 @@ class Path extends Shape_1.Shape {
305
302
  while ((match = re.exec(str))) {
306
303
  coords.push(match[0]);
307
304
  }
308
- const p = [];
305
+ let p = [];
306
+ let arcParamIndex = c === 'A' || c === 'a' ? 0 : -1;
309
307
  for (let j = 0, jlen = coords.length; j < jlen; j++) {
310
- if (coords[j] === '00') {
308
+ const token = coords[j];
309
+ if (token === '00') {
311
310
  p.push(0, 0);
311
+ if (arcParamIndex >= 0) {
312
+ arcParamIndex += 2;
313
+ if (arcParamIndex >= 7)
314
+ arcParamIndex -= 7;
315
+ }
312
316
  continue;
313
317
  }
314
- const parsed = parseFloat(coords[j]);
315
- if (!isNaN(parsed)) {
316
- p.push(parsed);
318
+ if (arcParamIndex >= 0) {
319
+ if (arcParamIndex === 3) {
320
+ if (/^[01]{2}\d+(?:\.\d+)?$/.test(token)) {
321
+ p.push(parseInt(token[0], 10));
322
+ p.push(parseInt(token[1], 10));
323
+ p.push(parseFloat(token.slice(2)));
324
+ arcParamIndex += 3;
325
+ if (arcParamIndex >= 7)
326
+ arcParamIndex -= 7;
327
+ continue;
328
+ }
329
+ if (token === '11' || token === '10' || token === '01') {
330
+ p.push(parseInt(token[0], 10));
331
+ p.push(parseInt(token[1], 10));
332
+ arcParamIndex += 2;
333
+ if (arcParamIndex >= 7)
334
+ arcParamIndex -= 7;
335
+ continue;
336
+ }
337
+ if (token === '0' || token === '1') {
338
+ p.push(parseInt(token, 10));
339
+ arcParamIndex += 1;
340
+ if (arcParamIndex >= 7)
341
+ arcParamIndex -= 7;
342
+ continue;
343
+ }
344
+ }
345
+ else if (arcParamIndex === 4) {
346
+ if (/^[01]\d+(?:\.\d+)?$/.test(token)) {
347
+ p.push(parseInt(token[0], 10));
348
+ p.push(parseFloat(token.slice(1)));
349
+ arcParamIndex += 2;
350
+ if (arcParamIndex >= 7)
351
+ arcParamIndex -= 7;
352
+ continue;
353
+ }
354
+ if (token === '0' || token === '1') {
355
+ p.push(parseInt(token, 10));
356
+ arcParamIndex += 1;
357
+ if (arcParamIndex >= 7)
358
+ arcParamIndex -= 7;
359
+ continue;
360
+ }
361
+ }
362
+ const parsedArc = parseFloat(token);
363
+ if (!isNaN(parsedArc)) {
364
+ p.push(parsedArc);
365
+ }
366
+ else {
367
+ p.push(0);
368
+ }
369
+ arcParamIndex += 1;
370
+ if (arcParamIndex >= 7)
371
+ arcParamIndex -= 7;
317
372
  }
318
373
  else {
319
- p.push(0);
374
+ const parsed = parseFloat(token);
375
+ if (!isNaN(parsed)) {
376
+ p.push(parsed);
377
+ }
378
+ else {
379
+ p.push(0);
380
+ }
320
381
  }
321
382
  }
322
383
  while (p.length > 0) {
@@ -520,9 +581,9 @@ class Path extends Shape_1.Shape {
520
581
  case 'L':
521
582
  return path.getLineLength(x, y, points[0], points[1]);
522
583
  case 'C':
523
- return (0, BezierFunctions_1.getCubicArcLength)([x, points[0], points[2], points[4]], [y, points[1], points[3], points[5]], 1);
584
+ return getCubicArcLength([x, points[0], points[2], points[4]], [y, points[1], points[3], points[5]], 1);
524
585
  case 'Q':
525
- return (0, BezierFunctions_1.getQuadraticArcLength)([x, points[0], points[2]], [y, points[1], points[3]], 1);
586
+ return getQuadraticArcLength([x, points[0], points[2]], [y, points[1], points[3]], 1);
526
587
  case 'A':
527
588
  len = 0.0;
528
589
  const start = points[4];
@@ -603,8 +664,7 @@ class Path extends Shape_1.Shape {
603
664
  return [cx, cy, rx, ry, theta, dTheta, psi, fs];
604
665
  }
605
666
  }
606
- exports.Path = Path;
607
667
  Path.prototype.className = 'Path';
608
668
  Path.prototype._attrsAffectingSize = ['data'];
609
- (0, Global_1._registerNode)(Path);
610
- Factory_1.Factory.addGetterSetter(Path, 'data');
669
+ _registerNode(Path);
670
+ Factory.addGetterSetter(Path, 'data');
@@ -1,6 +1,7 @@
1
- import { Shape, ShapeConfig } from '../Shape.js';
2
- import { GetSet } from '../types.js';
3
- import { Context } from '../Context.js';
1
+ import type { ShapeConfig } from '../Shape.ts';
2
+ import { Shape } from '../Shape.ts';
3
+ import type { GetSet } from '../types.ts';
4
+ import type { Context } from '../Context.ts';
4
5
  export interface RectConfig extends ShapeConfig {
5
6
  cornerRadius?: number | number[];
6
7
  }
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Rect = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Shape_1 = require("../Shape");
6
- const Global_1 = require("../Global");
7
- const Util_1 = require("../Util");
8
- const Validators_1 = require("../Validators");
9
- class Rect extends Shape_1.Shape {
1
+ import { Factory } from "../Factory.js";
2
+ import { Shape } from "../Shape.js";
3
+ import { _registerNode } from "../Global.js";
4
+ import { Util } from "../Util.js";
5
+ import { getNumberOrArrayOfNumbersValidator } from "../Validators.js";
6
+ export class Rect extends Shape {
10
7
  _sceneFunc(context) {
11
8
  const cornerRadius = this.cornerRadius(), width = this.width(), height = this.height();
12
9
  context.beginPath();
@@ -14,13 +11,12 @@ class Rect extends Shape_1.Shape {
14
11
  context.rect(0, 0, width, height);
15
12
  }
16
13
  else {
17
- Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius);
14
+ Util.drawRoundedRectPath(context, width, height, cornerRadius);
18
15
  }
19
16
  context.closePath();
20
17
  context.fillStrokeShape(this);
21
18
  }
22
19
  }
23
- exports.Rect = Rect;
24
20
  Rect.prototype.className = 'Rect';
25
- (0, Global_1._registerNode)(Rect);
26
- Factory_1.Factory.addGetterSetter(Rect, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));
21
+ _registerNode(Rect);
22
+ Factory.addGetterSetter(Rect, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
@@ -1,9 +1,11 @@
1
- import { Shape, ShapeConfig } from '../Shape.js';
2
- import { GetSet, Vector2d } from '../types.js';
3
- import { Context } from '../Context.js';
1
+ import type { ShapeConfig } from '../Shape.ts';
2
+ import { Shape } from '../Shape.ts';
3
+ import type { GetSet, Vector2d } from '../types.ts';
4
+ import type { Context } from '../Context.ts';
4
5
  export interface RegularPolygonConfig extends ShapeConfig {
5
6
  sides: number;
6
7
  radius: number;
8
+ cornerRadius?: number | number[];
7
9
  }
8
10
  export declare class RegularPolygon extends Shape<RegularPolygonConfig> {
9
11
  _sceneFunc(context: Context): void;
@@ -20,4 +22,5 @@ export declare class RegularPolygon extends Shape<RegularPolygonConfig> {
20
22
  setHeight(height: number): void;
21
23
  radius: GetSet<number, this>;
22
24
  sides: GetSet<number, this>;
25
+ cornerRadius: GetSet<number | number[], this>;
23
26
  }
@@ -1,17 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RegularPolygon = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Shape_1 = require("../Shape");
6
- const Validators_1 = require("../Validators");
7
- const Global_1 = require("../Global");
8
- class RegularPolygon extends Shape_1.Shape {
1
+ import { Factory } from "../Factory.js";
2
+ import { Shape } from "../Shape.js";
3
+ import { getNumberOrArrayOfNumbersValidator, getNumberValidator, } from "../Validators.js";
4
+ import { _registerNode } from "../Global.js";
5
+ import { Util } from "../Util.js";
6
+ export class RegularPolygon extends Shape {
9
7
  _sceneFunc(context) {
10
- const points = this._getPoints();
8
+ const points = this._getPoints(), radius = this.radius(), sides = this.sides(), cornerRadius = this.cornerRadius();
11
9
  context.beginPath();
12
- context.moveTo(points[0].x, points[0].y);
13
- for (let n = 1; n < points.length; n++) {
14
- context.lineTo(points[n].x, points[n].y);
10
+ if (!cornerRadius) {
11
+ context.moveTo(points[0].x, points[0].y);
12
+ for (let n = 1; n < points.length; n++) {
13
+ context.lineTo(points[n].x, points[n].y);
14
+ }
15
+ }
16
+ else {
17
+ Util.drawRoundedPolygonPath(context, points, sides, radius, cornerRadius);
15
18
  }
16
19
  context.closePath();
17
20
  context.fillStrokeShape(this);
@@ -60,10 +63,10 @@ class RegularPolygon extends Shape_1.Shape {
60
63
  this.radius(height / 2);
61
64
  }
62
65
  }
63
- exports.RegularPolygon = RegularPolygon;
64
66
  RegularPolygon.prototype.className = 'RegularPolygon';
65
67
  RegularPolygon.prototype._centroid = true;
66
68
  RegularPolygon.prototype._attrsAffectingSize = ['radius'];
67
- (0, Global_1._registerNode)(RegularPolygon);
68
- Factory_1.Factory.addGetterSetter(RegularPolygon, 'radius', 0, (0, Validators_1.getNumberValidator)());
69
- Factory_1.Factory.addGetterSetter(RegularPolygon, 'sides', 0, (0, Validators_1.getNumberValidator)());
69
+ _registerNode(RegularPolygon);
70
+ Factory.addGetterSetter(RegularPolygon, 'radius', 0, getNumberValidator());
71
+ Factory.addGetterSetter(RegularPolygon, 'sides', 0, getNumberValidator());
72
+ Factory.addGetterSetter(RegularPolygon, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
@@ -1,6 +1,7 @@
1
- import { Shape, ShapeConfig } from '../Shape.js';
2
- import { GetSet } from '../types.js';
3
- import { Context } from '../Context.js';
1
+ import type { ShapeConfig } from '../Shape.ts';
2
+ import { Shape } from '../Shape.ts';
3
+ import type { GetSet } from '../types.ts';
4
+ import type { Context } from '../Context.ts';
4
5
  export interface RingConfig extends ShapeConfig {
5
6
  innerRadius: number;
6
7
  outerRadius: number;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Ring = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Shape_1 = require("../Shape");
6
- const Validators_1 = require("../Validators");
7
- const Global_1 = require("../Global");
1
+ import { Factory } from "../Factory.js";
2
+ import { Shape } from "../Shape.js";
3
+ import { getNumberValidator } from "../Validators.js";
4
+ import { _registerNode } from "../Global.js";
8
5
  const PIx2 = Math.PI * 2;
9
- class Ring extends Shape_1.Shape {
6
+ export class Ring extends Shape {
10
7
  _sceneFunc(context) {
11
8
  context.beginPath();
12
9
  context.arc(0, 0, this.innerRadius(), 0, PIx2, false);
@@ -28,10 +25,9 @@ class Ring extends Shape_1.Shape {
28
25
  this.outerRadius(height / 2);
29
26
  }
30
27
  }
31
- exports.Ring = Ring;
32
28
  Ring.prototype.className = 'Ring';
33
29
  Ring.prototype._centroid = true;
34
30
  Ring.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
35
- (0, Global_1._registerNode)(Ring);
36
- Factory_1.Factory.addGetterSetter(Ring, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
37
- Factory_1.Factory.addGetterSetter(Ring, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
31
+ _registerNode(Ring);
32
+ Factory.addGetterSetter(Ring, 'innerRadius', 0, getNumberValidator());
33
+ Factory.addGetterSetter(Ring, 'outerRadius', 0, getNumberValidator());
@@ -1,7 +1,8 @@
1
- import { Context } from '../Context.js';
2
- import { Shape, ShapeConfig } from '../Shape.js';
3
- import { Animation } from '../Animation.js';
4
- import { GetSet } from '../types.js';
1
+ import type { Context } from '../Context.ts';
2
+ import type { ShapeConfig } from '../Shape.ts';
3
+ import { Shape } from '../Shape.ts';
4
+ import { Animation } from '../Animation.ts';
5
+ import type { GetSet } from '../types.ts';
5
6
  export interface SpriteConfig extends ShapeConfig {
6
7
  animation: string;
7
8
  animations: any;
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Sprite = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Shape_1 = require("../Shape");
6
- const Animation_1 = require("../Animation");
7
- const Validators_1 = require("../Validators");
8
- const Global_1 = require("../Global");
9
- class Sprite extends Shape_1.Shape {
1
+ import { Factory } from "../Factory.js";
2
+ import { Shape } from "../Shape.js";
3
+ import { Animation } from "../Animation.js";
4
+ import { getNumberValidator } from "../Validators.js";
5
+ import { _registerNode } from "../Global.js";
6
+ export class Sprite extends Shape {
10
7
  constructor(config) {
11
8
  super(config);
12
9
  this._updated = true;
13
- this.anim = new Animation_1.Animation(() => {
10
+ this.anim = new Animation(() => {
14
11
  const updated = this._updated;
15
12
  this._updated = false;
16
13
  return updated;
@@ -96,16 +93,15 @@ class Sprite extends Shape_1.Shape {
96
93
  }
97
94
  }
98
95
  }
99
- exports.Sprite = Sprite;
100
96
  Sprite.prototype.className = 'Sprite';
101
- (0, Global_1._registerNode)(Sprite);
102
- Factory_1.Factory.addGetterSetter(Sprite, 'animation');
103
- Factory_1.Factory.addGetterSetter(Sprite, 'animations');
104
- Factory_1.Factory.addGetterSetter(Sprite, 'frameOffsets');
105
- Factory_1.Factory.addGetterSetter(Sprite, 'image');
106
- Factory_1.Factory.addGetterSetter(Sprite, 'frameIndex', 0, (0, Validators_1.getNumberValidator)());
107
- Factory_1.Factory.addGetterSetter(Sprite, 'frameRate', 17, (0, Validators_1.getNumberValidator)());
108
- Factory_1.Factory.backCompat(Sprite, {
97
+ _registerNode(Sprite);
98
+ Factory.addGetterSetter(Sprite, 'animation');
99
+ Factory.addGetterSetter(Sprite, 'animations');
100
+ Factory.addGetterSetter(Sprite, 'frameOffsets');
101
+ Factory.addGetterSetter(Sprite, 'image');
102
+ Factory.addGetterSetter(Sprite, 'frameIndex', 0, getNumberValidator());
103
+ Factory.addGetterSetter(Sprite, 'frameRate', 17, getNumberValidator());
104
+ Factory.backCompat(Sprite, {
109
105
  index: 'frameIndex',
110
106
  getIndex: 'getFrameIndex',
111
107
  setIndex: 'setFrameIndex',
@@ -1,6 +1,7 @@
1
- import { Context } from '../Context.js';
2
- import { Shape, ShapeConfig } from '../Shape.js';
3
- import { GetSet } from '../types.js';
1
+ import type { Context } from '../Context.ts';
2
+ import type { ShapeConfig } from '../Shape.ts';
3
+ import { Shape } from '../Shape.ts';
4
+ import type { GetSet } from '../types.ts';
4
5
  export interface StarConfig extends ShapeConfig {
5
6
  numPoints: number;
6
7
  innerRadius: number;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Star = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Shape_1 = require("../Shape");
6
- const Validators_1 = require("../Validators");
7
- const Global_1 = require("../Global");
8
- class Star extends Shape_1.Shape {
1
+ import { Factory } from "../Factory.js";
2
+ import { Shape } from "../Shape.js";
3
+ import { getNumberValidator } from "../Validators.js";
4
+ import { _registerNode } from "../Global.js";
5
+ export class Star extends Shape {
9
6
  _sceneFunc(context) {
10
7
  const innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();
11
8
  context.beginPath();
@@ -32,11 +29,10 @@ class Star extends Shape_1.Shape {
32
29
  this.outerRadius(height / 2);
33
30
  }
34
31
  }
35
- exports.Star = Star;
36
32
  Star.prototype.className = 'Star';
37
33
  Star.prototype._centroid = true;
38
34
  Star.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
39
- (0, Global_1._registerNode)(Star);
40
- Factory_1.Factory.addGetterSetter(Star, 'numPoints', 5, (0, Validators_1.getNumberValidator)());
41
- Factory_1.Factory.addGetterSetter(Star, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
42
- Factory_1.Factory.addGetterSetter(Star, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
35
+ _registerNode(Star);
36
+ Factory.addGetterSetter(Star, 'numPoints', 5, getNumberValidator());
37
+ Factory.addGetterSetter(Star, 'innerRadius', 0, getNumberValidator());
38
+ Factory.addGetterSetter(Star, 'outerRadius', 0, getNumberValidator());
@@ -1,6 +1,18 @@
1
- import { Context } from '../Context.js';
2
- import { Shape, ShapeConfig } from '../Shape.js';
3
- import { GetSet } from '../types.js';
1
+ import type { Context } from '../Context.ts';
2
+ import type { ShapeConfig } from '../Shape.ts';
3
+ import { Shape } from '../Shape.ts';
4
+ import type { GetSet } from '../types.ts';
5
+ export interface CharRenderProps {
6
+ char: string;
7
+ index: number;
8
+ x: number;
9
+ y: number;
10
+ lineIndex: number;
11
+ column: number;
12
+ isLastInLine: boolean;
13
+ width: number;
14
+ context: Context;
15
+ }
4
16
  export declare function stringToArray(string: string): string[];
5
17
  export interface TextConfig extends ShapeConfig {
6
18
  direction?: string;
@@ -74,4 +86,5 @@ export declare class Text extends Shape<TextConfig> {
74
86
  text: GetSet<string, this>;
75
87
  wrap: GetSet<string, this>;
76
88
  ellipsis: GetSet<boolean, this>;
89
+ charRenderFunc: GetSet<null | ((props: CharRenderProps) => void), this>;
77
90
  }