konva 8.4.3 → 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 -16989
- package/konva.min.js +3 -3
- package/lib/Animation.js +11 -7
- package/lib/BezierFunctions.d.ts +6 -0
- package/lib/BezierFunctions.js +791 -0
- package/lib/Canvas.d.ts +1 -0
- package/lib/Canvas.js +26 -18
- package/lib/Container.js +16 -12
- package/lib/Context.d.ts +3 -1
- package/lib/Context.js +18 -10
- package/lib/Core.js +7 -3
- package/lib/DragAndDrop.js +25 -22
- package/lib/Factory.js +27 -24
- package/lib/FastLayer.js +10 -6
- package/lib/Global.js +16 -12
- package/lib/Group.js +10 -6
- package/lib/Layer.js +37 -33
- package/lib/Node.js +95 -90
- package/lib/PointerEvents.js +15 -7
- package/lib/Shape.js +90 -86
- package/lib/Stage.js +51 -47
- package/lib/Tween.js +26 -22
- package/lib/Util.js +29 -25
- package/lib/Validators.js +58 -44
- package/lib/_CoreInternals.js +36 -33
- package/lib/_FullInternals.js +78 -75
- package/lib/filters/Blur.js +9 -5
- package/lib/filters/Brighten.js +9 -5
- package/lib/filters/Contrast.js +9 -5
- package/lib/filters/Emboss.js +14 -10
- package/lib/filters/Enhance.js +9 -5
- package/lib/filters/Grayscale.js +5 -1
- package/lib/filters/HSL.js +11 -7
- package/lib/filters/HSV.js +11 -7
- package/lib/filters/Invert.js +5 -1
- package/lib/filters/Kaleidoscope.js +13 -9
- package/lib/filters/Mask.js +9 -5
- package/lib/filters/Noise.js +9 -5
- package/lib/filters/Pixelate.js +11 -7
- package/lib/filters/Posterize.js +9 -5
- package/lib/filters/RGB.js +11 -7
- package/lib/filters/RGBA.js +12 -8
- package/lib/filters/Sepia.js +5 -1
- package/lib/filters/Solarize.js +5 -1
- package/lib/filters/Threshold.js +9 -5
- package/lib/index-node.js +7 -5
- package/lib/index.js +4 -2
- package/lib/shapes/Arc.js +17 -13
- package/lib/shapes/Arrow.js +17 -13
- package/lib/shapes/Circle.js +11 -7
- package/lib/shapes/Ellipse.js +13 -9
- package/lib/shapes/Image.js +21 -17
- package/lib/shapes/Label.js +18 -13
- package/lib/shapes/Line.js +14 -10
- package/lib/shapes/Path.d.ts +5 -2
- package/lib/shapes/Path.js +44 -43
- package/lib/shapes/Rect.js +13 -9
- package/lib/shapes/RegularPolygon.js +12 -8
- package/lib/shapes/Ring.js +12 -8
- package/lib/shapes/Sprite.js +19 -15
- package/lib/shapes/Star.js +13 -9
- package/lib/shapes/Text.js +31 -26
- package/lib/shapes/TextPath.d.ts +5 -1
- package/lib/shapes/TextPath.js +82 -188
- package/lib/shapes/Transformer.js +85 -81
- 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 -85
- 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 -186
- 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 -26
- package/cmj/shapes/Arc.js +0 -59
- package/cmj/shapes/Arrow.d.ts +0 -26
- package/cmj/shapes/Arrow.js +0 -103
- package/cmj/shapes/Circle.d.ts +0 -14
- package/cmj/shapes/Circle.js +0 -37
- package/cmj/shapes/Ellipse.d.ts +0 -17
- 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 -36
- 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 -23
- package/cmj/shapes/RegularPolygon.js +0 -69
- package/cmj/shapes/Ring.d.ts +0 -16
- package/cmj/shapes/Ring.js +0 -37
- package/cmj/shapes/Sprite.d.ts +0 -31
- package/cmj/shapes/Sprite.js +0 -112
- package/cmj/shapes/Star.d.ts +0 -18
- package/cmj/shapes/Star.js +0 -42
- package/cmj/shapes/Text.d.ts +0 -63
- package/cmj/shapes/Text.js +0 -373
- package/cmj/shapes/TextPath.d.ts +0 -56
- package/cmj/shapes/TextPath.js +0 -351
- package/cmj/shapes/Transformer.d.ts +0 -116
- package/cmj/shapes/Transformer.js +0 -971
- package/cmj/shapes/Wedge.d.ts +0 -18
- package/cmj/shapes/Wedge.js +0 -42
- package/cmj/types.d.ts +0 -50
- package/cmj/types.js +0 -25
package/cmj/Layer.js
DELETED
|
@@ -1,309 +0,0 @@
|
|
|
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");
|
|
12
|
-
var HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [
|
|
13
|
-
{ x: 0, y: 0 },
|
|
14
|
-
{ x: -1, y: -1 },
|
|
15
|
-
{ x: 1, y: -1 },
|
|
16
|
-
{ x: 1, y: 1 },
|
|
17
|
-
{ x: -1, y: 1 },
|
|
18
|
-
], INTERSECTION_OFFSETS_LEN = INTERSECTION_OFFSETS.length;
|
|
19
|
-
class Layer extends Container_1.Container {
|
|
20
|
-
constructor(config) {
|
|
21
|
-
super(config);
|
|
22
|
-
this.canvas = new Canvas_1.SceneCanvas();
|
|
23
|
-
this.hitCanvas = new Canvas_1.HitCanvas({
|
|
24
|
-
pixelRatio: 1,
|
|
25
|
-
});
|
|
26
|
-
this._waitingForDraw = false;
|
|
27
|
-
this.on('visibleChange.konva', this._checkVisibility);
|
|
28
|
-
this._checkVisibility();
|
|
29
|
-
this.on('imageSmoothingEnabledChange.konva', this._setSmoothEnabled);
|
|
30
|
-
this._setSmoothEnabled();
|
|
31
|
-
}
|
|
32
|
-
createPNGStream() {
|
|
33
|
-
const c = this.canvas._canvas;
|
|
34
|
-
return c.createPNGStream();
|
|
35
|
-
}
|
|
36
|
-
getCanvas() {
|
|
37
|
-
return this.canvas;
|
|
38
|
-
}
|
|
39
|
-
getNativeCanvasElement() {
|
|
40
|
-
return this.canvas._canvas;
|
|
41
|
-
}
|
|
42
|
-
getHitCanvas() {
|
|
43
|
-
return this.hitCanvas;
|
|
44
|
-
}
|
|
45
|
-
getContext() {
|
|
46
|
-
return this.getCanvas().getContext();
|
|
47
|
-
}
|
|
48
|
-
clear(bounds) {
|
|
49
|
-
this.getContext().clear(bounds);
|
|
50
|
-
this.getHitCanvas().getContext().clear(bounds);
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
setZIndex(index) {
|
|
54
|
-
super.setZIndex(index);
|
|
55
|
-
var stage = this.getStage();
|
|
56
|
-
if (stage && stage.content) {
|
|
57
|
-
stage.content.removeChild(this.getNativeCanvasElement());
|
|
58
|
-
if (index < stage.children.length - 1) {
|
|
59
|
-
stage.content.insertBefore(this.getNativeCanvasElement(), stage.children[index + 1].getCanvas()._canvas);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
stage.content.appendChild(this.getNativeCanvasElement());
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
moveToTop() {
|
|
68
|
-
Node_1.Node.prototype.moveToTop.call(this);
|
|
69
|
-
var stage = this.getStage();
|
|
70
|
-
if (stage && stage.content) {
|
|
71
|
-
stage.content.removeChild(this.getNativeCanvasElement());
|
|
72
|
-
stage.content.appendChild(this.getNativeCanvasElement());
|
|
73
|
-
}
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
moveUp() {
|
|
77
|
-
var moved = Node_1.Node.prototype.moveUp.call(this);
|
|
78
|
-
if (!moved) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
var stage = this.getStage();
|
|
82
|
-
if (!stage || !stage.content) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
stage.content.removeChild(this.getNativeCanvasElement());
|
|
86
|
-
if (this.index < stage.children.length - 1) {
|
|
87
|
-
stage.content.insertBefore(this.getNativeCanvasElement(), stage.children[this.index + 1].getCanvas()._canvas);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
stage.content.appendChild(this.getNativeCanvasElement());
|
|
91
|
-
}
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
moveDown() {
|
|
95
|
-
if (Node_1.Node.prototype.moveDown.call(this)) {
|
|
96
|
-
var stage = this.getStage();
|
|
97
|
-
if (stage) {
|
|
98
|
-
var children = stage.children;
|
|
99
|
-
if (stage.content) {
|
|
100
|
-
stage.content.removeChild(this.getNativeCanvasElement());
|
|
101
|
-
stage.content.insertBefore(this.getNativeCanvasElement(), children[this.index + 1].getCanvas()._canvas);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
moveToBottom() {
|
|
109
|
-
if (Node_1.Node.prototype.moveToBottom.call(this)) {
|
|
110
|
-
var stage = this.getStage();
|
|
111
|
-
if (stage) {
|
|
112
|
-
var children = stage.children;
|
|
113
|
-
if (stage.content) {
|
|
114
|
-
stage.content.removeChild(this.getNativeCanvasElement());
|
|
115
|
-
stage.content.insertBefore(this.getNativeCanvasElement(), children[1].getCanvas()._canvas);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
getLayer() {
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
remove() {
|
|
126
|
-
var _canvas = this.getNativeCanvasElement();
|
|
127
|
-
Node_1.Node.prototype.remove.call(this);
|
|
128
|
-
if (_canvas && _canvas.parentNode && Util_1.Util._isInDocument(_canvas)) {
|
|
129
|
-
_canvas.parentNode.removeChild(_canvas);
|
|
130
|
-
}
|
|
131
|
-
return this;
|
|
132
|
-
}
|
|
133
|
-
getStage() {
|
|
134
|
-
return this.parent;
|
|
135
|
-
}
|
|
136
|
-
setSize({ width, height }) {
|
|
137
|
-
this.canvas.setSize(width, height);
|
|
138
|
-
this.hitCanvas.setSize(width, height);
|
|
139
|
-
this._setSmoothEnabled();
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
142
|
-
_validateAdd(child) {
|
|
143
|
-
var type = child.getType();
|
|
144
|
-
if (type !== 'Group' && type !== 'Shape') {
|
|
145
|
-
Util_1.Util.throw('You may only add groups and shapes to a layer.');
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
_toKonvaCanvas(config) {
|
|
149
|
-
config = config || {};
|
|
150
|
-
config.width = config.width || this.getWidth();
|
|
151
|
-
config.height = config.height || this.getHeight();
|
|
152
|
-
config.x = config.x !== undefined ? config.x : this.x();
|
|
153
|
-
config.y = config.y !== undefined ? config.y : this.y();
|
|
154
|
-
return Node_1.Node.prototype._toKonvaCanvas.call(this, config);
|
|
155
|
-
}
|
|
156
|
-
_checkVisibility() {
|
|
157
|
-
const visible = this.visible();
|
|
158
|
-
if (visible) {
|
|
159
|
-
this.canvas._canvas.style.display = 'block';
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
this.canvas._canvas.style.display = 'none';
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
_setSmoothEnabled() {
|
|
166
|
-
this.getContext()._context.imageSmoothingEnabled =
|
|
167
|
-
this.imageSmoothingEnabled();
|
|
168
|
-
}
|
|
169
|
-
getWidth() {
|
|
170
|
-
if (this.parent) {
|
|
171
|
-
return this.parent.width();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
setWidth() {
|
|
175
|
-
Util_1.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.');
|
|
176
|
-
}
|
|
177
|
-
getHeight() {
|
|
178
|
-
if (this.parent) {
|
|
179
|
-
return this.parent.height();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
setHeight() {
|
|
183
|
-
Util_1.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.');
|
|
184
|
-
}
|
|
185
|
-
batchDraw() {
|
|
186
|
-
if (!this._waitingForDraw) {
|
|
187
|
-
this._waitingForDraw = true;
|
|
188
|
-
Util_1.Util.requestAnimFrame(() => {
|
|
189
|
-
this.draw();
|
|
190
|
-
this._waitingForDraw = false;
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
return this;
|
|
194
|
-
}
|
|
195
|
-
getIntersection(pos) {
|
|
196
|
-
if (!this.isListening() || !this.isVisible()) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
var spiralSearchDistance = 1;
|
|
200
|
-
var continueSearch = false;
|
|
201
|
-
while (true) {
|
|
202
|
-
for (let i = 0; i < INTERSECTION_OFFSETS_LEN; i++) {
|
|
203
|
-
const intersectionOffset = INTERSECTION_OFFSETS[i];
|
|
204
|
-
const obj = this._getIntersection({
|
|
205
|
-
x: pos.x + intersectionOffset.x * spiralSearchDistance,
|
|
206
|
-
y: pos.y + intersectionOffset.y * spiralSearchDistance,
|
|
207
|
-
});
|
|
208
|
-
const shape = obj.shape;
|
|
209
|
-
if (shape) {
|
|
210
|
-
return shape;
|
|
211
|
-
}
|
|
212
|
-
continueSearch = !!obj.antialiased;
|
|
213
|
-
if (!obj.antialiased) {
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (continueSearch) {
|
|
218
|
-
spiralSearchDistance += 1;
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
_getIntersection(pos) {
|
|
226
|
-
const ratio = this.hitCanvas.pixelRatio;
|
|
227
|
-
const p = this.hitCanvas.context.getImageData(Math.round(pos.x * ratio), Math.round(pos.y * ratio), 1, 1).data;
|
|
228
|
-
const p3 = p[3];
|
|
229
|
-
if (p3 === 255) {
|
|
230
|
-
const colorKey = Util_1.Util._rgbToHex(p[0], p[1], p[2]);
|
|
231
|
-
const shape = Shape_1.shapes[HASH + colorKey];
|
|
232
|
-
if (shape) {
|
|
233
|
-
return {
|
|
234
|
-
shape: shape,
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
return {
|
|
238
|
-
antialiased: true,
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
else if (p3 > 0) {
|
|
242
|
-
return {
|
|
243
|
-
antialiased: true,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
return {};
|
|
247
|
-
}
|
|
248
|
-
drawScene(can, top) {
|
|
249
|
-
var layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());
|
|
250
|
-
this._fire(BEFORE_DRAW, {
|
|
251
|
-
node: this,
|
|
252
|
-
});
|
|
253
|
-
if (this.clearBeforeDraw()) {
|
|
254
|
-
canvas.getContext().clear();
|
|
255
|
-
}
|
|
256
|
-
Container_1.Container.prototype.drawScene.call(this, canvas, top);
|
|
257
|
-
this._fire(DRAW, {
|
|
258
|
-
node: this,
|
|
259
|
-
});
|
|
260
|
-
return this;
|
|
261
|
-
}
|
|
262
|
-
drawHit(can, top) {
|
|
263
|
-
var layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas);
|
|
264
|
-
if (layer && layer.clearBeforeDraw()) {
|
|
265
|
-
layer.getHitCanvas().getContext().clear();
|
|
266
|
-
}
|
|
267
|
-
Container_1.Container.prototype.drawHit.call(this, canvas, top);
|
|
268
|
-
return this;
|
|
269
|
-
}
|
|
270
|
-
enableHitGraph() {
|
|
271
|
-
this.hitGraphEnabled(true);
|
|
272
|
-
return this;
|
|
273
|
-
}
|
|
274
|
-
disableHitGraph() {
|
|
275
|
-
this.hitGraphEnabled(false);
|
|
276
|
-
return this;
|
|
277
|
-
}
|
|
278
|
-
setHitGraphEnabled(val) {
|
|
279
|
-
Util_1.Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
|
|
280
|
-
this.listening(val);
|
|
281
|
-
}
|
|
282
|
-
getHitGraphEnabled(val) {
|
|
283
|
-
Util_1.Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
|
|
284
|
-
return this.listening();
|
|
285
|
-
}
|
|
286
|
-
toggleHitCanvas() {
|
|
287
|
-
if (!this.parent || !this.parent['content']) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
var parent = this.parent;
|
|
291
|
-
var added = !!this.hitCanvas._canvas.parentNode;
|
|
292
|
-
if (added) {
|
|
293
|
-
parent.content.removeChild(this.hitCanvas._canvas);
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
parent.content.appendChild(this.hitCanvas._canvas);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
destroy() {
|
|
300
|
-
Util_1.Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas);
|
|
301
|
-
return super.destroy();
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
exports.Layer = Layer;
|
|
305
|
-
Layer.prototype.nodeType = 'Layer';
|
|
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/cmj/Node.d.ts
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
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';
|
|
9
|
-
export type Filter = (this: Node, imageData: ImageData) => void;
|
|
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
|
-
export interface NodeConfig {
|
|
12
|
-
[index: string]: any;
|
|
13
|
-
x?: number;
|
|
14
|
-
y?: number;
|
|
15
|
-
width?: number;
|
|
16
|
-
height?: number;
|
|
17
|
-
visible?: boolean;
|
|
18
|
-
listening?: boolean;
|
|
19
|
-
id?: string;
|
|
20
|
-
name?: string;
|
|
21
|
-
opacity?: number;
|
|
22
|
-
scale?: Vector2d;
|
|
23
|
-
scaleX?: number;
|
|
24
|
-
scaleY?: number;
|
|
25
|
-
rotation?: number;
|
|
26
|
-
rotationDeg?: number;
|
|
27
|
-
offset?: Vector2d;
|
|
28
|
-
offsetX?: number;
|
|
29
|
-
offsetY?: number;
|
|
30
|
-
draggable?: boolean;
|
|
31
|
-
dragDistance?: number;
|
|
32
|
-
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
|
|
33
|
-
preventDefault?: boolean;
|
|
34
|
-
globalCompositeOperation?: globalCompositeOperationType;
|
|
35
|
-
filters?: Array<Filter>;
|
|
36
|
-
}
|
|
37
|
-
type NodeEventMap = GlobalEventHandlersEventMap & {
|
|
38
|
-
[index: string]: any;
|
|
39
|
-
};
|
|
40
|
-
export interface KonvaEventObject<EventType> {
|
|
41
|
-
type: string;
|
|
42
|
-
target: Shape | Stage;
|
|
43
|
-
evt: EventType;
|
|
44
|
-
currentTarget: Node;
|
|
45
|
-
cancelBubble: boolean;
|
|
46
|
-
child?: Node;
|
|
47
|
-
}
|
|
48
|
-
export type KonvaEventListener<This, EventType> = (this: This, ev: KonvaEventObject<EventType>) => void;
|
|
49
|
-
export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
50
|
-
_id: number;
|
|
51
|
-
eventListeners: {
|
|
52
|
-
[index: string]: Array<{
|
|
53
|
-
name: string;
|
|
54
|
-
handler: Function;
|
|
55
|
-
}>;
|
|
56
|
-
};
|
|
57
|
-
attrs: any;
|
|
58
|
-
index: number;
|
|
59
|
-
_allEventListeners: null | Array<Function>;
|
|
60
|
-
parent: Container<Node> | null;
|
|
61
|
-
_cache: Map<string, any>;
|
|
62
|
-
_attachedDepsListeners: Map<string, boolean>;
|
|
63
|
-
_lastPos: Vector2d;
|
|
64
|
-
_attrsAffectingSize: string[];
|
|
65
|
-
_batchingTransformChange: boolean;
|
|
66
|
-
_needClearTransformCache: boolean;
|
|
67
|
-
_filterUpToDate: boolean;
|
|
68
|
-
_isUnderCache: boolean;
|
|
69
|
-
nodeType: string;
|
|
70
|
-
className: string;
|
|
71
|
-
_dragEventId: number | null;
|
|
72
|
-
_shouldFireChangeEvents: boolean;
|
|
73
|
-
constructor(config?: Config);
|
|
74
|
-
hasChildren(): boolean;
|
|
75
|
-
_clearCache(attr?: string): void;
|
|
76
|
-
_getCache(attr: string, privateGetter: Function): any;
|
|
77
|
-
_calculate(name: string, deps: Array<string>, getter: Function): any;
|
|
78
|
-
_getCanvasCache(): any;
|
|
79
|
-
_clearSelfAndDescendantCache(attr?: string): void;
|
|
80
|
-
clearCache(): this;
|
|
81
|
-
cache(config?: {
|
|
82
|
-
x?: number;
|
|
83
|
-
y?: number;
|
|
84
|
-
width?: number;
|
|
85
|
-
height?: number;
|
|
86
|
-
drawBorder?: boolean;
|
|
87
|
-
offset?: number;
|
|
88
|
-
pixelRatio?: number;
|
|
89
|
-
imageSmoothingEnabled?: boolean;
|
|
90
|
-
hitCanvasPixelRatio?: number;
|
|
91
|
-
}): this;
|
|
92
|
-
isCached(): boolean;
|
|
93
|
-
abstract drawScene(canvas?: Canvas, top?: Node): void;
|
|
94
|
-
abstract drawHit(canvas?: Canvas, top?: Node): void;
|
|
95
|
-
getClientRect(config?: {
|
|
96
|
-
skipTransform?: boolean;
|
|
97
|
-
skipShadow?: boolean;
|
|
98
|
-
skipStroke?: boolean;
|
|
99
|
-
relativeTo?: Container<Node>;
|
|
100
|
-
}): {
|
|
101
|
-
x: number;
|
|
102
|
-
y: number;
|
|
103
|
-
width: number;
|
|
104
|
-
height: number;
|
|
105
|
-
};
|
|
106
|
-
_transformedRect(rect: IRect, top: Node): {
|
|
107
|
-
x: number;
|
|
108
|
-
y: number;
|
|
109
|
-
width: number;
|
|
110
|
-
height: number;
|
|
111
|
-
};
|
|
112
|
-
_drawCachedSceneCanvas(context: Context): void;
|
|
113
|
-
_drawCachedHitCanvas(context: Context): void;
|
|
114
|
-
_getCachedSceneCanvas(): any;
|
|
115
|
-
on<K extends keyof NodeEventMap>(evtStr: K, handler: KonvaEventListener<this, NodeEventMap[K]>): any;
|
|
116
|
-
off(evtStr?: string, callback?: Function): this;
|
|
117
|
-
dispatchEvent(evt: any): this;
|
|
118
|
-
addEventListener(type: string, handler: (e: Event) => void): this;
|
|
119
|
-
removeEventListener(type: string): this;
|
|
120
|
-
_delegate(event: string, selector: string, handler: (e: Event) => void): void;
|
|
121
|
-
remove(): this;
|
|
122
|
-
_clearCaches(): void;
|
|
123
|
-
_remove(): void;
|
|
124
|
-
destroy(): this;
|
|
125
|
-
getAttr(attr: string): any;
|
|
126
|
-
getAncestors(): Node<NodeConfig>[];
|
|
127
|
-
getAttrs(): any;
|
|
128
|
-
setAttrs(config: any): this;
|
|
129
|
-
isListening(): any;
|
|
130
|
-
_isListening(relativeTo?: Node): boolean;
|
|
131
|
-
isVisible(): any;
|
|
132
|
-
_isVisible(relativeTo?: Node): boolean;
|
|
133
|
-
shouldDrawHit(top?: Node, skipDragCheck?: boolean): boolean;
|
|
134
|
-
show(): this;
|
|
135
|
-
hide(): this;
|
|
136
|
-
getZIndex(): number;
|
|
137
|
-
getAbsoluteZIndex(): number;
|
|
138
|
-
getDepth(): number;
|
|
139
|
-
_batchTransformChanges(func: any): void;
|
|
140
|
-
setPosition(pos: Vector2d): this;
|
|
141
|
-
getPosition(): {
|
|
142
|
-
x: number;
|
|
143
|
-
y: number;
|
|
144
|
-
};
|
|
145
|
-
getRelativePointerPosition(): {
|
|
146
|
-
x: number;
|
|
147
|
-
y: number;
|
|
148
|
-
};
|
|
149
|
-
getAbsolutePosition(top?: Node): {
|
|
150
|
-
x: number;
|
|
151
|
-
y: number;
|
|
152
|
-
};
|
|
153
|
-
setAbsolutePosition(pos: Vector2d): this;
|
|
154
|
-
_setTransform(trans: any): void;
|
|
155
|
-
_clearTransform(): {
|
|
156
|
-
x: number;
|
|
157
|
-
y: number;
|
|
158
|
-
rotation: number;
|
|
159
|
-
scaleX: number;
|
|
160
|
-
scaleY: number;
|
|
161
|
-
offsetX: number;
|
|
162
|
-
offsetY: number;
|
|
163
|
-
skewX: number;
|
|
164
|
-
skewY: number;
|
|
165
|
-
};
|
|
166
|
-
move(change: Vector2d): this;
|
|
167
|
-
_eachAncestorReverse(func: any, top: any): void;
|
|
168
|
-
rotate(theta: number): this;
|
|
169
|
-
moveToTop(): boolean;
|
|
170
|
-
moveUp(): boolean;
|
|
171
|
-
moveDown(): boolean;
|
|
172
|
-
moveToBottom(): boolean;
|
|
173
|
-
setZIndex(zIndex: any): this;
|
|
174
|
-
getAbsoluteOpacity(): any;
|
|
175
|
-
_getAbsoluteOpacity(): number;
|
|
176
|
-
moveTo(newContainer: any): this;
|
|
177
|
-
toObject(): any;
|
|
178
|
-
toJSON(): string;
|
|
179
|
-
getParent(): Container<Node<NodeConfig>>;
|
|
180
|
-
findAncestors(selector: string, includeSelf?: boolean, stopNode?: Node): Node<NodeConfig>[];
|
|
181
|
-
isAncestorOf(node: Node): boolean;
|
|
182
|
-
findAncestor(selector?: string, includeSelf?: boolean, stopNode?: Container): any;
|
|
183
|
-
_isMatch(selector: string | Function): any;
|
|
184
|
-
getLayer(): Layer | null;
|
|
185
|
-
getStage(): Stage | null;
|
|
186
|
-
_getStage(): Stage | undefined;
|
|
187
|
-
fire(eventType: string, evt?: any, bubble?: boolean): this;
|
|
188
|
-
getAbsoluteTransform(top?: Node): Transform;
|
|
189
|
-
_getAbsoluteTransform(top?: Node): Transform;
|
|
190
|
-
getAbsoluteScale(top?: Node): {
|
|
191
|
-
x: number;
|
|
192
|
-
y: number;
|
|
193
|
-
};
|
|
194
|
-
getAbsoluteRotation(): number;
|
|
195
|
-
getTransform(): Transform;
|
|
196
|
-
_getTransform(): Transform;
|
|
197
|
-
clone(obj?: any): any;
|
|
198
|
-
_toKonvaCanvas(config: any): SceneCanvas;
|
|
199
|
-
toCanvas(config?: any): HTMLCanvasElement;
|
|
200
|
-
toDataURL(config?: {
|
|
201
|
-
x?: number;
|
|
202
|
-
y?: number;
|
|
203
|
-
width?: number;
|
|
204
|
-
height?: number;
|
|
205
|
-
pixelRatio?: number;
|
|
206
|
-
mimeType?: string;
|
|
207
|
-
quality?: number;
|
|
208
|
-
callback?: (str: string) => void;
|
|
209
|
-
}): string;
|
|
210
|
-
toImage(config?: {
|
|
211
|
-
x?: number;
|
|
212
|
-
y?: number;
|
|
213
|
-
width?: number;
|
|
214
|
-
height?: number;
|
|
215
|
-
pixelRatio?: number;
|
|
216
|
-
mimeType?: string;
|
|
217
|
-
quality?: number;
|
|
218
|
-
callback?: (img: HTMLImageElement) => void;
|
|
219
|
-
}): Promise<unknown>;
|
|
220
|
-
toBlob(config?: {
|
|
221
|
-
x?: number;
|
|
222
|
-
y?: number;
|
|
223
|
-
width?: number;
|
|
224
|
-
height?: number;
|
|
225
|
-
pixelRatio?: number;
|
|
226
|
-
mimeType?: string;
|
|
227
|
-
quality?: number;
|
|
228
|
-
callback?: (blob: Blob) => void;
|
|
229
|
-
}): Promise<unknown>;
|
|
230
|
-
setSize(size: any): this;
|
|
231
|
-
getSize(): {
|
|
232
|
-
width: number;
|
|
233
|
-
height: number;
|
|
234
|
-
};
|
|
235
|
-
getClassName(): string;
|
|
236
|
-
getType(): string;
|
|
237
|
-
getDragDistance(): number;
|
|
238
|
-
_off(type: any, name?: any, callback?: any): void;
|
|
239
|
-
_fireChangeEvent(attr: any, oldVal: any, newVal: any): void;
|
|
240
|
-
addName(name: any): this;
|
|
241
|
-
hasName(name: any): boolean;
|
|
242
|
-
removeName(name: any): this;
|
|
243
|
-
setAttr(attr: any, val: any): this;
|
|
244
|
-
_requestDraw(): void;
|
|
245
|
-
_setAttr(key: any, val: any): void;
|
|
246
|
-
_setComponentAttr(key: any, component: any, val: any): void;
|
|
247
|
-
_fireAndBubble(eventType: any, evt: any, compareShape?: any): void;
|
|
248
|
-
_getProtoListeners(eventType: any): any;
|
|
249
|
-
_fire(eventType: any, evt: any): void;
|
|
250
|
-
draw(): this;
|
|
251
|
-
_createDragElement(evt: any): void;
|
|
252
|
-
startDrag(evt?: any, bubbleEvent?: boolean): void;
|
|
253
|
-
_setDragPosition(evt: any, elem: any): void;
|
|
254
|
-
stopDrag(evt?: any): void;
|
|
255
|
-
setDraggable(draggable: any): void;
|
|
256
|
-
isDragging(): boolean;
|
|
257
|
-
_listenDrag(): void;
|
|
258
|
-
_dragChange(): void;
|
|
259
|
-
_dragCleanup(): void;
|
|
260
|
-
isClientRectOnScreen(margin?: {
|
|
261
|
-
x: number;
|
|
262
|
-
y: number;
|
|
263
|
-
}): boolean;
|
|
264
|
-
preventDefault: GetSet<boolean, this>;
|
|
265
|
-
blue: GetSet<number, this>;
|
|
266
|
-
brightness: GetSet<number, this>;
|
|
267
|
-
contrast: GetSet<number, this>;
|
|
268
|
-
blurRadius: GetSet<number, this>;
|
|
269
|
-
luminance: GetSet<number, this>;
|
|
270
|
-
green: GetSet<number, this>;
|
|
271
|
-
alpha: GetSet<number, this>;
|
|
272
|
-
hue: GetSet<number, this>;
|
|
273
|
-
kaleidoscopeAngle: GetSet<number, this>;
|
|
274
|
-
kaleidoscopePower: GetSet<number, this>;
|
|
275
|
-
levels: GetSet<number, this>;
|
|
276
|
-
noise: GetSet<number, this>;
|
|
277
|
-
pixelSize: GetSet<number, this>;
|
|
278
|
-
red: GetSet<number, this>;
|
|
279
|
-
saturation: GetSet<number, this>;
|
|
280
|
-
threshold: GetSet<number, this>;
|
|
281
|
-
value: GetSet<number, this>;
|
|
282
|
-
dragBoundFunc: GetSet<(this: Node, pos: Vector2d) => Vector2d, this>;
|
|
283
|
-
draggable: GetSet<boolean, this>;
|
|
284
|
-
dragDistance: GetSet<number, this>;
|
|
285
|
-
embossBlend: GetSet<boolean, this>;
|
|
286
|
-
embossDirection: GetSet<string, this>;
|
|
287
|
-
embossStrength: GetSet<number, this>;
|
|
288
|
-
embossWhiteLevel: GetSet<number, this>;
|
|
289
|
-
enhance: GetSet<number, this>;
|
|
290
|
-
filters: GetSet<Filter[], this>;
|
|
291
|
-
position: GetSet<Vector2d, this>;
|
|
292
|
-
absolutePosition: GetSet<Vector2d, this>;
|
|
293
|
-
size: GetSet<{
|
|
294
|
-
width: number;
|
|
295
|
-
height: number;
|
|
296
|
-
}, this>;
|
|
297
|
-
id: GetSet<string, this>;
|
|
298
|
-
listening: GetSet<boolean, this>;
|
|
299
|
-
name: GetSet<string, this>;
|
|
300
|
-
offset: GetSet<Vector2d, this>;
|
|
301
|
-
offsetX: GetSet<number, this>;
|
|
302
|
-
offsetY: GetSet<number, this>;
|
|
303
|
-
opacity: GetSet<number, this>;
|
|
304
|
-
rotation: GetSet<number, this>;
|
|
305
|
-
zIndex: GetSet<number, this>;
|
|
306
|
-
scale: GetSet<Vector2d | undefined, this>;
|
|
307
|
-
scaleX: GetSet<number, this>;
|
|
308
|
-
scaleY: GetSet<number, this>;
|
|
309
|
-
skew: GetSet<Vector2d, this>;
|
|
310
|
-
skewX: GetSet<number, this>;
|
|
311
|
-
skewY: GetSet<number, this>;
|
|
312
|
-
to: (params: AnimTo) => void;
|
|
313
|
-
transformsEnabled: GetSet<string, this>;
|
|
314
|
-
visible: GetSet<boolean, this>;
|
|
315
|
-
width: GetSet<number, this>;
|
|
316
|
-
height: GetSet<number, this>;
|
|
317
|
-
x: GetSet<number, this>;
|
|
318
|
-
y: GetSet<number, this>;
|
|
319
|
-
globalCompositeOperation: GetSet<globalCompositeOperationType, this>;
|
|
320
|
-
static create(data: any, container?: any): any;
|
|
321
|
-
static _createNode(obj: any, container?: any): any;
|
|
322
|
-
}
|
|
323
|
-
interface AnimTo extends NodeConfig {
|
|
324
|
-
onFinish?: Function;
|
|
325
|
-
onUpdate?: Function;
|
|
326
|
-
duration?: number;
|
|
327
|
-
}
|
|
328
|
-
export {};
|