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.
- package/README.md +1 -1
- package/konva.js +664 -226
- package/konva.min.js +46 -4
- package/lib/Animation.d.ts +2 -2
- package/lib/Animation.js +7 -11
- package/lib/BezierFunctions.js +9 -15
- package/lib/Canvas.d.ts +1 -1
- package/lib/Canvas.js +14 -20
- package/lib/Container.d.ts +7 -6
- package/lib/Container.js +12 -16
- package/lib/Context.d.ts +7 -5
- package/lib/Context.js +34 -14
- package/lib/Core.d.ts +2 -2
- package/lib/Core.js +3 -7
- package/lib/DragAndDrop.d.ts +3 -3
- package/lib/DragAndDrop.js +24 -27
- package/lib/Factory.d.ts +2 -2
- package/lib/Factory.js +24 -27
- package/lib/FastLayer.d.ts +1 -1
- package/lib/FastLayer.js +6 -10
- package/lib/Global.d.ts +4 -3
- package/lib/Global.js +19 -19
- package/lib/Group.d.ts +4 -3
- package/lib/Group.js +6 -10
- package/lib/Layer.d.ts +10 -9
- package/lib/Layer.js +33 -37
- package/lib/Node.d.ts +16 -13
- package/lib/Node.js +207 -123
- package/lib/PointerEvents.d.ts +4 -4
- package/lib/PointerEvents.js +7 -14
- package/lib/Shape.d.ts +7 -4
- package/lib/Shape.js +91 -91
- package/lib/Stage.d.ts +8 -7
- package/lib/Stage.js +66 -56
- package/lib/Tween.d.ts +3 -2
- package/lib/Tween.js +29 -31
- package/lib/Util.d.ts +3 -2
- package/lib/Util.js +98 -38
- package/lib/Validators.js +44 -57
- package/lib/_CoreInternals.d.ts +49 -23
- package/lib/_CoreInternals.js +33 -36
- package/lib/_FullInternals.d.ts +126 -62
- package/lib/_FullInternals.js +77 -78
- package/lib/canvas-backend.d.ts +2 -0
- package/lib/canvas-backend.js +27 -0
- package/lib/filters/Blur.d.ts +1 -1
- package/lib/filters/Blur.js +5 -9
- package/lib/filters/Brighten.d.ts +1 -1
- package/lib/filters/Brighten.js +5 -9
- package/lib/filters/Brightness.d.ts +2 -0
- package/lib/filters/Brightness.js +8 -0
- package/lib/filters/Contrast.d.ts +1 -1
- package/lib/filters/Contrast.js +5 -9
- package/lib/filters/Emboss.d.ts +1 -1
- package/lib/filters/Emboss.js +95 -101
- package/lib/filters/Enhance.d.ts +1 -1
- package/lib/filters/Enhance.js +5 -9
- package/lib/filters/Grayscale.d.ts +1 -1
- package/lib/filters/Grayscale.js +1 -5
- package/lib/filters/HSL.d.ts +1 -1
- package/lib/filters/HSL.js +7 -11
- package/lib/filters/HSV.d.ts +1 -1
- package/lib/filters/HSV.js +7 -11
- package/lib/filters/Invert.d.ts +1 -1
- package/lib/filters/Invert.js +1 -5
- package/lib/filters/Kaleidoscope.d.ts +1 -1
- package/lib/filters/Kaleidoscope.js +9 -13
- package/lib/filters/Mask.d.ts +1 -1
- package/lib/filters/Mask.js +16 -10
- package/lib/filters/Noise.d.ts +1 -1
- package/lib/filters/Noise.js +5 -9
- package/lib/filters/Pixelate.d.ts +1 -1
- package/lib/filters/Pixelate.js +7 -11
- package/lib/filters/Posterize.d.ts +1 -1
- package/lib/filters/Posterize.js +5 -9
- package/lib/filters/RGB.d.ts +1 -1
- package/lib/filters/RGB.js +7 -11
- package/lib/filters/RGBA.d.ts +1 -1
- package/lib/filters/RGBA.js +8 -12
- package/lib/filters/Sepia.d.ts +1 -1
- package/lib/filters/Sepia.js +1 -5
- package/lib/filters/Solarize.d.ts +1 -1
- package/lib/filters/Solarize.js +13 -29
- package/lib/filters/Threshold.d.ts +1 -1
- package/lib/filters/Threshold.js +5 -9
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -4
- package/lib/shapes/Arc.d.ts +4 -3
- package/lib/shapes/Arc.js +13 -17
- package/lib/shapes/Arrow.d.ts +4 -3
- package/lib/shapes/Arrow.js +13 -17
- package/lib/shapes/Circle.d.ts +4 -3
- package/lib/shapes/Circle.js +7 -11
- package/lib/shapes/Ellipse.d.ts +4 -3
- package/lib/shapes/Ellipse.js +9 -13
- package/lib/shapes/Image.d.ts +4 -3
- package/lib/shapes/Image.js +17 -21
- package/lib/shapes/Label.d.ts +7 -6
- package/lib/shapes/Label.js +13 -18
- package/lib/shapes/Line.d.ts +4 -3
- package/lib/shapes/Line.js +10 -14
- package/lib/shapes/Path.d.ts +3 -2
- package/lib/shapes/Path.js +83 -23
- package/lib/shapes/Rect.d.ts +4 -3
- package/lib/shapes/Rect.js +9 -13
- package/lib/shapes/RegularPolygon.d.ts +6 -3
- package/lib/shapes/RegularPolygon.js +19 -16
- package/lib/shapes/Ring.d.ts +4 -3
- package/lib/shapes/Ring.js +8 -12
- package/lib/shapes/Sprite.d.ts +5 -4
- package/lib/shapes/Sprite.js +15 -19
- package/lib/shapes/Star.d.ts +4 -3
- package/lib/shapes/Star.js +9 -13
- package/lib/shapes/Text.d.ts +16 -3
- package/lib/shapes/Text.js +73 -53
- package/lib/shapes/TextPath.d.ts +5 -4
- package/lib/shapes/TextPath.js +48 -41
- package/lib/shapes/Transformer.d.ts +8 -8
- package/lib/shapes/Transformer.js +90 -90
- package/lib/shapes/Wedge.d.ts +4 -3
- package/lib/shapes/Wedge.js +12 -16
- package/lib/skia-backend.d.ts +2 -0
- package/lib/skia-backend.js +24 -0
- package/lib/types.d.ts +22 -22
- package/lib/types.js +21 -25
- package/package.json +53 -25
- package/lib/index-node.d.ts +0 -2
- package/lib/index-node.js +0 -21
- package/lib/index-types.d.ts +0 -181
package/lib/shapes/Path.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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(
|
|
181
|
-
return
|
|
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(
|
|
185
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
|
|
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
|
|
584
|
+
return getCubicArcLength([x, points[0], points[2], points[4]], [y, points[1], points[3], points[5]], 1);
|
|
524
585
|
case 'Q':
|
|
525
|
-
return
|
|
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
|
-
|
|
610
|
-
|
|
669
|
+
_registerNode(Path);
|
|
670
|
+
Factory.addGetterSetter(Path, 'data');
|
package/lib/shapes/Rect.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
}
|
package/lib/shapes/Rect.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26
|
-
|
|
21
|
+
_registerNode(Rect);
|
|
22
|
+
Factory.addGetterSetter(Rect, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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));
|
package/lib/shapes/Ring.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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;
|
package/lib/shapes/Ring.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
_registerNode(Ring);
|
|
32
|
+
Factory.addGetterSetter(Ring, 'innerRadius', 0, getNumberValidator());
|
|
33
|
+
Factory.addGetterSetter(Ring, 'outerRadius', 0, getNumberValidator());
|
package/lib/shapes/Sprite.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Context } from '../Context.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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;
|
package/lib/shapes/Sprite.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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',
|
package/lib/shapes/Star.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Context } from '../Context.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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;
|
package/lib/shapes/Star.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
_registerNode(Star);
|
|
36
|
+
Factory.addGetterSetter(Star, 'numPoints', 5, getNumberValidator());
|
|
37
|
+
Factory.addGetterSetter(Star, 'innerRadius', 0, getNumberValidator());
|
|
38
|
+
Factory.addGetterSetter(Star, 'outerRadius', 0, getNumberValidator());
|
package/lib/shapes/Text.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import { Context } from '../Context.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
}
|