konva 8.4.2 → 9.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 -9
- package/konva.js +17669 -16968
- package/konva.min.js +3 -3
- package/lib/Animation.d.ts +2 -2
- package/lib/Animation.js +11 -7
- package/lib/BezierFunctions.d.ts +6 -0
- package/lib/BezierFunctions.js +791 -0
- package/lib/Canvas.d.ts +2 -1
- package/lib/Canvas.js +26 -18
- package/lib/Container.d.ts +4 -4
- package/lib/Container.js +16 -12
- package/lib/Context.d.ts +16 -13
- package/lib/Context.js +27 -19
- package/lib/Core.d.ts +2 -2
- package/lib/Core.js +7 -3
- package/lib/DragAndDrop.d.ts +3 -3
- package/lib/DragAndDrop.js +25 -22
- package/lib/Factory.js +27 -24
- package/lib/FastLayer.d.ts +1 -1
- package/lib/FastLayer.js +10 -6
- package/lib/Global.js +16 -12
- package/lib/Group.d.ts +3 -3
- package/lib/Group.js +10 -6
- package/lib/Layer.d.ts +9 -9
- package/lib/Layer.js +37 -33
- package/lib/Node.d.ts +8 -8
- package/lib/Node.js +95 -90
- package/lib/PointerEvents.d.ts +4 -4
- package/lib/PointerEvents.js +15 -7
- package/lib/Shape.d.ts +6 -4
- package/lib/Shape.js +90 -86
- package/lib/Stage.d.ts +7 -7
- package/lib/Stage.js +51 -47
- package/lib/Tween.d.ts +2 -2
- package/lib/Tween.js +26 -22
- package/lib/Util.d.ts +2 -2
- package/lib/Util.js +29 -25
- package/lib/Validators.js +58 -44
- package/lib/_CoreInternals.d.ts +29 -29
- package/lib/_CoreInternals.js +36 -33
- package/lib/_FullInternals.d.ts +67 -67
- package/lib/_FullInternals.js +78 -75
- package/lib/filters/Blur.d.ts +1 -1
- package/lib/filters/Blur.js +9 -5
- package/lib/filters/Brighten.d.ts +1 -1
- package/lib/filters/Brighten.js +9 -5
- package/lib/filters/Contrast.d.ts +1 -1
- package/lib/filters/Contrast.js +9 -5
- package/lib/filters/Emboss.d.ts +1 -1
- package/lib/filters/Emboss.js +14 -10
- package/lib/filters/Enhance.d.ts +1 -1
- package/lib/filters/Enhance.js +9 -5
- package/lib/filters/Grayscale.d.ts +1 -1
- package/lib/filters/Grayscale.js +5 -1
- package/lib/filters/HSL.d.ts +1 -1
- package/lib/filters/HSL.js +11 -7
- package/lib/filters/HSV.d.ts +1 -1
- package/lib/filters/HSV.js +11 -7
- package/lib/filters/Invert.d.ts +1 -1
- package/lib/filters/Invert.js +5 -1
- package/lib/filters/Kaleidoscope.d.ts +1 -1
- package/lib/filters/Kaleidoscope.js +13 -9
- package/lib/filters/Mask.d.ts +1 -1
- package/lib/filters/Mask.js +9 -5
- package/lib/filters/Noise.d.ts +1 -1
- package/lib/filters/Noise.js +9 -5
- package/lib/filters/Pixelate.d.ts +1 -1
- package/lib/filters/Pixelate.js +11 -7
- package/lib/filters/Posterize.d.ts +1 -1
- package/lib/filters/Posterize.js +9 -5
- package/lib/filters/RGB.d.ts +1 -1
- package/lib/filters/RGB.js +11 -7
- package/lib/filters/RGBA.d.ts +1 -1
- package/lib/filters/RGBA.js +12 -8
- package/lib/filters/Sepia.d.ts +1 -1
- package/lib/filters/Sepia.js +5 -1
- package/lib/filters/Solarize.d.ts +1 -1
- package/lib/filters/Solarize.js +5 -1
- package/lib/filters/Threshold.d.ts +1 -1
- package/lib/filters/Threshold.js +9 -5
- package/lib/index-node.d.ts +1 -1
- package/lib/index-node.js +7 -5
- package/lib/index-types.d.ts +124 -124
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -2
- package/lib/shapes/Arc.d.ts +6 -5
- package/lib/shapes/Arc.js +17 -13
- package/lib/shapes/Arrow.d.ts +5 -4
- package/lib/shapes/Arrow.js +17 -13
- package/lib/shapes/Circle.d.ts +6 -5
- package/lib/shapes/Circle.js +11 -7
- package/lib/shapes/Ellipse.d.ts +6 -5
- package/lib/shapes/Ellipse.js +13 -9
- package/lib/shapes/Image.d.ts +5 -5
- package/lib/shapes/Image.js +21 -17
- package/lib/shapes/Label.d.ts +8 -7
- package/lib/shapes/Label.js +18 -13
- package/lib/shapes/Line.d.ts +3 -3
- package/lib/shapes/Line.js +14 -10
- package/lib/shapes/Path.d.ts +6 -3
- package/lib/shapes/Path.js +44 -43
- package/lib/shapes/Rect.d.ts +3 -3
- package/lib/shapes/Rect.js +13 -9
- package/lib/shapes/RegularPolygon.d.ts +6 -5
- package/lib/shapes/RegularPolygon.js +12 -8
- package/lib/shapes/Ring.d.ts +6 -5
- package/lib/shapes/Ring.js +12 -8
- package/lib/shapes/Sprite.d.ts +7 -6
- package/lib/shapes/Sprite.js +19 -15
- package/lib/shapes/Star.d.ts +6 -5
- package/lib/shapes/Star.js +13 -9
- package/lib/shapes/Text.d.ts +8 -7
- package/lib/shapes/Text.js +31 -26
- package/lib/shapes/TextPath.d.ts +12 -7
- package/lib/shapes/TextPath.js +82 -188
- package/lib/shapes/Transformer.d.ts +10 -10
- package/lib/shapes/Transformer.js +92 -81
- package/lib/shapes/Wedge.d.ts +6 -5
- package/lib/shapes/Wedge.js +16 -12
- package/lib/types.d.ts +6 -0
- package/lib/types.js +5 -2
- package/package.json +13 -42
- package/cmj/Animation.d.ts +0 -24
- package/cmj/Animation.js +0 -145
- package/cmj/Canvas.d.ts +0 -32
- package/cmj/Canvas.js +0 -114
- package/cmj/Container.d.ts +0 -47
- package/cmj/Container.js +0 -325
- package/cmj/Context.d.ts +0 -84
- package/cmj/Context.js +0 -538
- package/cmj/Core.d.ts +0 -3
- package/cmj/Core.js +0 -7
- package/cmj/DragAndDrop.d.ts +0 -17
- package/cmj/DragAndDrop.js +0 -111
- package/cmj/Factory.d.ts +0 -11
- package/cmj/Factory.js +0 -125
- package/cmj/FastLayer.d.ts +0 -4
- package/cmj/FastLayer.js +0 -16
- package/cmj/Global.d.ts +0 -34
- package/cmj/Global.js +0 -61
- package/cmj/Group.d.ts +0 -8
- package/cmj/Group.js +0 -17
- package/cmj/Layer.d.ts +0 -61
- package/cmj/Layer.js +0 -309
- package/cmj/Node.d.ts +0 -328
- package/cmj/Node.js +0 -1420
- package/cmj/PointerEvents.d.ts +0 -11
- package/cmj/PointerEvents.js +0 -45
- package/cmj/Shape.d.ts +0 -184
- package/cmj/Shape.js +0 -521
- package/cmj/Stage.d.ts +0 -85
- package/cmj/Stage.js +0 -692
- package/cmj/Tween.d.ts +0 -86
- package/cmj/Tween.js +0 -520
- package/cmj/Util.d.ts +0 -91
- package/cmj/Util.js +0 -801
- package/cmj/Validators.d.ts +0 -11
- package/cmj/Validators.js +0 -192
- package/cmj/_CoreInternals.d.ts +0 -152
- package/cmj/_CoreInternals.js +0 -37
- package/cmj/_FullInternals.d.ts +0 -196
- package/cmj/_FullInternals.js +0 -81
- package/cmj/filters/Blur.d.ts +0 -2
- package/cmj/filters/Blur.js +0 -701
- package/cmj/filters/Brighten.d.ts +0 -2
- package/cmj/filters/Brighten.js +0 -16
- package/cmj/filters/Contrast.d.ts +0 -2
- package/cmj/filters/Contrast.js +0 -38
- package/cmj/filters/Emboss.d.ts +0 -2
- package/cmj/filters/Emboss.js +0 -106
- package/cmj/filters/Enhance.d.ts +0 -2
- package/cmj/filters/Enhance.js +0 -87
- package/cmj/filters/Grayscale.d.ts +0 -2
- package/cmj/filters/Grayscale.js +0 -13
- package/cmj/filters/HSL.d.ts +0 -2
- package/cmj/filters/HSL.js +0 -28
- package/cmj/filters/HSV.d.ts +0 -2
- package/cmj/filters/HSV.js +0 -28
- package/cmj/filters/Invert.d.ts +0 -2
- package/cmj/filters/Invert.js +0 -12
- package/cmj/filters/Kaleidoscope.d.ts +0 -2
- package/cmj/filters/Kaleidoscope.js +0 -137
- package/cmj/filters/Mask.d.ts +0 -2
- package/cmj/filters/Mask.js +0 -144
- package/cmj/filters/Noise.d.ts +0 -2
- package/cmj/filters/Noise.js +0 -16
- package/cmj/filters/Pixelate.d.ts +0 -2
- package/cmj/filters/Pixelate.js +0 -64
- package/cmj/filters/Posterize.d.ts +0 -2
- package/cmj/filters/Posterize.js +0 -14
- package/cmj/filters/RGB.d.ts +0 -2
- package/cmj/filters/RGB.js +0 -43
- package/cmj/filters/RGBA.d.ts +0 -2
- package/cmj/filters/RGBA.js +0 -53
- package/cmj/filters/Sepia.d.ts +0 -2
- package/cmj/filters/Sepia.js +0 -15
- package/cmj/filters/Solarize.d.ts +0 -2
- package/cmj/filters/Solarize.js +0 -29
- package/cmj/filters/Threshold.d.ts +0 -2
- package/cmj/filters/Threshold.js +0 -14
- package/cmj/index-node.d.ts +0 -2
- package/cmj/index-node.js +0 -21
- package/cmj/index-types.d.ts +0 -181
- package/cmj/index.d.ts +0 -2
- package/cmj/index.js +0 -4
- package/cmj/package.json +0 -6
- package/cmj/shapes/Arc.d.ts +0 -25
- package/cmj/shapes/Arc.js +0 -59
- package/cmj/shapes/Arrow.d.ts +0 -25
- package/cmj/shapes/Arrow.js +0 -103
- package/cmj/shapes/Circle.d.ts +0 -13
- package/cmj/shapes/Circle.js +0 -37
- package/cmj/shapes/Ellipse.d.ts +0 -16
- package/cmj/shapes/Ellipse.js +0 -41
- package/cmj/shapes/Image.d.ts +0 -25
- package/cmj/shapes/Image.js +0 -117
- package/cmj/shapes/Label.d.ts +0 -35
- package/cmj/shapes/Label.js +0 -178
- package/cmj/shapes/Line.d.ts +0 -28
- package/cmj/shapes/Line.js +0 -159
- package/cmj/shapes/Path.d.ts +0 -37
- package/cmj/shapes/Path.js +0 -631
- package/cmj/shapes/Rect.d.ts +0 -10
- package/cmj/shapes/Rect.js +0 -26
- package/cmj/shapes/RegularPolygon.d.ts +0 -22
- package/cmj/shapes/RegularPolygon.js +0 -69
- package/cmj/shapes/Ring.d.ts +0 -15
- package/cmj/shapes/Ring.js +0 -37
- package/cmj/shapes/Sprite.d.ts +0 -30
- package/cmj/shapes/Sprite.js +0 -112
- package/cmj/shapes/Star.d.ts +0 -17
- package/cmj/shapes/Star.js +0 -42
- package/cmj/shapes/Text.d.ts +0 -62
- package/cmj/shapes/Text.js +0 -373
- package/cmj/shapes/TextPath.d.ts +0 -55
- package/cmj/shapes/TextPath.js +0 -351
- package/cmj/shapes/Transformer.d.ts +0 -116
- package/cmj/shapes/Transformer.js +0 -964
- package/cmj/shapes/Wedge.d.ts +0 -17
- package/cmj/shapes/Wedge.js +0 -42
- package/cmj/types.d.ts +0 -50
- package/cmj/types.js +0 -25
package/lib/shapes/Label.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { Group } from '../Group';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { Shape, ShapeConfig } from '../Shape.js';
|
|
2
|
+
import { Group } from '../Group.js';
|
|
3
|
+
import { Context } from '../Context.js';
|
|
4
|
+
import { ContainerConfig } from '../Container.js';
|
|
5
|
+
import { GetSet } from '../types.js';
|
|
6
|
+
import { Text } from './Text.js';
|
|
6
7
|
export interface LabelConfig extends ContainerConfig {
|
|
7
8
|
}
|
|
8
9
|
export declare class Label extends Group {
|
|
9
|
-
constructor(config?:
|
|
10
|
+
constructor(config?: LabelConfig);
|
|
10
11
|
getText(): Text;
|
|
11
12
|
getTag(): Tag;
|
|
12
13
|
_addListeners(text: any): void;
|
|
@@ -21,7 +22,7 @@ export interface TagConfig extends ShapeConfig {
|
|
|
21
22
|
cornerRadius?: number | Array<number>;
|
|
22
23
|
}
|
|
23
24
|
export declare class Tag extends Shape<TagConfig> {
|
|
24
|
-
_sceneFunc(context:
|
|
25
|
+
_sceneFunc(context: Context): void;
|
|
25
26
|
getSelfRect(): {
|
|
26
27
|
x: number;
|
|
27
28
|
y: number;
|
package/lib/shapes/Label.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tag = exports.Label = void 0;
|
|
4
|
+
const Factory_1 = require("../Factory");
|
|
5
|
+
const Shape_1 = require("../Shape");
|
|
6
|
+
const Group_1 = require("../Group");
|
|
7
|
+
const Validators_1 = require("../Validators");
|
|
8
|
+
const Global_1 = require("../Global");
|
|
6
9
|
var ATTR_CHANGE_LIST = [
|
|
7
10
|
'fontFamily',
|
|
8
11
|
'fontSize',
|
|
@@ -16,7 +19,7 @@ var ATTR_CHANGE_LIST = [
|
|
|
16
19
|
'pointerWidth',
|
|
17
20
|
'pointerHeight',
|
|
18
21
|
], CHANGE_KONVA = 'Change.konva', NONE = 'none', UP = 'up', RIGHT = 'right', DOWN = 'down', LEFT = 'left', attrChangeListLen = ATTR_CHANGE_LIST.length;
|
|
19
|
-
|
|
22
|
+
class Label extends Group_1.Group {
|
|
20
23
|
constructor(config) {
|
|
21
24
|
super(config);
|
|
22
25
|
this.on('add.konva', function (evt) {
|
|
@@ -86,9 +89,10 @@ export class Label extends Group {
|
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
}
|
|
92
|
+
exports.Label = Label;
|
|
89
93
|
Label.prototype.className = 'Label';
|
|
90
|
-
_registerNode(Label);
|
|
91
|
-
|
|
94
|
+
(0, Global_1._registerNode)(Label);
|
|
95
|
+
class Tag extends Shape_1.Shape {
|
|
92
96
|
_sceneFunc(context) {
|
|
93
97
|
var width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = this.cornerRadius();
|
|
94
98
|
let topLeft = 0;
|
|
@@ -165,9 +169,10 @@ export class Tag extends Shape {
|
|
|
165
169
|
};
|
|
166
170
|
}
|
|
167
171
|
}
|
|
172
|
+
exports.Tag = Tag;
|
|
168
173
|
Tag.prototype.className = 'Tag';
|
|
169
|
-
_registerNode(Tag);
|
|
170
|
-
Factory.addGetterSetter(Tag, 'pointerDirection', NONE);
|
|
171
|
-
Factory.addGetterSetter(Tag, 'pointerWidth', 0, getNumberValidator());
|
|
172
|
-
Factory.addGetterSetter(Tag, 'pointerHeight', 0, getNumberValidator());
|
|
173
|
-
Factory.addGetterSetter(Tag, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
|
|
174
|
+
(0, Global_1._registerNode)(Tag);
|
|
175
|
+
Factory_1.Factory.addGetterSetter(Tag, 'pointerDirection', NONE);
|
|
176
|
+
Factory_1.Factory.addGetterSetter(Tag, 'pointerWidth', 0, (0, Validators_1.getNumberValidator)());
|
|
177
|
+
Factory_1.Factory.addGetterSetter(Tag, 'pointerHeight', 0, (0, Validators_1.getNumberValidator)());
|
|
178
|
+
Factory_1.Factory.addGetterSetter(Tag, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));
|
package/lib/shapes/Line.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { GetSet } from '../types';
|
|
3
|
-
import { Context } from '../Context';
|
|
1
|
+
import { Shape, ShapeConfig } from '../Shape.js';
|
|
2
|
+
import { GetSet } from '../types.js';
|
|
3
|
+
import { Context } from '../Context.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;
|
package/lib/shapes/Line.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Line = 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");
|
|
5
8
|
function getControlPoints(x0, y0, x1, y1, x2, y2, t) {
|
|
6
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);
|
|
7
10
|
return [p1x, p1y, p2x, p2y];
|
|
@@ -22,7 +25,7 @@ function expandPoints(p, tension) {
|
|
|
22
25
|
}
|
|
23
26
|
return allPoints;
|
|
24
27
|
}
|
|
25
|
-
|
|
28
|
+
class Line extends Shape_1.Shape {
|
|
26
29
|
constructor(config) {
|
|
27
30
|
super(config);
|
|
28
31
|
this.on('pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva', function () {
|
|
@@ -146,10 +149,11 @@ export class Line extends Shape {
|
|
|
146
149
|
};
|
|
147
150
|
}
|
|
148
151
|
}
|
|
152
|
+
exports.Line = Line;
|
|
149
153
|
Line.prototype.className = 'Line';
|
|
150
154
|
Line.prototype._attrsAffectingSize = ['points', 'bezier', 'tension'];
|
|
151
|
-
_registerNode(Line);
|
|
152
|
-
Factory.addGetterSetter(Line, 'closed', false);
|
|
153
|
-
Factory.addGetterSetter(Line, 'bezier', false);
|
|
154
|
-
Factory.addGetterSetter(Line, 'tension', 0, getNumberValidator());
|
|
155
|
-
Factory.addGetterSetter(Line, 'points', [], getNumberArrayValidator());
|
|
155
|
+
(0, Global_1._registerNode)(Line);
|
|
156
|
+
Factory_1.Factory.addGetterSetter(Line, 'closed', false);
|
|
157
|
+
Factory_1.Factory.addGetterSetter(Line, 'bezier', false);
|
|
158
|
+
Factory_1.Factory.addGetterSetter(Line, 'tension', 0, (0, Validators_1.getNumberValidator)());
|
|
159
|
+
Factory_1.Factory.addGetterSetter(Line, 'points', [], (0, Validators_1.getNumberArrayValidator)());
|
package/lib/shapes/Path.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { GetSet } from '../types';
|
|
1
|
+
import { Shape, ShapeConfig } from '../Shape.js';
|
|
2
|
+
import { GetSet, PathSegment } from '../types.js';
|
|
3
3
|
export interface PathConfig extends ShapeConfig {
|
|
4
4
|
data?: string;
|
|
5
5
|
}
|
|
@@ -7,6 +7,7 @@ export declare class Path extends Shape<PathConfig> {
|
|
|
7
7
|
dataArray: any[];
|
|
8
8
|
pathLength: number;
|
|
9
9
|
constructor(config?: PathConfig);
|
|
10
|
+
_readDataAttribute(): void;
|
|
10
11
|
_sceneFunc(context: any): void;
|
|
11
12
|
getSelfRect(): {
|
|
12
13
|
x: any;
|
|
@@ -18,6 +19,8 @@ export declare class Path extends Shape<PathConfig> {
|
|
|
18
19
|
getPointAtLength(length: any): any;
|
|
19
20
|
data: GetSet<string, this>;
|
|
20
21
|
static getLineLength(x1: any, y1: any, x2: any, y2: any): number;
|
|
22
|
+
static getPathLength(dataArray: PathSegment[]): number;
|
|
23
|
+
static getPointAtLengthOfDataArray(length: number, dataArray: any): any;
|
|
21
24
|
static getPointOnLine(dist: any, P1x: any, P1y: any, P2x: any, P2y: any, fromX?: any, fromY?: any): any;
|
|
22
25
|
static getPointOnCubicBezier(pct: any, P1x: any, P1y: any, P2x: any, P2y: any, P3x: any, P3y: any, P4x: any, P4y: any): {
|
|
23
26
|
x: number;
|
|
@@ -31,7 +34,7 @@ export declare class Path extends Shape<PathConfig> {
|
|
|
31
34
|
x: any;
|
|
32
35
|
y: any;
|
|
33
36
|
};
|
|
34
|
-
static parsePathData(data: any):
|
|
37
|
+
static parsePathData(data: any): PathSegment[];
|
|
35
38
|
static calcLength(x: any, y: any, cmd: any, points: any): any;
|
|
36
39
|
static convertEndpointToCenterParameterization(x1: any, y1: any, x2: any, y2: any, fa: any, fs: any, rx: any, ry: any, psiDeg: any): any[];
|
|
37
40
|
}
|
package/lib/shapes/Path.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Path = void 0;
|
|
4
|
+
const Factory_1 = require("../Factory");
|
|
5
|
+
const Shape_1 = require("../Shape");
|
|
6
|
+
const Global_1 = require("../Global");
|
|
7
|
+
const BezierFunctions_1 = require("../BezierFunctions");
|
|
8
|
+
class Path extends Shape_1.Shape {
|
|
5
9
|
constructor(config) {
|
|
6
10
|
super(config);
|
|
7
11
|
this.dataArray = [];
|
|
8
12
|
this.pathLength = 0;
|
|
9
|
-
this.
|
|
10
|
-
this.pathLength = 0;
|
|
11
|
-
for (var i = 0; i < this.dataArray.length; ++i) {
|
|
12
|
-
this.pathLength += this.dataArray[i].pathLength;
|
|
13
|
-
}
|
|
13
|
+
this._readDataAttribute();
|
|
14
14
|
this.on('dataChange.konva', function () {
|
|
15
|
-
this.
|
|
16
|
-
this.pathLength = 0;
|
|
17
|
-
for (var i = 0; i < this.dataArray.length; ++i) {
|
|
18
|
-
this.pathLength += this.dataArray[i].pathLength;
|
|
19
|
-
}
|
|
15
|
+
this._readDataAttribute();
|
|
20
16
|
});
|
|
21
17
|
}
|
|
18
|
+
_readDataAttribute() {
|
|
19
|
+
this.dataArray = Path.parsePathData(this.data());
|
|
20
|
+
this.pathLength = Path.getPathLength(this.dataArray);
|
|
21
|
+
}
|
|
22
22
|
_sceneFunc(context) {
|
|
23
23
|
var ca = this.dataArray;
|
|
24
24
|
context.beginPath();
|
|
@@ -127,37 +127,54 @@ export class Path extends Shape {
|
|
|
127
127
|
return this.pathLength;
|
|
128
128
|
}
|
|
129
129
|
getPointAtLength(length) {
|
|
130
|
-
|
|
130
|
+
return Path.getPointAtLengthOfDataArray(length, this.dataArray);
|
|
131
|
+
}
|
|
132
|
+
static getLineLength(x1, y1, x2, y2) {
|
|
133
|
+
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
|
134
|
+
}
|
|
135
|
+
static getPathLength(dataArray) {
|
|
136
|
+
let pathLength = 0;
|
|
137
|
+
for (var i = 0; i < dataArray.length; ++i) {
|
|
138
|
+
pathLength += dataArray[i].pathLength;
|
|
139
|
+
}
|
|
140
|
+
return pathLength;
|
|
141
|
+
}
|
|
142
|
+
static getPointAtLengthOfDataArray(length, dataArray) {
|
|
143
|
+
var point, i = 0, ii = dataArray.length;
|
|
131
144
|
if (!ii) {
|
|
132
145
|
return null;
|
|
133
146
|
}
|
|
134
|
-
while (i < ii && length >
|
|
135
|
-
length -=
|
|
147
|
+
while (i < ii && length > dataArray[i].pathLength) {
|
|
148
|
+
length -= dataArray[i].pathLength;
|
|
136
149
|
++i;
|
|
137
150
|
}
|
|
138
151
|
if (i === ii) {
|
|
139
|
-
point =
|
|
152
|
+
point = dataArray[i - 1].points.slice(-2);
|
|
140
153
|
return {
|
|
141
154
|
x: point[0],
|
|
142
155
|
y: point[1],
|
|
143
156
|
};
|
|
144
157
|
}
|
|
145
158
|
if (length < 0.01) {
|
|
146
|
-
point =
|
|
159
|
+
point = dataArray[i].points.slice(0, 2);
|
|
147
160
|
return {
|
|
148
161
|
x: point[0],
|
|
149
162
|
y: point[1],
|
|
150
163
|
};
|
|
151
164
|
}
|
|
152
|
-
var cp =
|
|
165
|
+
var cp = dataArray[i];
|
|
153
166
|
var p = cp.points;
|
|
154
167
|
switch (cp.command) {
|
|
155
168
|
case 'L':
|
|
156
169
|
return Path.getPointOnLine(length, cp.start.x, cp.start.y, p[0], p[1]);
|
|
157
170
|
case 'C':
|
|
158
|
-
return Path.getPointOnCubicBezier(
|
|
171
|
+
return Path.getPointOnCubicBezier((0, BezierFunctions_1.t2length)(length, Path.getPathLength(dataArray), (i) => {
|
|
172
|
+
return (0, BezierFunctions_1.getCubicArcLength)([cp.start.x, p[0], p[2], p[4]], [cp.start.y, p[1], p[3], p[5]], i);
|
|
173
|
+
}), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3], p[4], p[5]);
|
|
159
174
|
case 'Q':
|
|
160
|
-
return Path.getPointOnQuadraticBezier(
|
|
175
|
+
return Path.getPointOnQuadraticBezier((0, BezierFunctions_1.t2length)(length, Path.getPathLength(dataArray), (i) => {
|
|
176
|
+
return (0, BezierFunctions_1.getQuadraticArcLength)([cp.start.x, p[0], p[2]], [cp.start.y, p[1], p[3]], i);
|
|
177
|
+
}), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3]);
|
|
161
178
|
case 'A':
|
|
162
179
|
var cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6];
|
|
163
180
|
theta += (dTheta * length) / cp.pathLength;
|
|
@@ -165,9 +182,6 @@ export class Path extends Shape {
|
|
|
165
182
|
}
|
|
166
183
|
return null;
|
|
167
184
|
}
|
|
168
|
-
static getLineLength(x1, y1, x2, y2) {
|
|
169
|
-
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
|
170
|
-
}
|
|
171
185
|
static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX, fromY) {
|
|
172
186
|
if (fromX === undefined) {
|
|
173
187
|
fromX = P1x;
|
|
@@ -524,23 +538,9 @@ export class Path extends Shape {
|
|
|
524
538
|
case 'L':
|
|
525
539
|
return path.getLineLength(x, y, points[0], points[1]);
|
|
526
540
|
case 'C':
|
|
527
|
-
|
|
528
|
-
p1 = path.getPointOnCubicBezier(0, x, y, points[0], points[1], points[2], points[3], points[4], points[5]);
|
|
529
|
-
for (t = 0.01; t <= 1; t += 0.01) {
|
|
530
|
-
p2 = path.getPointOnCubicBezier(t, x, y, points[0], points[1], points[2], points[3], points[4], points[5]);
|
|
531
|
-
len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);
|
|
532
|
-
p1 = p2;
|
|
533
|
-
}
|
|
534
|
-
return len;
|
|
541
|
+
return (0, BezierFunctions_1.getCubicArcLength)([x, points[0], points[2], points[4]], [y, points[1], points[3], points[5]], 1);
|
|
535
542
|
case 'Q':
|
|
536
|
-
|
|
537
|
-
p1 = path.getPointOnQuadraticBezier(0, x, y, points[0], points[1], points[2], points[3]);
|
|
538
|
-
for (t = 0.01; t <= 1; t += 0.01) {
|
|
539
|
-
p2 = path.getPointOnQuadraticBezier(t, x, y, points[0], points[1], points[2], points[3]);
|
|
540
|
-
len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);
|
|
541
|
-
p1 = p2;
|
|
542
|
-
}
|
|
543
|
-
return len;
|
|
543
|
+
return (0, BezierFunctions_1.getQuadraticArcLength)([x, points[0], points[2]], [y, points[1], points[3]], 1);
|
|
544
544
|
case 'A':
|
|
545
545
|
len = 0.0;
|
|
546
546
|
var start = points[4];
|
|
@@ -621,7 +621,8 @@ export class Path extends Shape {
|
|
|
621
621
|
return [cx, cy, rx, ry, theta, dTheta, psi, fs];
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
|
+
exports.Path = Path;
|
|
624
625
|
Path.prototype.className = 'Path';
|
|
625
626
|
Path.prototype._attrsAffectingSize = ['data'];
|
|
626
|
-
_registerNode(Path);
|
|
627
|
-
Factory.addGetterSetter(Path, 'data');
|
|
627
|
+
(0, Global_1._registerNode)(Path);
|
|
628
|
+
Factory_1.Factory.addGetterSetter(Path, 'data');
|
package/lib/shapes/Rect.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { GetSet } from '../types';
|
|
3
|
-
import { Context } from '../Context';
|
|
1
|
+
import { Shape, ShapeConfig } from '../Shape.js';
|
|
2
|
+
import { GetSet } from '../types.js';
|
|
3
|
+
import { Context } from '../Context.js';
|
|
4
4
|
export interface RectConfig extends ShapeConfig {
|
|
5
5
|
cornerRadius?: number | number[];
|
|
6
6
|
}
|
package/lib/shapes/Rect.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
7
10
|
_sceneFunc(context) {
|
|
8
11
|
var cornerRadius = this.cornerRadius(), width = this.width(), height = this.height();
|
|
9
12
|
context.beginPath();
|
|
@@ -11,12 +14,13 @@ export class Rect extends Shape {
|
|
|
11
14
|
context.rect(0, 0, width, height);
|
|
12
15
|
}
|
|
13
16
|
else {
|
|
14
|
-
Util.drawRoundedRectPath(context, width, height, cornerRadius);
|
|
17
|
+
Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius);
|
|
15
18
|
}
|
|
16
19
|
context.closePath();
|
|
17
20
|
context.fillStrokeShape(this);
|
|
18
21
|
}
|
|
19
22
|
}
|
|
23
|
+
exports.Rect = Rect;
|
|
20
24
|
Rect.prototype.className = 'Rect';
|
|
21
|
-
_registerNode(Rect);
|
|
22
|
-
Factory.addGetterSetter(Rect, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
|
|
25
|
+
(0, Global_1._registerNode)(Rect);
|
|
26
|
+
Factory_1.Factory.addGetterSetter(Rect, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { GetSet } from '../types';
|
|
1
|
+
import { Shape, ShapeConfig } from '../Shape.js';
|
|
2
|
+
import { GetSet } from '../types.js';
|
|
3
|
+
import { Context } from '../Context.js';
|
|
3
4
|
export interface RegularPolygonConfig extends ShapeConfig {
|
|
4
5
|
sides: number;
|
|
5
6
|
radius: number;
|
|
6
7
|
}
|
|
7
8
|
export declare class RegularPolygon extends Shape<RegularPolygonConfig> {
|
|
8
|
-
_sceneFunc(context:
|
|
9
|
+
_sceneFunc(context: Context): void;
|
|
9
10
|
_getPoints(): any[];
|
|
10
11
|
getSelfRect(): {
|
|
11
12
|
x: any;
|
|
@@ -15,8 +16,8 @@ export declare class RegularPolygon extends Shape<RegularPolygonConfig> {
|
|
|
15
16
|
};
|
|
16
17
|
getWidth(): number;
|
|
17
18
|
getHeight(): number;
|
|
18
|
-
setWidth(width:
|
|
19
|
-
setHeight(height:
|
|
19
|
+
setWidth(width: number): void;
|
|
20
|
+
setHeight(height: number): void;
|
|
20
21
|
radius: GetSet<number, this>;
|
|
21
22
|
sides: GetSet<number, this>;
|
|
22
23
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 {
|
|
6
9
|
_sceneFunc(context) {
|
|
7
10
|
const points = this._getPoints();
|
|
8
11
|
context.beginPath();
|
|
@@ -57,9 +60,10 @@ export class RegularPolygon extends Shape {
|
|
|
57
60
|
this.radius(height / 2);
|
|
58
61
|
}
|
|
59
62
|
}
|
|
63
|
+
exports.RegularPolygon = RegularPolygon;
|
|
60
64
|
RegularPolygon.prototype.className = 'RegularPolygon';
|
|
61
65
|
RegularPolygon.prototype._centroid = true;
|
|
62
66
|
RegularPolygon.prototype._attrsAffectingSize = ['radius'];
|
|
63
|
-
_registerNode(RegularPolygon);
|
|
64
|
-
Factory.addGetterSetter(RegularPolygon, 'radius', 0, getNumberValidator());
|
|
65
|
-
Factory.addGetterSetter(RegularPolygon, 'sides', 0, getNumberValidator());
|
|
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)());
|
package/lib/shapes/Ring.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { GetSet } from '../types';
|
|
1
|
+
import { Shape, ShapeConfig } from '../Shape.js';
|
|
2
|
+
import { GetSet } from '../types.js';
|
|
3
|
+
import { Context } from '../Context.js';
|
|
3
4
|
export interface RingConfig extends ShapeConfig {
|
|
4
5
|
innerRadius: number;
|
|
5
6
|
outerRadius: number;
|
|
6
7
|
}
|
|
7
8
|
export declare class Ring extends Shape<RingConfig> {
|
|
8
|
-
_sceneFunc(context:
|
|
9
|
+
_sceneFunc(context: Context): void;
|
|
9
10
|
getWidth(): number;
|
|
10
11
|
getHeight(): number;
|
|
11
|
-
setWidth(width:
|
|
12
|
-
setHeight(height:
|
|
12
|
+
setWidth(width: number): void;
|
|
13
|
+
setHeight(height: number): void;
|
|
13
14
|
outerRadius: GetSet<number, this>;
|
|
14
15
|
innerRadius: GetSet<number, this>;
|
|
15
16
|
}
|
package/lib/shapes/Ring.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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");
|
|
5
8
|
var PIx2 = Math.PI * 2;
|
|
6
|
-
|
|
9
|
+
class Ring extends Shape_1.Shape {
|
|
7
10
|
_sceneFunc(context) {
|
|
8
11
|
context.beginPath();
|
|
9
12
|
context.arc(0, 0, this.innerRadius(), 0, PIx2, false);
|
|
@@ -25,9 +28,10 @@ export class Ring extends Shape {
|
|
|
25
28
|
this.outerRadius(height / 2);
|
|
26
29
|
}
|
|
27
30
|
}
|
|
31
|
+
exports.Ring = Ring;
|
|
28
32
|
Ring.prototype.className = 'Ring';
|
|
29
33
|
Ring.prototype._centroid = true;
|
|
30
34
|
Ring.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
|
31
|
-
_registerNode(Ring);
|
|
32
|
-
Factory.addGetterSetter(Ring, 'innerRadius', 0, getNumberValidator());
|
|
33
|
-
Factory.addGetterSetter(Ring, 'outerRadius', 0, getNumberValidator());
|
|
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)());
|
package/lib/shapes/Sprite.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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';
|
|
4
5
|
export interface SpriteConfig extends ShapeConfig {
|
|
5
6
|
animation: string;
|
|
6
7
|
animations: any;
|
|
@@ -12,9 +13,9 @@ export declare class Sprite extends Shape<SpriteConfig> {
|
|
|
12
13
|
_updated: boolean;
|
|
13
14
|
anim: Animation;
|
|
14
15
|
interval: any;
|
|
15
|
-
constructor(config:
|
|
16
|
-
_sceneFunc(context:
|
|
17
|
-
_hitFunc(context:
|
|
16
|
+
constructor(config: SpriteConfig);
|
|
17
|
+
_sceneFunc(context: Context): void;
|
|
18
|
+
_hitFunc(context: Context): void;
|
|
18
19
|
_useBufferCanvas(): boolean;
|
|
19
20
|
_setInterval(): void;
|
|
20
21
|
start(): void;
|
package/lib/shapes/Sprite.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
7
10
|
constructor(config) {
|
|
8
11
|
super(config);
|
|
9
12
|
this._updated = true;
|
|
10
|
-
this.anim = new Animation(() => {
|
|
13
|
+
this.anim = new Animation_1.Animation(() => {
|
|
11
14
|
var updated = this._updated;
|
|
12
15
|
this._updated = false;
|
|
13
16
|
return updated;
|
|
@@ -93,15 +96,16 @@ export class Sprite extends Shape {
|
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
}
|
|
99
|
+
exports.Sprite = Sprite;
|
|
96
100
|
Sprite.prototype.className = '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, {
|
|
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, {
|
|
105
109
|
index: 'frameIndex',
|
|
106
110
|
getIndex: 'getFrameIndex',
|
|
107
111
|
setIndex: 'setFrameIndex',
|
package/lib/shapes/Star.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Context } from '../Context.js';
|
|
2
|
+
import { Shape, ShapeConfig } from '../Shape.js';
|
|
3
|
+
import { GetSet } from '../types.js';
|
|
3
4
|
export interface StarConfig extends ShapeConfig {
|
|
4
5
|
numPoints: number;
|
|
5
6
|
innerRadius: number;
|
|
6
7
|
outerRadius: number;
|
|
7
8
|
}
|
|
8
9
|
export declare class Star extends Shape<StarConfig> {
|
|
9
|
-
_sceneFunc(context:
|
|
10
|
+
_sceneFunc(context: Context): void;
|
|
10
11
|
getWidth(): number;
|
|
11
12
|
getHeight(): number;
|
|
12
|
-
setWidth(width:
|
|
13
|
-
setHeight(height:
|
|
13
|
+
setWidth(width: number): void;
|
|
14
|
+
setHeight(height: number): void;
|
|
14
15
|
outerRadius: GetSet<number, this>;
|
|
15
16
|
innerRadius: GetSet<number, this>;
|
|
16
17
|
numPoints: GetSet<number, this>;
|
package/lib/shapes/Star.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 {
|
|
6
9
|
_sceneFunc(context) {
|
|
7
10
|
var innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();
|
|
8
11
|
context.beginPath();
|
|
@@ -29,10 +32,11 @@ export class Star extends Shape {
|
|
|
29
32
|
this.outerRadius(height / 2);
|
|
30
33
|
}
|
|
31
34
|
}
|
|
35
|
+
exports.Star = Star;
|
|
32
36
|
Star.prototype.className = 'Star';
|
|
33
37
|
Star.prototype._centroid = true;
|
|
34
38
|
Star.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
|
35
|
-
_registerNode(Star);
|
|
36
|
-
Factory.addGetterSetter(Star, 'numPoints', 5, getNumberValidator());
|
|
37
|
-
Factory.addGetterSetter(Star, 'innerRadius', 0, getNumberValidator());
|
|
38
|
-
Factory.addGetterSetter(Star, 'outerRadius', 0, getNumberValidator());
|
|
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)());
|
package/lib/shapes/Text.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Context } from '../Context.js';
|
|
2
|
+
import { Shape, ShapeConfig } from '../Shape.js';
|
|
3
|
+
import { GetSet } from '../types.js';
|
|
3
4
|
export declare function stringToArray(string: string): string[];
|
|
4
5
|
export interface TextConfig extends ShapeConfig {
|
|
5
6
|
text?: string;
|
|
@@ -28,9 +29,9 @@ export declare class Text extends Shape<TextConfig> {
|
|
|
28
29
|
textWidth: number;
|
|
29
30
|
textHeight: number;
|
|
30
31
|
constructor(config?: TextConfig);
|
|
31
|
-
_sceneFunc(context:
|
|
32
|
-
_hitFunc(context:
|
|
33
|
-
setText(text:
|
|
32
|
+
_sceneFunc(context: Context): void;
|
|
33
|
+
_hitFunc(context: Context): void;
|
|
34
|
+
setText(text: string): this;
|
|
34
35
|
getWidth(): any;
|
|
35
36
|
getHeight(): any;
|
|
36
37
|
getTextWidth(): number;
|
|
@@ -40,8 +41,8 @@ export declare class Text extends Shape<TextConfig> {
|
|
|
40
41
|
height: number;
|
|
41
42
|
};
|
|
42
43
|
_getContextFont(): string;
|
|
43
|
-
_addTextLine(line:
|
|
44
|
-
_getTextWidth(text:
|
|
44
|
+
_addTextLine(line: string): number;
|
|
45
|
+
_getTextWidth(text: string): number;
|
|
45
46
|
_setTextData(): void;
|
|
46
47
|
_shouldHandleEllipsis(currentHeightPx: number): boolean;
|
|
47
48
|
_tryToAddEllipsisToLastLine(): void;
|