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/cmj/shapes/Arrow.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Arrow = void 0;
|
|
4
|
-
const Factory_1 = require("../Factory");
|
|
5
|
-
const Line_1 = require("./Line");
|
|
6
|
-
const Validators_1 = require("../Validators");
|
|
7
|
-
const Global_1 = require("../Global");
|
|
8
|
-
const Path_1 = require("./Path");
|
|
9
|
-
class Arrow extends Line_1.Line {
|
|
10
|
-
_sceneFunc(ctx) {
|
|
11
|
-
super._sceneFunc(ctx);
|
|
12
|
-
var PI2 = Math.PI * 2;
|
|
13
|
-
var points = this.points();
|
|
14
|
-
var tp = points;
|
|
15
|
-
var fromTension = this.tension() !== 0 && points.length > 4;
|
|
16
|
-
if (fromTension) {
|
|
17
|
-
tp = this.getTensionPoints();
|
|
18
|
-
}
|
|
19
|
-
var length = this.pointerLength();
|
|
20
|
-
var n = points.length;
|
|
21
|
-
var dx, dy;
|
|
22
|
-
if (fromTension) {
|
|
23
|
-
const lp = [
|
|
24
|
-
tp[tp.length - 4],
|
|
25
|
-
tp[tp.length - 3],
|
|
26
|
-
tp[tp.length - 2],
|
|
27
|
-
tp[tp.length - 1],
|
|
28
|
-
points[n - 2],
|
|
29
|
-
points[n - 1],
|
|
30
|
-
];
|
|
31
|
-
const lastLength = Path_1.Path.calcLength(tp[tp.length - 4], tp[tp.length - 3], 'C', lp);
|
|
32
|
-
const previous = Path_1.Path.getPointOnQuadraticBezier(Math.min(1, 1 - length / lastLength), lp[0], lp[1], lp[2], lp[3], lp[4], lp[5]);
|
|
33
|
-
dx = points[n - 2] - previous.x;
|
|
34
|
-
dy = points[n - 1] - previous.y;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
dx = points[n - 2] - points[n - 4];
|
|
38
|
-
dy = points[n - 1] - points[n - 3];
|
|
39
|
-
}
|
|
40
|
-
var radians = (Math.atan2(dy, dx) + PI2) % PI2;
|
|
41
|
-
var width = this.pointerWidth();
|
|
42
|
-
if (this.pointerAtEnding()) {
|
|
43
|
-
ctx.save();
|
|
44
|
-
ctx.beginPath();
|
|
45
|
-
ctx.translate(points[n - 2], points[n - 1]);
|
|
46
|
-
ctx.rotate(radians);
|
|
47
|
-
ctx.moveTo(0, 0);
|
|
48
|
-
ctx.lineTo(-length, width / 2);
|
|
49
|
-
ctx.lineTo(-length, -width / 2);
|
|
50
|
-
ctx.closePath();
|
|
51
|
-
ctx.restore();
|
|
52
|
-
this.__fillStroke(ctx);
|
|
53
|
-
}
|
|
54
|
-
if (this.pointerAtBeginning()) {
|
|
55
|
-
ctx.save();
|
|
56
|
-
ctx.beginPath();
|
|
57
|
-
ctx.translate(points[0], points[1]);
|
|
58
|
-
if (fromTension) {
|
|
59
|
-
dx = (tp[0] + tp[2]) / 2 - points[0];
|
|
60
|
-
dy = (tp[1] + tp[3]) / 2 - points[1];
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
dx = points[2] - points[0];
|
|
64
|
-
dy = points[3] - points[1];
|
|
65
|
-
}
|
|
66
|
-
ctx.rotate((Math.atan2(-dy, -dx) + PI2) % PI2);
|
|
67
|
-
ctx.moveTo(0, 0);
|
|
68
|
-
ctx.lineTo(-length, width / 2);
|
|
69
|
-
ctx.lineTo(-length, -width / 2);
|
|
70
|
-
ctx.closePath();
|
|
71
|
-
ctx.restore();
|
|
72
|
-
this.__fillStroke(ctx);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
__fillStroke(ctx) {
|
|
76
|
-
var isDashEnabled = this.dashEnabled();
|
|
77
|
-
if (isDashEnabled) {
|
|
78
|
-
this.attrs.dashEnabled = false;
|
|
79
|
-
ctx.setLineDash([]);
|
|
80
|
-
}
|
|
81
|
-
ctx.fillStrokeShape(this);
|
|
82
|
-
if (isDashEnabled) {
|
|
83
|
-
this.attrs.dashEnabled = true;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
getSelfRect() {
|
|
87
|
-
const lineRect = super.getSelfRect();
|
|
88
|
-
const offset = this.pointerWidth() / 2;
|
|
89
|
-
return {
|
|
90
|
-
x: lineRect.x - offset,
|
|
91
|
-
y: lineRect.y - offset,
|
|
92
|
-
width: lineRect.width + offset * 2,
|
|
93
|
-
height: lineRect.height + offset * 2,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.Arrow = Arrow;
|
|
98
|
-
Arrow.prototype.className = 'Arrow';
|
|
99
|
-
(0, Global_1._registerNode)(Arrow);
|
|
100
|
-
Factory_1.Factory.addGetterSetter(Arrow, 'pointerLength', 10, (0, Validators_1.getNumberValidator)());
|
|
101
|
-
Factory_1.Factory.addGetterSetter(Arrow, 'pointerWidth', 10, (0, Validators_1.getNumberValidator)());
|
|
102
|
-
Factory_1.Factory.addGetterSetter(Arrow, 'pointerAtBeginning', false);
|
|
103
|
-
Factory_1.Factory.addGetterSetter(Arrow, 'pointerAtEnding', true);
|
package/cmj/shapes/Circle.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { GetSet } from '../types';
|
|
3
|
-
export interface CircleConfig extends ShapeConfig {
|
|
4
|
-
radius?: number;
|
|
5
|
-
}
|
|
6
|
-
export declare class Circle extends Shape<CircleConfig> {
|
|
7
|
-
_sceneFunc(context: any): void;
|
|
8
|
-
getWidth(): number;
|
|
9
|
-
getHeight(): number;
|
|
10
|
-
setWidth(width: any): void;
|
|
11
|
-
setHeight(height: any): void;
|
|
12
|
-
radius: GetSet<number, this>;
|
|
13
|
-
}
|
package/cmj/shapes/Circle.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Circle = 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 Circle extends Shape_1.Shape {
|
|
9
|
-
_sceneFunc(context) {
|
|
10
|
-
context.beginPath();
|
|
11
|
-
context.arc(0, 0, this.attrs.radius || 0, 0, Math.PI * 2, false);
|
|
12
|
-
context.closePath();
|
|
13
|
-
context.fillStrokeShape(this);
|
|
14
|
-
}
|
|
15
|
-
getWidth() {
|
|
16
|
-
return this.radius() * 2;
|
|
17
|
-
}
|
|
18
|
-
getHeight() {
|
|
19
|
-
return this.radius() * 2;
|
|
20
|
-
}
|
|
21
|
-
setWidth(width) {
|
|
22
|
-
if (this.radius() !== width / 2) {
|
|
23
|
-
this.radius(width / 2);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
setHeight(height) {
|
|
27
|
-
if (this.radius() !== height / 2) {
|
|
28
|
-
this.radius(height / 2);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.Circle = Circle;
|
|
33
|
-
Circle.prototype._centroid = true;
|
|
34
|
-
Circle.prototype.className = 'Circle';
|
|
35
|
-
Circle.prototype._attrsAffectingSize = ['radius'];
|
|
36
|
-
(0, Global_1._registerNode)(Circle);
|
|
37
|
-
Factory_1.Factory.addGetterSetter(Circle, 'radius', 0, (0, Validators_1.getNumberValidator)());
|
package/cmj/shapes/Ellipse.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { GetSet, Vector2d } from '../types';
|
|
3
|
-
export interface EllipseConfig extends ShapeConfig {
|
|
4
|
-
radiusX: number;
|
|
5
|
-
radiusY: number;
|
|
6
|
-
}
|
|
7
|
-
export declare class Ellipse extends Shape<EllipseConfig> {
|
|
8
|
-
_sceneFunc(context: any): void;
|
|
9
|
-
getWidth(): number;
|
|
10
|
-
getHeight(): number;
|
|
11
|
-
setWidth(width: any): void;
|
|
12
|
-
setHeight(height: any): void;
|
|
13
|
-
radius: GetSet<Vector2d, this>;
|
|
14
|
-
radiusX: GetSet<number, this>;
|
|
15
|
-
radiusY: GetSet<number, this>;
|
|
16
|
-
}
|
package/cmj/shapes/Ellipse.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Ellipse = 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 Ellipse extends Shape_1.Shape {
|
|
9
|
-
_sceneFunc(context) {
|
|
10
|
-
var rx = this.radiusX(), ry = this.radiusY();
|
|
11
|
-
context.beginPath();
|
|
12
|
-
context.save();
|
|
13
|
-
if (rx !== ry) {
|
|
14
|
-
context.scale(1, ry / rx);
|
|
15
|
-
}
|
|
16
|
-
context.arc(0, 0, rx, 0, Math.PI * 2, false);
|
|
17
|
-
context.restore();
|
|
18
|
-
context.closePath();
|
|
19
|
-
context.fillStrokeShape(this);
|
|
20
|
-
}
|
|
21
|
-
getWidth() {
|
|
22
|
-
return this.radiusX() * 2;
|
|
23
|
-
}
|
|
24
|
-
getHeight() {
|
|
25
|
-
return this.radiusY() * 2;
|
|
26
|
-
}
|
|
27
|
-
setWidth(width) {
|
|
28
|
-
this.radiusX(width / 2);
|
|
29
|
-
}
|
|
30
|
-
setHeight(height) {
|
|
31
|
-
this.radiusY(height / 2);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.Ellipse = Ellipse;
|
|
35
|
-
Ellipse.prototype.className = 'Ellipse';
|
|
36
|
-
Ellipse.prototype._centroid = true;
|
|
37
|
-
Ellipse.prototype._attrsAffectingSize = ['radiusX', 'radiusY'];
|
|
38
|
-
(0, Global_1._registerNode)(Ellipse);
|
|
39
|
-
Factory_1.Factory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']);
|
|
40
|
-
Factory_1.Factory.addGetterSetter(Ellipse, 'radiusX', 0, (0, Validators_1.getNumberValidator)());
|
|
41
|
-
Factory_1.Factory.addGetterSetter(Ellipse, 'radiusY', 0, (0, Validators_1.getNumberValidator)());
|
package/cmj/shapes/Image.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { GetSet, IRect } from '../types';
|
|
3
|
-
import { Context } from '../Context';
|
|
4
|
-
export interface ImageConfig extends ShapeConfig {
|
|
5
|
-
image: CanvasImageSource | undefined;
|
|
6
|
-
crop?: IRect;
|
|
7
|
-
cornerRadius?: number | number[];
|
|
8
|
-
}
|
|
9
|
-
export declare class Image extends Shape<ImageConfig> {
|
|
10
|
-
constructor(attrs: ImageConfig);
|
|
11
|
-
_setImageLoad(): void;
|
|
12
|
-
_useBufferCanvas(): boolean;
|
|
13
|
-
_sceneFunc(context: Context): void;
|
|
14
|
-
_hitFunc(context: any): void;
|
|
15
|
-
getWidth(): any;
|
|
16
|
-
getHeight(): any;
|
|
17
|
-
static fromURL(url: any, callback: any, onError?: any): void;
|
|
18
|
-
image: GetSet<CanvasImageSource | undefined, this>;
|
|
19
|
-
crop: GetSet<IRect, this>;
|
|
20
|
-
cropX: GetSet<number, this>;
|
|
21
|
-
cropY: GetSet<number, this>;
|
|
22
|
-
cropWidth: GetSet<number, this>;
|
|
23
|
-
cropHeight: GetSet<number, this>;
|
|
24
|
-
cornerRadius: GetSet<number | number[], this>;
|
|
25
|
-
}
|
package/cmj/shapes/Image.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Image = void 0;
|
|
4
|
-
const Util_1 = require("../Util");
|
|
5
|
-
const Factory_1 = require("../Factory");
|
|
6
|
-
const Shape_1 = require("../Shape");
|
|
7
|
-
const Global_1 = require("../Global");
|
|
8
|
-
const Validators_1 = require("../Validators");
|
|
9
|
-
class Image extends Shape_1.Shape {
|
|
10
|
-
constructor(attrs) {
|
|
11
|
-
super(attrs);
|
|
12
|
-
this.on('imageChange.konva', () => {
|
|
13
|
-
this._setImageLoad();
|
|
14
|
-
});
|
|
15
|
-
this._setImageLoad();
|
|
16
|
-
}
|
|
17
|
-
_setImageLoad() {
|
|
18
|
-
const image = this.image();
|
|
19
|
-
if (image && image.complete) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (image && image.readyState === 4) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (image && image['addEventListener']) {
|
|
26
|
-
image['addEventListener']('load', () => {
|
|
27
|
-
this._requestDraw();
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
_useBufferCanvas() {
|
|
32
|
-
return super._useBufferCanvas(true);
|
|
33
|
-
}
|
|
34
|
-
_sceneFunc(context) {
|
|
35
|
-
const width = this.getWidth();
|
|
36
|
-
const height = this.getHeight();
|
|
37
|
-
const cornerRadius = this.cornerRadius();
|
|
38
|
-
const image = this.attrs.image;
|
|
39
|
-
let params;
|
|
40
|
-
if (image) {
|
|
41
|
-
const cropWidth = this.attrs.cropWidth;
|
|
42
|
-
const cropHeight = this.attrs.cropHeight;
|
|
43
|
-
if (cropWidth && cropHeight) {
|
|
44
|
-
params = [
|
|
45
|
-
image,
|
|
46
|
-
this.cropX(),
|
|
47
|
-
this.cropY(),
|
|
48
|
-
cropWidth,
|
|
49
|
-
cropHeight,
|
|
50
|
-
0,
|
|
51
|
-
0,
|
|
52
|
-
width,
|
|
53
|
-
height,
|
|
54
|
-
];
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
params = [image, 0, 0, width, height];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (this.hasFill() || this.hasStroke() || cornerRadius) {
|
|
61
|
-
context.beginPath();
|
|
62
|
-
cornerRadius
|
|
63
|
-
? Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius)
|
|
64
|
-
: context.rect(0, 0, width, height);
|
|
65
|
-
context.closePath();
|
|
66
|
-
context.fillStrokeShape(this);
|
|
67
|
-
}
|
|
68
|
-
if (image) {
|
|
69
|
-
if (cornerRadius) {
|
|
70
|
-
context.clip();
|
|
71
|
-
}
|
|
72
|
-
context.drawImage.apply(context, params);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
_hitFunc(context) {
|
|
76
|
-
var width = this.width(), height = this.height(), cornerRadius = this.cornerRadius();
|
|
77
|
-
context.beginPath();
|
|
78
|
-
if (!cornerRadius) {
|
|
79
|
-
context.rect(0, 0, width, height);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius);
|
|
83
|
-
}
|
|
84
|
-
context.closePath();
|
|
85
|
-
context.fillStrokeShape(this);
|
|
86
|
-
}
|
|
87
|
-
getWidth() {
|
|
88
|
-
var _a, _b;
|
|
89
|
-
return (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width;
|
|
90
|
-
}
|
|
91
|
-
getHeight() {
|
|
92
|
-
var _a, _b;
|
|
93
|
-
return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
|
|
94
|
-
}
|
|
95
|
-
static fromURL(url, callback, onError = null) {
|
|
96
|
-
var img = Util_1.Util.createImageElement();
|
|
97
|
-
img.onload = function () {
|
|
98
|
-
var image = new Image({
|
|
99
|
-
image: img,
|
|
100
|
-
});
|
|
101
|
-
callback(image);
|
|
102
|
-
};
|
|
103
|
-
img.onerror = onError;
|
|
104
|
-
img.crossOrigin = 'Anonymous';
|
|
105
|
-
img.src = url;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.Image = Image;
|
|
109
|
-
Image.prototype.className = 'Image';
|
|
110
|
-
(0, Global_1._registerNode)(Image);
|
|
111
|
-
Factory_1.Factory.addGetterSetter(Image, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));
|
|
112
|
-
Factory_1.Factory.addGetterSetter(Image, 'image');
|
|
113
|
-
Factory_1.Factory.addComponentsGetterSetter(Image, 'crop', ['x', 'y', 'width', 'height']);
|
|
114
|
-
Factory_1.Factory.addGetterSetter(Image, 'cropX', 0, (0, Validators_1.getNumberValidator)());
|
|
115
|
-
Factory_1.Factory.addGetterSetter(Image, 'cropY', 0, (0, Validators_1.getNumberValidator)());
|
|
116
|
-
Factory_1.Factory.addGetterSetter(Image, 'cropWidth', 0, (0, Validators_1.getNumberValidator)());
|
|
117
|
-
Factory_1.Factory.addGetterSetter(Image, 'cropHeight', 0, (0, Validators_1.getNumberValidator)());
|
package/cmj/shapes/Label.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { Group } from '../Group';
|
|
3
|
-
import { ContainerConfig } from '../Container';
|
|
4
|
-
import { GetSet } from '../types';
|
|
5
|
-
import { Text } from './Text';
|
|
6
|
-
export interface LabelConfig extends ContainerConfig {
|
|
7
|
-
}
|
|
8
|
-
export declare class Label extends Group {
|
|
9
|
-
constructor(config?: any);
|
|
10
|
-
getText(): Text;
|
|
11
|
-
getTag(): Tag;
|
|
12
|
-
_addListeners(text: any): void;
|
|
13
|
-
getWidth(): number;
|
|
14
|
-
getHeight(): number;
|
|
15
|
-
_sync(): void;
|
|
16
|
-
}
|
|
17
|
-
export interface TagConfig extends ShapeConfig {
|
|
18
|
-
pointerDirection?: string;
|
|
19
|
-
pointerWidth?: number;
|
|
20
|
-
pointerHeight?: number;
|
|
21
|
-
cornerRadius?: number | Array<number>;
|
|
22
|
-
}
|
|
23
|
-
export declare class Tag extends Shape<TagConfig> {
|
|
24
|
-
_sceneFunc(context: any): void;
|
|
25
|
-
getSelfRect(): {
|
|
26
|
-
x: number;
|
|
27
|
-
y: number;
|
|
28
|
-
width: number;
|
|
29
|
-
height: number;
|
|
30
|
-
};
|
|
31
|
-
pointerDirection: GetSet<'left' | 'top' | 'right' | 'bottom', this>;
|
|
32
|
-
pointerWidth: GetSet<number, this>;
|
|
33
|
-
pointerHeight: GetSet<number, this>;
|
|
34
|
-
cornerRadius: GetSet<number, this>;
|
|
35
|
-
}
|
package/cmj/shapes/Label.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
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");
|
|
9
|
-
var ATTR_CHANGE_LIST = [
|
|
10
|
-
'fontFamily',
|
|
11
|
-
'fontSize',
|
|
12
|
-
'fontStyle',
|
|
13
|
-
'padding',
|
|
14
|
-
'lineHeight',
|
|
15
|
-
'text',
|
|
16
|
-
'width',
|
|
17
|
-
'height',
|
|
18
|
-
'pointerDirection',
|
|
19
|
-
'pointerWidth',
|
|
20
|
-
'pointerHeight',
|
|
21
|
-
], CHANGE_KONVA = 'Change.konva', NONE = 'none', UP = 'up', RIGHT = 'right', DOWN = 'down', LEFT = 'left', attrChangeListLen = ATTR_CHANGE_LIST.length;
|
|
22
|
-
class Label extends Group_1.Group {
|
|
23
|
-
constructor(config) {
|
|
24
|
-
super(config);
|
|
25
|
-
this.on('add.konva', function (evt) {
|
|
26
|
-
this._addListeners(evt.child);
|
|
27
|
-
this._sync();
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
getText() {
|
|
31
|
-
return this.find('Text')[0];
|
|
32
|
-
}
|
|
33
|
-
getTag() {
|
|
34
|
-
return this.find('Tag')[0];
|
|
35
|
-
}
|
|
36
|
-
_addListeners(text) {
|
|
37
|
-
var that = this, n;
|
|
38
|
-
var func = function () {
|
|
39
|
-
that._sync();
|
|
40
|
-
};
|
|
41
|
-
for (n = 0; n < attrChangeListLen; n++) {
|
|
42
|
-
text.on(ATTR_CHANGE_LIST[n] + CHANGE_KONVA, func);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
getWidth() {
|
|
46
|
-
return this.getText().width();
|
|
47
|
-
}
|
|
48
|
-
getHeight() {
|
|
49
|
-
return this.getText().height();
|
|
50
|
-
}
|
|
51
|
-
_sync() {
|
|
52
|
-
var text = this.getText(), tag = this.getTag(), width, height, pointerDirection, pointerWidth, x, y, pointerHeight;
|
|
53
|
-
if (text && tag) {
|
|
54
|
-
width = text.width();
|
|
55
|
-
height = text.height();
|
|
56
|
-
pointerDirection = tag.pointerDirection();
|
|
57
|
-
pointerWidth = tag.pointerWidth();
|
|
58
|
-
pointerHeight = tag.pointerHeight();
|
|
59
|
-
x = 0;
|
|
60
|
-
y = 0;
|
|
61
|
-
switch (pointerDirection) {
|
|
62
|
-
case UP:
|
|
63
|
-
x = width / 2;
|
|
64
|
-
y = -1 * pointerHeight;
|
|
65
|
-
break;
|
|
66
|
-
case RIGHT:
|
|
67
|
-
x = width + pointerWidth;
|
|
68
|
-
y = height / 2;
|
|
69
|
-
break;
|
|
70
|
-
case DOWN:
|
|
71
|
-
x = width / 2;
|
|
72
|
-
y = height + pointerHeight;
|
|
73
|
-
break;
|
|
74
|
-
case LEFT:
|
|
75
|
-
x = -1 * pointerWidth;
|
|
76
|
-
y = height / 2;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
tag.setAttrs({
|
|
80
|
-
x: -1 * x,
|
|
81
|
-
y: -1 * y,
|
|
82
|
-
width: width,
|
|
83
|
-
height: height,
|
|
84
|
-
});
|
|
85
|
-
text.setAttrs({
|
|
86
|
-
x: -1 * x,
|
|
87
|
-
y: -1 * y,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.Label = Label;
|
|
93
|
-
Label.prototype.className = 'Label';
|
|
94
|
-
(0, Global_1._registerNode)(Label);
|
|
95
|
-
class Tag extends Shape_1.Shape {
|
|
96
|
-
_sceneFunc(context) {
|
|
97
|
-
var width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = this.cornerRadius();
|
|
98
|
-
let topLeft = 0;
|
|
99
|
-
let topRight = 0;
|
|
100
|
-
let bottomLeft = 0;
|
|
101
|
-
let bottomRight = 0;
|
|
102
|
-
if (typeof cornerRadius === 'number') {
|
|
103
|
-
topLeft =
|
|
104
|
-
topRight =
|
|
105
|
-
bottomLeft =
|
|
106
|
-
bottomRight =
|
|
107
|
-
Math.min(cornerRadius, width / 2, height / 2);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
topLeft = Math.min(cornerRadius[0] || 0, width / 2, height / 2);
|
|
111
|
-
topRight = Math.min(cornerRadius[1] || 0, width / 2, height / 2);
|
|
112
|
-
bottomRight = Math.min(cornerRadius[2] || 0, width / 2, height / 2);
|
|
113
|
-
bottomLeft = Math.min(cornerRadius[3] || 0, width / 2, height / 2);
|
|
114
|
-
}
|
|
115
|
-
context.beginPath();
|
|
116
|
-
context.moveTo(topLeft, 0);
|
|
117
|
-
if (pointerDirection === UP) {
|
|
118
|
-
context.lineTo((width - pointerWidth) / 2, 0);
|
|
119
|
-
context.lineTo(width / 2, -1 * pointerHeight);
|
|
120
|
-
context.lineTo((width + pointerWidth) / 2, 0);
|
|
121
|
-
}
|
|
122
|
-
context.lineTo(width - topRight, 0);
|
|
123
|
-
context.arc(width - topRight, topRight, topRight, (Math.PI * 3) / 2, 0, false);
|
|
124
|
-
if (pointerDirection === RIGHT) {
|
|
125
|
-
context.lineTo(width, (height - pointerHeight) / 2);
|
|
126
|
-
context.lineTo(width + pointerWidth, height / 2);
|
|
127
|
-
context.lineTo(width, (height + pointerHeight) / 2);
|
|
128
|
-
}
|
|
129
|
-
context.lineTo(width, height - bottomRight);
|
|
130
|
-
context.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, false);
|
|
131
|
-
if (pointerDirection === DOWN) {
|
|
132
|
-
context.lineTo((width + pointerWidth) / 2, height);
|
|
133
|
-
context.lineTo(width / 2, height + pointerHeight);
|
|
134
|
-
context.lineTo((width - pointerWidth) / 2, height);
|
|
135
|
-
}
|
|
136
|
-
context.lineTo(bottomLeft, height);
|
|
137
|
-
context.arc(bottomLeft, height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);
|
|
138
|
-
if (pointerDirection === LEFT) {
|
|
139
|
-
context.lineTo(0, (height + pointerHeight) / 2);
|
|
140
|
-
context.lineTo(-1 * pointerWidth, height / 2);
|
|
141
|
-
context.lineTo(0, (height - pointerHeight) / 2);
|
|
142
|
-
}
|
|
143
|
-
context.lineTo(0, topLeft);
|
|
144
|
-
context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);
|
|
145
|
-
context.closePath();
|
|
146
|
-
context.fillStrokeShape(this);
|
|
147
|
-
}
|
|
148
|
-
getSelfRect() {
|
|
149
|
-
var x = 0, y = 0, pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), direction = this.pointerDirection(), width = this.width(), height = this.height();
|
|
150
|
-
if (direction === UP) {
|
|
151
|
-
y -= pointerHeight;
|
|
152
|
-
height += pointerHeight;
|
|
153
|
-
}
|
|
154
|
-
else if (direction === DOWN) {
|
|
155
|
-
height += pointerHeight;
|
|
156
|
-
}
|
|
157
|
-
else if (direction === LEFT) {
|
|
158
|
-
x -= pointerWidth * 1.5;
|
|
159
|
-
width += pointerWidth;
|
|
160
|
-
}
|
|
161
|
-
else if (direction === RIGHT) {
|
|
162
|
-
width += pointerWidth * 1.5;
|
|
163
|
-
}
|
|
164
|
-
return {
|
|
165
|
-
x: x,
|
|
166
|
-
y: y,
|
|
167
|
-
width: width,
|
|
168
|
-
height: height,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
exports.Tag = Tag;
|
|
173
|
-
Tag.prototype.className = 'Tag';
|
|
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/cmj/shapes/Line.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Shape, ShapeConfig } from '../Shape';
|
|
2
|
-
import { GetSet } from '../types';
|
|
3
|
-
import { Context } from '../Context';
|
|
4
|
-
export interface LineConfig extends ShapeConfig {
|
|
5
|
-
points?: number[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
|
6
|
-
tension?: number;
|
|
7
|
-
closed?: boolean;
|
|
8
|
-
bezier?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare class Line<Config extends LineConfig = LineConfig> extends Shape<Config> {
|
|
11
|
-
constructor(config?: Config);
|
|
12
|
-
_sceneFunc(context: Context): void;
|
|
13
|
-
getTensionPoints(): any;
|
|
14
|
-
_getTensionPoints(): any[];
|
|
15
|
-
_getTensionPointsClosed(): any[];
|
|
16
|
-
getWidth(): number;
|
|
17
|
-
getHeight(): number;
|
|
18
|
-
getSelfRect(): {
|
|
19
|
-
x: number;
|
|
20
|
-
y: number;
|
|
21
|
-
width: number;
|
|
22
|
-
height: number;
|
|
23
|
-
};
|
|
24
|
-
closed: GetSet<boolean, this>;
|
|
25
|
-
bezier: GetSet<boolean, this>;
|
|
26
|
-
tension: GetSet<number, this>;
|
|
27
|
-
points: GetSet<number[], this>;
|
|
28
|
-
}
|