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/Global.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._registerNode = exports.Konva = exports.glob = void 0;
|
|
1
4
|
var PI_OVER_180 = Math.PI / 180;
|
|
2
5
|
function detectBrowser() {
|
|
3
6
|
return (typeof window !== 'undefined' &&
|
|
4
7
|
({}.toString.call(window) === '[object Window]' ||
|
|
5
8
|
{}.toString.call(window) === '[object global]'));
|
|
6
9
|
}
|
|
7
|
-
|
|
10
|
+
exports.glob = typeof global !== 'undefined'
|
|
8
11
|
? global
|
|
9
12
|
: typeof window !== 'undefined'
|
|
10
13
|
? window
|
|
11
14
|
: typeof WorkerGlobalScope !== 'undefined'
|
|
12
15
|
? self
|
|
13
16
|
: {};
|
|
14
|
-
|
|
15
|
-
_global: glob,
|
|
16
|
-
version: '
|
|
17
|
+
exports.Konva = {
|
|
18
|
+
_global: exports.glob,
|
|
19
|
+
version: '9.0.0',
|
|
17
20
|
isBrowser: detectBrowser(),
|
|
18
21
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
19
22
|
dblClickWindow: 400,
|
|
20
23
|
getAngle(angle) {
|
|
21
|
-
return Konva.angleDeg ? angle * PI_OVER_180 : angle;
|
|
24
|
+
return exports.Konva.angleDeg ? angle * PI_OVER_180 : angle;
|
|
22
25
|
},
|
|
23
26
|
enableTrace: false,
|
|
24
27
|
pointerEventsEnabled: true,
|
|
@@ -40,18 +43,19 @@ export const Konva = {
|
|
|
40
43
|
showWarnings: true,
|
|
41
44
|
dragButtons: [0, 1],
|
|
42
45
|
isDragging() {
|
|
43
|
-
return Konva['DD'].isDragging;
|
|
46
|
+
return exports.Konva['DD'].isDragging;
|
|
44
47
|
},
|
|
45
48
|
isDragReady() {
|
|
46
|
-
return !!Konva['DD'].node;
|
|
49
|
+
return !!exports.Konva['DD'].node;
|
|
47
50
|
},
|
|
48
51
|
releaseCanvasOnDestroy: true,
|
|
49
|
-
document: glob.document,
|
|
52
|
+
document: exports.glob.document,
|
|
50
53
|
_injectGlobal(Konva) {
|
|
51
|
-
glob.Konva = Konva;
|
|
54
|
+
exports.glob.Konva = Konva;
|
|
52
55
|
},
|
|
53
56
|
};
|
|
54
|
-
|
|
55
|
-
Konva[NodeClass.prototype.getClassName()] = NodeClass;
|
|
57
|
+
const _registerNode = (NodeClass) => {
|
|
58
|
+
exports.Konva[NodeClass.prototype.getClassName()] = NodeClass;
|
|
56
59
|
};
|
|
57
|
-
|
|
60
|
+
exports._registerNode = _registerNode;
|
|
61
|
+
exports.Konva._injectGlobal(exports.Konva);
|
package/lib/Group.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Container, ContainerConfig } from './Container';
|
|
2
|
-
import { Node } from './Node';
|
|
3
|
-
import { Shape } from './Shape';
|
|
1
|
+
import { Container, ContainerConfig } from './Container.js';
|
|
2
|
+
import { Node } from './Node.js';
|
|
3
|
+
import { Shape } from './Shape.js';
|
|
4
4
|
export interface GroupConfig extends ContainerConfig {
|
|
5
5
|
}
|
|
6
6
|
export declare class Group extends Container<Group | Shape> {
|
package/lib/Group.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Group = void 0;
|
|
4
|
+
const Util_1 = require("./Util");
|
|
5
|
+
const Container_1 = require("./Container");
|
|
6
|
+
const Global_1 = require("./Global");
|
|
7
|
+
class Group extends Container_1.Container {
|
|
5
8
|
_validateAdd(child) {
|
|
6
9
|
var type = child.getType();
|
|
7
10
|
if (type !== 'Group' && type !== 'Shape') {
|
|
8
|
-
Util.throw('You may only add groups and shapes to groups.');
|
|
11
|
+
Util_1.Util.throw('You may only add groups and shapes to groups.');
|
|
9
12
|
}
|
|
10
13
|
}
|
|
11
14
|
}
|
|
15
|
+
exports.Group = Group;
|
|
12
16
|
Group.prototype.nodeType = 'Group';
|
|
13
|
-
_registerNode(Group);
|
|
17
|
+
(0, Global_1._registerNode)(Group);
|
package/lib/Layer.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Container, ContainerConfig } from './Container';
|
|
2
|
-
import { Node } from './Node';
|
|
3
|
-
import { SceneCanvas, HitCanvas } from './Canvas';
|
|
4
|
-
import { Stage } from './Stage';
|
|
5
|
-
import { GetSet, Vector2d } from './types';
|
|
6
|
-
import { Group } from './Group';
|
|
7
|
-
import { Shape } from './Shape';
|
|
1
|
+
import { Container, ContainerConfig } from './Container.js';
|
|
2
|
+
import { Node } from './Node.js';
|
|
3
|
+
import { SceneCanvas, HitCanvas } from './Canvas.js';
|
|
4
|
+
import { Stage } from './Stage.js';
|
|
5
|
+
import { GetSet, Vector2d } from './types.js';
|
|
6
|
+
import { Group } from './Group.js';
|
|
7
|
+
import { Shape } from './Shape.js';
|
|
8
8
|
export interface LayerConfig extends ContainerConfig {
|
|
9
9
|
clearBeforeDraw?: boolean;
|
|
10
10
|
hitGraphEnabled?: boolean;
|
|
@@ -19,7 +19,7 @@ export declare class Layer extends Container<Group | Shape> {
|
|
|
19
19
|
getCanvas(): SceneCanvas;
|
|
20
20
|
getNativeCanvasElement(): HTMLCanvasElement;
|
|
21
21
|
getHitCanvas(): HitCanvas;
|
|
22
|
-
getContext(): import("./Context").Context;
|
|
22
|
+
getContext(): import("./Context.js").Context;
|
|
23
23
|
clear(bounds?: any): this;
|
|
24
24
|
setZIndex(index: any): this;
|
|
25
25
|
moveToTop(): boolean;
|
|
@@ -42,7 +42,7 @@ export declare class Layer extends Container<Group | Shape> {
|
|
|
42
42
|
getHeight(): number;
|
|
43
43
|
setHeight(): void;
|
|
44
44
|
batchDraw(): this;
|
|
45
|
-
getIntersection(pos: Vector2d): Shape<import("./Shape").ShapeConfig>;
|
|
45
|
+
getIntersection(pos: Vector2d): Shape<import("./Shape.js").ShapeConfig>;
|
|
46
46
|
_getIntersection(pos: Vector2d): {
|
|
47
47
|
shape?: Shape;
|
|
48
48
|
antialiased?: boolean;
|
package/lib/Layer.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Layer = void 0;
|
|
4
|
+
const Util_1 = require("./Util");
|
|
5
|
+
const Container_1 = require("./Container");
|
|
6
|
+
const Node_1 = require("./Node");
|
|
7
|
+
const Factory_1 = require("./Factory");
|
|
8
|
+
const Canvas_1 = require("./Canvas");
|
|
9
|
+
const Validators_1 = require("./Validators");
|
|
10
|
+
const Shape_1 = require("./Shape");
|
|
11
|
+
const Global_1 = require("./Global");
|
|
9
12
|
var HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [
|
|
10
13
|
{ x: 0, y: 0 },
|
|
11
14
|
{ x: -1, y: -1 },
|
|
@@ -13,11 +16,11 @@ var HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS
|
|
|
13
16
|
{ x: 1, y: 1 },
|
|
14
17
|
{ x: -1, y: 1 },
|
|
15
18
|
], INTERSECTION_OFFSETS_LEN = INTERSECTION_OFFSETS.length;
|
|
16
|
-
|
|
19
|
+
class Layer extends Container_1.Container {
|
|
17
20
|
constructor(config) {
|
|
18
21
|
super(config);
|
|
19
|
-
this.canvas = new SceneCanvas();
|
|
20
|
-
this.hitCanvas = new HitCanvas({
|
|
22
|
+
this.canvas = new Canvas_1.SceneCanvas();
|
|
23
|
+
this.hitCanvas = new Canvas_1.HitCanvas({
|
|
21
24
|
pixelRatio: 1,
|
|
22
25
|
});
|
|
23
26
|
this._waitingForDraw = false;
|
|
@@ -62,7 +65,7 @@ export class Layer extends Container {
|
|
|
62
65
|
return this;
|
|
63
66
|
}
|
|
64
67
|
moveToTop() {
|
|
65
|
-
Node.prototype.moveToTop.call(this);
|
|
68
|
+
Node_1.Node.prototype.moveToTop.call(this);
|
|
66
69
|
var stage = this.getStage();
|
|
67
70
|
if (stage && stage.content) {
|
|
68
71
|
stage.content.removeChild(this.getNativeCanvasElement());
|
|
@@ -71,7 +74,7 @@ export class Layer extends Container {
|
|
|
71
74
|
return true;
|
|
72
75
|
}
|
|
73
76
|
moveUp() {
|
|
74
|
-
var moved = Node.prototype.moveUp.call(this);
|
|
77
|
+
var moved = Node_1.Node.prototype.moveUp.call(this);
|
|
75
78
|
if (!moved) {
|
|
76
79
|
return false;
|
|
77
80
|
}
|
|
@@ -89,7 +92,7 @@ export class Layer extends Container {
|
|
|
89
92
|
return true;
|
|
90
93
|
}
|
|
91
94
|
moveDown() {
|
|
92
|
-
if (Node.prototype.moveDown.call(this)) {
|
|
95
|
+
if (Node_1.Node.prototype.moveDown.call(this)) {
|
|
93
96
|
var stage = this.getStage();
|
|
94
97
|
if (stage) {
|
|
95
98
|
var children = stage.children;
|
|
@@ -103,7 +106,7 @@ export class Layer extends Container {
|
|
|
103
106
|
return false;
|
|
104
107
|
}
|
|
105
108
|
moveToBottom() {
|
|
106
|
-
if (Node.prototype.moveToBottom.call(this)) {
|
|
109
|
+
if (Node_1.Node.prototype.moveToBottom.call(this)) {
|
|
107
110
|
var stage = this.getStage();
|
|
108
111
|
if (stage) {
|
|
109
112
|
var children = stage.children;
|
|
@@ -121,8 +124,8 @@ export class Layer extends Container {
|
|
|
121
124
|
}
|
|
122
125
|
remove() {
|
|
123
126
|
var _canvas = this.getNativeCanvasElement();
|
|
124
|
-
Node.prototype.remove.call(this);
|
|
125
|
-
if (_canvas && _canvas.parentNode && Util._isInDocument(_canvas)) {
|
|
127
|
+
Node_1.Node.prototype.remove.call(this);
|
|
128
|
+
if (_canvas && _canvas.parentNode && Util_1.Util._isInDocument(_canvas)) {
|
|
126
129
|
_canvas.parentNode.removeChild(_canvas);
|
|
127
130
|
}
|
|
128
131
|
return this;
|
|
@@ -139,7 +142,7 @@ export class Layer extends Container {
|
|
|
139
142
|
_validateAdd(child) {
|
|
140
143
|
var type = child.getType();
|
|
141
144
|
if (type !== 'Group' && type !== 'Shape') {
|
|
142
|
-
Util.throw('You may only add groups and shapes to a layer.');
|
|
145
|
+
Util_1.Util.throw('You may only add groups and shapes to a layer.');
|
|
143
146
|
}
|
|
144
147
|
}
|
|
145
148
|
_toKonvaCanvas(config) {
|
|
@@ -148,7 +151,7 @@ export class Layer extends Container {
|
|
|
148
151
|
config.height = config.height || this.getHeight();
|
|
149
152
|
config.x = config.x !== undefined ? config.x : this.x();
|
|
150
153
|
config.y = config.y !== undefined ? config.y : this.y();
|
|
151
|
-
return Node.prototype._toKonvaCanvas.call(this, config);
|
|
154
|
+
return Node_1.Node.prototype._toKonvaCanvas.call(this, config);
|
|
152
155
|
}
|
|
153
156
|
_checkVisibility() {
|
|
154
157
|
const visible = this.visible();
|
|
@@ -169,7 +172,7 @@ export class Layer extends Container {
|
|
|
169
172
|
}
|
|
170
173
|
}
|
|
171
174
|
setWidth() {
|
|
172
|
-
Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.');
|
|
175
|
+
Util_1.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.');
|
|
173
176
|
}
|
|
174
177
|
getHeight() {
|
|
175
178
|
if (this.parent) {
|
|
@@ -177,12 +180,12 @@ export class Layer extends Container {
|
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
setHeight() {
|
|
180
|
-
Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.');
|
|
183
|
+
Util_1.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.');
|
|
181
184
|
}
|
|
182
185
|
batchDraw() {
|
|
183
186
|
if (!this._waitingForDraw) {
|
|
184
187
|
this._waitingForDraw = true;
|
|
185
|
-
Util.requestAnimFrame(() => {
|
|
188
|
+
Util_1.Util.requestAnimFrame(() => {
|
|
186
189
|
this.draw();
|
|
187
190
|
this._waitingForDraw = false;
|
|
188
191
|
});
|
|
@@ -224,8 +227,8 @@ export class Layer extends Container {
|
|
|
224
227
|
const p = this.hitCanvas.context.getImageData(Math.round(pos.x * ratio), Math.round(pos.y * ratio), 1, 1).data;
|
|
225
228
|
const p3 = p[3];
|
|
226
229
|
if (p3 === 255) {
|
|
227
|
-
const colorKey = Util._rgbToHex(p[0], p[1], p[2]);
|
|
228
|
-
const shape = shapes[HASH + colorKey];
|
|
230
|
+
const colorKey = Util_1.Util._rgbToHex(p[0], p[1], p[2]);
|
|
231
|
+
const shape = Shape_1.shapes[HASH + colorKey];
|
|
229
232
|
if (shape) {
|
|
230
233
|
return {
|
|
231
234
|
shape: shape,
|
|
@@ -250,7 +253,7 @@ export class Layer extends Container {
|
|
|
250
253
|
if (this.clearBeforeDraw()) {
|
|
251
254
|
canvas.getContext().clear();
|
|
252
255
|
}
|
|
253
|
-
Container.prototype.drawScene.call(this, canvas, top);
|
|
256
|
+
Container_1.Container.prototype.drawScene.call(this, canvas, top);
|
|
254
257
|
this._fire(DRAW, {
|
|
255
258
|
node: this,
|
|
256
259
|
});
|
|
@@ -261,7 +264,7 @@ export class Layer extends Container {
|
|
|
261
264
|
if (layer && layer.clearBeforeDraw()) {
|
|
262
265
|
layer.getHitCanvas().getContext().clear();
|
|
263
266
|
}
|
|
264
|
-
Container.prototype.drawHit.call(this, canvas, top);
|
|
267
|
+
Container_1.Container.prototype.drawHit.call(this, canvas, top);
|
|
265
268
|
return this;
|
|
266
269
|
}
|
|
267
270
|
enableHitGraph() {
|
|
@@ -273,11 +276,11 @@ export class Layer extends Container {
|
|
|
273
276
|
return this;
|
|
274
277
|
}
|
|
275
278
|
setHitGraphEnabled(val) {
|
|
276
|
-
Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
|
|
279
|
+
Util_1.Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
|
|
277
280
|
this.listening(val);
|
|
278
281
|
}
|
|
279
282
|
getHitGraphEnabled(val) {
|
|
280
|
-
Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
|
|
283
|
+
Util_1.Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
|
|
281
284
|
return this.listening();
|
|
282
285
|
}
|
|
283
286
|
toggleHitCanvas() {
|
|
@@ -294,12 +297,13 @@ export class Layer extends Container {
|
|
|
294
297
|
}
|
|
295
298
|
}
|
|
296
299
|
destroy() {
|
|
297
|
-
Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas);
|
|
300
|
+
Util_1.Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas);
|
|
298
301
|
return super.destroy();
|
|
299
302
|
}
|
|
300
303
|
}
|
|
304
|
+
exports.Layer = Layer;
|
|
301
305
|
Layer.prototype.nodeType = 'Layer';
|
|
302
|
-
_registerNode(Layer);
|
|
303
|
-
Factory.addGetterSetter(Layer, 'imageSmoothingEnabled', true);
|
|
304
|
-
Factory.addGetterSetter(Layer, 'clearBeforeDraw', true);
|
|
305
|
-
Factory.addGetterSetter(Layer, 'hitGraphEnabled', true, getBooleanValidator());
|
|
306
|
+
(0, Global_1._registerNode)(Layer);
|
|
307
|
+
Factory_1.Factory.addGetterSetter(Layer, 'imageSmoothingEnabled', true);
|
|
308
|
+
Factory_1.Factory.addGetterSetter(Layer, 'clearBeforeDraw', true);
|
|
309
|
+
Factory_1.Factory.addGetterSetter(Layer, 'hitGraphEnabled', true, (0, Validators_1.getBooleanValidator)());
|
package/lib/Node.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Transform } from './Util';
|
|
2
|
-
import { SceneCanvas, Canvas } from './Canvas';
|
|
3
|
-
import { Container } from './Container';
|
|
4
|
-
import { GetSet, Vector2d, IRect } from './types';
|
|
5
|
-
import { Stage } from './Stage';
|
|
6
|
-
import { Context } from './Context';
|
|
7
|
-
import { Shape } from './Shape';
|
|
8
|
-
import { Layer } from './Layer';
|
|
1
|
+
import { Transform } from './Util.js';
|
|
2
|
+
import { SceneCanvas, Canvas } from './Canvas.js';
|
|
3
|
+
import { Container } from './Container.js';
|
|
4
|
+
import { GetSet, Vector2d, IRect } from './types.js';
|
|
5
|
+
import { Stage } from './Stage.js';
|
|
6
|
+
import { Context } from './Context.js';
|
|
7
|
+
import { Shape } from './Shape.js';
|
|
8
|
+
import { Layer } from './Layer.js';
|
|
9
9
|
export type Filter = (this: Node, imageData: ImageData) => void;
|
|
10
10
|
type globalCompositeOperationType = '' | 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'lighter' | 'copy' | 'xor' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity';
|
|
11
11
|
export interface NodeConfig {
|