konva 10.0.9 → 10.0.10

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.
Files changed (127) hide show
  1. package/konva.js +90 -44
  2. package/konva.min.js +4 -4
  3. package/package.json +1 -1
  4. package/lib/Animation.d.ts +0 -24
  5. package/lib/Animation.js +0 -142
  6. package/lib/BezierFunctions.d.ts +0 -6
  7. package/lib/BezierFunctions.js +0 -784
  8. package/lib/Canvas.d.ts +0 -33
  9. package/lib/Canvas.js +0 -137
  10. package/lib/Container.d.ts +0 -54
  11. package/lib/Container.js +0 -316
  12. package/lib/Context.d.ts +0 -95
  13. package/lib/Context.js +0 -561
  14. package/lib/Core.d.ts +0 -3
  15. package/lib/Core.js +0 -3
  16. package/lib/DragAndDrop.d.ts +0 -17
  17. package/lib/DragAndDrop.js +0 -110
  18. package/lib/Factory.d.ts +0 -22
  19. package/lib/Factory.js +0 -123
  20. package/lib/FastLayer.d.ts +0 -4
  21. package/lib/FastLayer.js +0 -12
  22. package/lib/Global.d.ts +0 -37
  23. package/lib/Global.js +0 -66
  24. package/lib/Group.d.ts +0 -9
  25. package/lib/Group.js +0 -13
  26. package/lib/Layer.d.ts +0 -62
  27. package/lib/Layer.js +0 -305
  28. package/lib/Node.d.ts +0 -323
  29. package/lib/Node.js +0 -1532
  30. package/lib/PointerEvents.d.ts +0 -11
  31. package/lib/PointerEvents.js +0 -37
  32. package/lib/Shape.d.ts +0 -196
  33. package/lib/Shape.js +0 -548
  34. package/lib/Stage.d.ts +0 -86
  35. package/lib/Stage.js +0 -715
  36. package/lib/Tween.d.ts +0 -90
  37. package/lib/Tween.js +0 -531
  38. package/lib/Util.d.ts +0 -133
  39. package/lib/Util.js +0 -866
  40. package/lib/Validators.d.ts +0 -11
  41. package/lib/Validators.js +0 -178
  42. package/lib/_CoreInternals.d.ts +0 -220
  43. package/lib/_CoreInternals.js +0 -34
  44. package/lib/_FullInternals.d.ts +0 -302
  45. package/lib/_FullInternals.js +0 -80
  46. package/lib/canvas-backend.d.ts +0 -2
  47. package/lib/canvas-backend.js +0 -27
  48. package/lib/filters/Blur.d.ts +0 -2
  49. package/lib/filters/Blur.js +0 -235
  50. package/lib/filters/Brighten.d.ts +0 -2
  51. package/lib/filters/Brighten.js +0 -12
  52. package/lib/filters/Brightness.d.ts +0 -2
  53. package/lib/filters/Brightness.js +0 -8
  54. package/lib/filters/Contrast.d.ts +0 -2
  55. package/lib/filters/Contrast.js +0 -35
  56. package/lib/filters/Emboss.d.ts +0 -2
  57. package/lib/filters/Emboss.js +0 -101
  58. package/lib/filters/Enhance.d.ts +0 -2
  59. package/lib/filters/Enhance.js +0 -84
  60. package/lib/filters/Grayscale.d.ts +0 -2
  61. package/lib/filters/Grayscale.js +0 -9
  62. package/lib/filters/HSL.d.ts +0 -2
  63. package/lib/filters/HSL.js +0 -24
  64. package/lib/filters/HSV.d.ts +0 -2
  65. package/lib/filters/HSV.js +0 -23
  66. package/lib/filters/Invert.d.ts +0 -2
  67. package/lib/filters/Invert.js +0 -8
  68. package/lib/filters/Kaleidoscope.d.ts +0 -2
  69. package/lib/filters/Kaleidoscope.js +0 -133
  70. package/lib/filters/Mask.d.ts +0 -2
  71. package/lib/filters/Mask.js +0 -151
  72. package/lib/filters/Noise.d.ts +0 -2
  73. package/lib/filters/Noise.js +0 -12
  74. package/lib/filters/Pixelate.d.ts +0 -2
  75. package/lib/filters/Pixelate.js +0 -60
  76. package/lib/filters/Posterize.d.ts +0 -2
  77. package/lib/filters/Posterize.js +0 -10
  78. package/lib/filters/RGB.d.ts +0 -2
  79. package/lib/filters/RGB.js +0 -38
  80. package/lib/filters/RGBA.d.ts +0 -2
  81. package/lib/filters/RGBA.js +0 -49
  82. package/lib/filters/Sepia.d.ts +0 -2
  83. package/lib/filters/Sepia.js +0 -11
  84. package/lib/filters/Solarize.d.ts +0 -2
  85. package/lib/filters/Solarize.js +0 -14
  86. package/lib/filters/Threshold.d.ts +0 -2
  87. package/lib/filters/Threshold.js +0 -10
  88. package/lib/index.d.ts +0 -2
  89. package/lib/index.js +0 -2
  90. package/lib/shapes/Arc.d.ts +0 -27
  91. package/lib/shapes/Arc.js +0 -60
  92. package/lib/shapes/Arrow.d.ts +0 -27
  93. package/lib/shapes/Arrow.js +0 -99
  94. package/lib/shapes/Circle.d.ts +0 -15
  95. package/lib/shapes/Circle.js +0 -33
  96. package/lib/shapes/Ellipse.d.ts +0 -18
  97. package/lib/shapes/Ellipse.js +0 -37
  98. package/lib/shapes/Image.d.ts +0 -29
  99. package/lib/shapes/Image.js +0 -131
  100. package/lib/shapes/Label.d.ts +0 -39
  101. package/lib/shapes/Label.js +0 -173
  102. package/lib/shapes/Line.d.ts +0 -29
  103. package/lib/shapes/Line.js +0 -156
  104. package/lib/shapes/Path.d.ts +0 -50
  105. package/lib/shapes/Path.js +0 -670
  106. package/lib/shapes/Rect.d.ts +0 -11
  107. package/lib/shapes/Rect.js +0 -22
  108. package/lib/shapes/RegularPolygon.d.ts +0 -26
  109. package/lib/shapes/RegularPolygon.js +0 -72
  110. package/lib/shapes/Ring.d.ts +0 -17
  111. package/lib/shapes/Ring.js +0 -33
  112. package/lib/shapes/Sprite.d.ts +0 -32
  113. package/lib/shapes/Sprite.js +0 -108
  114. package/lib/shapes/Star.d.ts +0 -19
  115. package/lib/shapes/Star.js +0 -38
  116. package/lib/shapes/Text.d.ts +0 -90
  117. package/lib/shapes/Text.js +0 -461
  118. package/lib/shapes/TextPath.d.ts +0 -72
  119. package/lib/shapes/TextPath.js +0 -268
  120. package/lib/shapes/Transformer.d.ts +0 -130
  121. package/lib/shapes/Transformer.js +0 -1009
  122. package/lib/shapes/Wedge.d.ts +0 -19
  123. package/lib/shapes/Wedge.js +0 -38
  124. package/lib/skia-backend.d.ts +0 -2
  125. package/lib/skia-backend.js +0 -24
  126. package/lib/types.d.ts +0 -56
  127. package/lib/types.js +0 -21
package/lib/Shape.js DELETED
@@ -1,548 +0,0 @@
1
- import { Konva } from "./Global.js";
2
- import { Transform, Util } from "./Util.js";
3
- import { Factory } from "./Factory.js";
4
- import { Node } from "./Node.js";
5
- import { getNumberValidator, getNumberOrAutoValidator, getStringValidator, getBooleanValidator, getStringOrGradientValidator, } from "./Validators.js";
6
- import { _registerNode } from "./Global.js";
7
- import * as PointerEvents from "./PointerEvents.js";
8
- const HAS_SHADOW = 'hasShadow';
9
- const SHADOW_RGBA = 'shadowRGBA';
10
- const patternImage = 'patternImage';
11
- const linearGradient = 'linearGradient';
12
- const radialGradient = 'radialGradient';
13
- let dummyContext;
14
- function getDummyContext() {
15
- if (dummyContext) {
16
- return dummyContext;
17
- }
18
- dummyContext = Util.createCanvasElement().getContext('2d');
19
- return dummyContext;
20
- }
21
- export const shapes = {};
22
- function _fillFunc(context) {
23
- const fillRule = this.attrs.fillRule;
24
- if (fillRule) {
25
- context.fill(fillRule);
26
- }
27
- else {
28
- context.fill();
29
- }
30
- }
31
- function _strokeFunc(context) {
32
- context.stroke();
33
- }
34
- function _fillFuncHit(context) {
35
- const fillRule = this.attrs.fillRule;
36
- if (fillRule) {
37
- context.fill(fillRule);
38
- }
39
- else {
40
- context.fill();
41
- }
42
- }
43
- function _strokeFuncHit(context) {
44
- context.stroke();
45
- }
46
- function _clearHasShadowCache() {
47
- this._clearCache(HAS_SHADOW);
48
- }
49
- function _clearGetShadowRGBACache() {
50
- this._clearCache(SHADOW_RGBA);
51
- }
52
- function _clearFillPatternCache() {
53
- this._clearCache(patternImage);
54
- }
55
- function _clearLinearGradientCache() {
56
- this._clearCache(linearGradient);
57
- }
58
- function _clearRadialGradientCache() {
59
- this._clearCache(radialGradient);
60
- }
61
- export class Shape extends Node {
62
- constructor(config) {
63
- super(config);
64
- let key;
65
- while (true) {
66
- key = Util.getRandomColor();
67
- if (key && !(key in shapes)) {
68
- break;
69
- }
70
- }
71
- this.colorKey = key;
72
- shapes[key] = this;
73
- }
74
- getContext() {
75
- Util.warn('shape.getContext() method is deprecated. Please do not use it.');
76
- return this.getLayer().getContext();
77
- }
78
- getCanvas() {
79
- Util.warn('shape.getCanvas() method is deprecated. Please do not use it.');
80
- return this.getLayer().getCanvas();
81
- }
82
- getSceneFunc() {
83
- return this.attrs.sceneFunc || this['_sceneFunc'];
84
- }
85
- getHitFunc() {
86
- return this.attrs.hitFunc || this['_hitFunc'];
87
- }
88
- hasShadow() {
89
- return this._getCache(HAS_SHADOW, this._hasShadow);
90
- }
91
- _hasShadow() {
92
- return (this.shadowEnabled() &&
93
- this.shadowOpacity() !== 0 &&
94
- !!(this.shadowColor() ||
95
- this.shadowBlur() ||
96
- this.shadowOffsetX() ||
97
- this.shadowOffsetY()));
98
- }
99
- _getFillPattern() {
100
- return this._getCache(patternImage, this.__getFillPattern);
101
- }
102
- __getFillPattern() {
103
- if (this.fillPatternImage()) {
104
- const ctx = getDummyContext();
105
- const pattern = ctx.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || 'repeat');
106
- if (pattern && pattern.setTransform) {
107
- const tr = new Transform();
108
- tr.translate(this.fillPatternX(), this.fillPatternY());
109
- tr.rotate(Konva.getAngle(this.fillPatternRotation()));
110
- tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());
111
- tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
112
- const m = tr.getMatrix();
113
- const matrix = typeof DOMMatrix === 'undefined'
114
- ? {
115
- a: m[0],
116
- b: m[1],
117
- c: m[2],
118
- d: m[3],
119
- e: m[4],
120
- f: m[5],
121
- }
122
- : new DOMMatrix(m);
123
- pattern.setTransform(matrix);
124
- }
125
- return pattern;
126
- }
127
- }
128
- _getLinearGradient() {
129
- return this._getCache(linearGradient, this.__getLinearGradient);
130
- }
131
- __getLinearGradient() {
132
- const colorStops = this.fillLinearGradientColorStops();
133
- if (colorStops) {
134
- const ctx = getDummyContext();
135
- const start = this.fillLinearGradientStartPoint();
136
- const end = this.fillLinearGradientEndPoint();
137
- const grd = ctx.createLinearGradient(start.x, start.y, end.x, end.y);
138
- for (let n = 0; n < colorStops.length; n += 2) {
139
- grd.addColorStop(colorStops[n], colorStops[n + 1]);
140
- }
141
- return grd;
142
- }
143
- }
144
- _getRadialGradient() {
145
- return this._getCache(radialGradient, this.__getRadialGradient);
146
- }
147
- __getRadialGradient() {
148
- const colorStops = this.fillRadialGradientColorStops();
149
- if (colorStops) {
150
- const ctx = getDummyContext();
151
- const start = this.fillRadialGradientStartPoint();
152
- const end = this.fillRadialGradientEndPoint();
153
- const grd = ctx.createRadialGradient(start.x, start.y, this.fillRadialGradientStartRadius(), end.x, end.y, this.fillRadialGradientEndRadius());
154
- for (let n = 0; n < colorStops.length; n += 2) {
155
- grd.addColorStop(colorStops[n], colorStops[n + 1]);
156
- }
157
- return grd;
158
- }
159
- }
160
- getShadowRGBA() {
161
- return this._getCache(SHADOW_RGBA, this._getShadowRGBA);
162
- }
163
- _getShadowRGBA() {
164
- if (!this.hasShadow()) {
165
- return;
166
- }
167
- const rgba = Util.colorToRGBA(this.shadowColor());
168
- if (rgba) {
169
- return ('rgba(' +
170
- rgba.r +
171
- ',' +
172
- rgba.g +
173
- ',' +
174
- rgba.b +
175
- ',' +
176
- rgba.a * (this.shadowOpacity() || 1) +
177
- ')');
178
- }
179
- }
180
- hasFill() {
181
- return this._calculate('hasFill', [
182
- 'fillEnabled',
183
- 'fill',
184
- 'fillPatternImage',
185
- 'fillLinearGradientColorStops',
186
- 'fillRadialGradientColorStops',
187
- ], () => {
188
- return (this.fillEnabled() &&
189
- !!(this.fill() ||
190
- this.fillPatternImage() ||
191
- this.fillLinearGradientColorStops() ||
192
- this.fillRadialGradientColorStops()));
193
- });
194
- }
195
- hasStroke() {
196
- return this._calculate('hasStroke', [
197
- 'strokeEnabled',
198
- 'strokeWidth',
199
- 'stroke',
200
- 'strokeLinearGradientColorStops',
201
- ], () => {
202
- return (this.strokeEnabled() &&
203
- this.strokeWidth() &&
204
- !!(this.stroke() || this.strokeLinearGradientColorStops()));
205
- });
206
- }
207
- hasHitStroke() {
208
- const width = this.hitStrokeWidth();
209
- if (width === 'auto') {
210
- return this.hasStroke();
211
- }
212
- return this.strokeEnabled() && !!width;
213
- }
214
- intersects(point) {
215
- const stage = this.getStage();
216
- if (!stage) {
217
- return false;
218
- }
219
- const bufferHitCanvas = stage.bufferHitCanvas;
220
- bufferHitCanvas.getContext().clear();
221
- this.drawHit(bufferHitCanvas, undefined, true);
222
- const p = bufferHitCanvas.context.getImageData(Math.round(point.x), Math.round(point.y), 1, 1).data;
223
- return p[3] > 0;
224
- }
225
- destroy() {
226
- Node.prototype.destroy.call(this);
227
- delete shapes[this.colorKey];
228
- delete this.colorKey;
229
- return this;
230
- }
231
- _useBufferCanvas(forceFill) {
232
- var _a;
233
- const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;
234
- if (!perfectDrawEnabled) {
235
- return false;
236
- }
237
- const hasFill = forceFill || this.hasFill();
238
- const hasStroke = this.hasStroke();
239
- const isTransparent = this.getAbsoluteOpacity() !== 1;
240
- if (hasFill && hasStroke && isTransparent) {
241
- return true;
242
- }
243
- const hasShadow = this.hasShadow();
244
- const strokeForShadow = this.shadowForStrokeEnabled();
245
- if (hasFill && hasStroke && hasShadow && strokeForShadow) {
246
- return true;
247
- }
248
- return false;
249
- }
250
- setStrokeHitEnabled(val) {
251
- Util.warn('strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.');
252
- if (val) {
253
- this.hitStrokeWidth('auto');
254
- }
255
- else {
256
- this.hitStrokeWidth(0);
257
- }
258
- }
259
- getStrokeHitEnabled() {
260
- if (this.hitStrokeWidth() === 0) {
261
- return false;
262
- }
263
- else {
264
- return true;
265
- }
266
- }
267
- getSelfRect() {
268
- const size = this.size();
269
- return {
270
- x: this._centroid ? -size.width / 2 : 0,
271
- y: this._centroid ? -size.height / 2 : 0,
272
- width: size.width,
273
- height: size.height,
274
- };
275
- }
276
- getClientRect(config = {}) {
277
- let hasCachedParent = false;
278
- let parent = this.getParent();
279
- while (parent) {
280
- if (parent.isCached()) {
281
- hasCachedParent = true;
282
- break;
283
- }
284
- parent = parent.getParent();
285
- }
286
- const skipTransform = config.skipTransform;
287
- const relativeTo = config.relativeTo || (hasCachedParent && this.getStage()) || undefined;
288
- const fillRect = this.getSelfRect();
289
- const applyStroke = !config.skipStroke && this.hasStroke();
290
- const strokeWidth = (applyStroke && this.strokeWidth()) || 0;
291
- const fillAndStrokeWidth = fillRect.width + strokeWidth;
292
- const fillAndStrokeHeight = fillRect.height + strokeWidth;
293
- const applyShadow = !config.skipShadow && this.hasShadow();
294
- const shadowOffsetX = applyShadow ? this.shadowOffsetX() : 0;
295
- const shadowOffsetY = applyShadow ? this.shadowOffsetY() : 0;
296
- const preWidth = fillAndStrokeWidth + Math.abs(shadowOffsetX);
297
- const preHeight = fillAndStrokeHeight + Math.abs(shadowOffsetY);
298
- const blurRadius = (applyShadow && this.shadowBlur()) || 0;
299
- const width = preWidth + blurRadius * 2;
300
- const height = preHeight + blurRadius * 2;
301
- const rect = {
302
- width: width,
303
- height: height,
304
- x: -(strokeWidth / 2 + blurRadius) +
305
- Math.min(shadowOffsetX, 0) +
306
- fillRect.x,
307
- y: -(strokeWidth / 2 + blurRadius) +
308
- Math.min(shadowOffsetY, 0) +
309
- fillRect.y,
310
- };
311
- if (!skipTransform) {
312
- return this._transformedRect(rect, relativeTo);
313
- }
314
- return rect;
315
- }
316
- drawScene(can, top, bufferCanvas) {
317
- const layer = this.getLayer();
318
- const canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow();
319
- let stage;
320
- const skipBuffer = false;
321
- const cachingSelf = top === this;
322
- if (!this.isVisible() && !cachingSelf) {
323
- return this;
324
- }
325
- if (cachedCanvas) {
326
- context.save();
327
- const m = this.getAbsoluteTransform(top).getMatrix();
328
- context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
329
- this._drawCachedSceneCanvas(context);
330
- context.restore();
331
- return this;
332
- }
333
- if (!drawFunc) {
334
- return this;
335
- }
336
- context.save();
337
- if (this._useBufferCanvas() && !skipBuffer) {
338
- stage = this.getStage();
339
- const bc = bufferCanvas || stage.bufferCanvas;
340
- const bufferContext = bc.getContext();
341
- bufferContext.clear();
342
- bufferContext.save();
343
- bufferContext._applyLineJoin(this);
344
- bufferContext._applyMiterLimit(this);
345
- const o = this.getAbsoluteTransform(top).getMatrix();
346
- bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
347
- drawFunc.call(this, bufferContext, this);
348
- bufferContext.restore();
349
- const ratio = bc.pixelRatio;
350
- if (hasShadow) {
351
- context._applyShadow(this);
352
- }
353
- if (!cachingSelf) {
354
- context._applyOpacity(this);
355
- context._applyGlobalCompositeOperation(this);
356
- }
357
- context.drawImage(bc._canvas, bc.x || 0, bc.y || 0, bc.width / ratio, bc.height / ratio);
358
- }
359
- else {
360
- context._applyLineJoin(this);
361
- context._applyMiterLimit(this);
362
- if (!cachingSelf) {
363
- const o = this.getAbsoluteTransform(top).getMatrix();
364
- context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
365
- context._applyOpacity(this);
366
- context._applyGlobalCompositeOperation(this);
367
- }
368
- if (hasShadow) {
369
- context._applyShadow(this);
370
- }
371
- drawFunc.call(this, context, this);
372
- }
373
- context.restore();
374
- return this;
375
- }
376
- drawHit(can, top, skipDragCheck = false) {
377
- if (!this.shouldDrawHit(top, skipDragCheck)) {
378
- return this;
379
- }
380
- const layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
381
- if (!this.colorKey) {
382
- Util.warn('Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()');
383
- }
384
- if (cachedHitCanvas) {
385
- context.save();
386
- const m = this.getAbsoluteTransform(top).getMatrix();
387
- context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
388
- this._drawCachedHitCanvas(context);
389
- context.restore();
390
- return this;
391
- }
392
- if (!drawFunc) {
393
- return this;
394
- }
395
- context.save();
396
- context._applyLineJoin(this);
397
- context._applyMiterLimit(this);
398
- const selfCache = this === top;
399
- if (!selfCache) {
400
- const o = this.getAbsoluteTransform(top).getMatrix();
401
- context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
402
- }
403
- drawFunc.call(this, context, this);
404
- context.restore();
405
- return this;
406
- }
407
- drawHitFromCache(alphaThreshold = 0) {
408
- const cachedCanvas = this._getCanvasCache(), sceneCanvas = this._getCachedSceneCanvas(), hitCanvas = cachedCanvas.hit, hitContext = hitCanvas.getContext(), hitWidth = hitCanvas.getWidth(), hitHeight = hitCanvas.getHeight();
409
- hitContext.clear();
410
- hitContext.drawImage(sceneCanvas._canvas, 0, 0, hitWidth, hitHeight);
411
- try {
412
- const hitImageData = hitContext.getImageData(0, 0, hitWidth, hitHeight);
413
- const hitData = hitImageData.data;
414
- const len = hitData.length;
415
- const rgbColorKey = Util._hexToRgb(this.colorKey);
416
- for (let i = 0; i < len; i += 4) {
417
- const alpha = hitData[i + 3];
418
- if (alpha > alphaThreshold) {
419
- hitData[i] = rgbColorKey.r;
420
- hitData[i + 1] = rgbColorKey.g;
421
- hitData[i + 2] = rgbColorKey.b;
422
- hitData[i + 3] = 255;
423
- }
424
- else {
425
- hitData[i + 3] = 0;
426
- }
427
- }
428
- hitContext.putImageData(hitImageData, 0, 0);
429
- }
430
- catch (e) {
431
- Util.error('Unable to draw hit graph from cached scene canvas. ' + e.message);
432
- }
433
- return this;
434
- }
435
- hasPointerCapture(pointerId) {
436
- return PointerEvents.hasPointerCapture(pointerId, this);
437
- }
438
- setPointerCapture(pointerId) {
439
- PointerEvents.setPointerCapture(pointerId, this);
440
- }
441
- releaseCapture(pointerId) {
442
- PointerEvents.releaseCapture(pointerId, this);
443
- }
444
- }
445
- Shape.prototype._fillFunc = _fillFunc;
446
- Shape.prototype._strokeFunc = _strokeFunc;
447
- Shape.prototype._fillFuncHit = _fillFuncHit;
448
- Shape.prototype._strokeFuncHit = _strokeFuncHit;
449
- Shape.prototype._centroid = false;
450
- Shape.prototype.nodeType = 'Shape';
451
- _registerNode(Shape);
452
- Shape.prototype.eventListeners = {};
453
- Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);
454
- Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);
455
- Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva', _clearFillPatternCache);
456
- Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);
457
- Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);
458
- Factory.addGetterSetter(Shape, 'stroke', undefined, getStringOrGradientValidator());
459
- Factory.addGetterSetter(Shape, 'strokeWidth', 2, getNumberValidator());
460
- Factory.addGetterSetter(Shape, 'fillAfterStrokeEnabled', false);
461
- Factory.addGetterSetter(Shape, 'hitStrokeWidth', 'auto', getNumberOrAutoValidator());
462
- Factory.addGetterSetter(Shape, 'strokeHitEnabled', true, getBooleanValidator());
463
- Factory.addGetterSetter(Shape, 'perfectDrawEnabled', true, getBooleanValidator());
464
- Factory.addGetterSetter(Shape, 'shadowForStrokeEnabled', true, getBooleanValidator());
465
- Factory.addGetterSetter(Shape, 'lineJoin');
466
- Factory.addGetterSetter(Shape, 'lineCap');
467
- Factory.addGetterSetter(Shape, 'miterLimit');
468
- Factory.addGetterSetter(Shape, 'sceneFunc');
469
- Factory.addGetterSetter(Shape, 'hitFunc');
470
- Factory.addGetterSetter(Shape, 'dash');
471
- Factory.addGetterSetter(Shape, 'dashOffset', 0, getNumberValidator());
472
- Factory.addGetterSetter(Shape, 'shadowColor', undefined, getStringValidator());
473
- Factory.addGetterSetter(Shape, 'shadowBlur', 0, getNumberValidator());
474
- Factory.addGetterSetter(Shape, 'shadowOpacity', 1, getNumberValidator());
475
- Factory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);
476
- Factory.addGetterSetter(Shape, 'shadowOffsetX', 0, getNumberValidator());
477
- Factory.addGetterSetter(Shape, 'shadowOffsetY', 0, getNumberValidator());
478
- Factory.addGetterSetter(Shape, 'fillPatternImage');
479
- Factory.addGetterSetter(Shape, 'fill', undefined, getStringOrGradientValidator());
480
- Factory.addGetterSetter(Shape, 'fillPatternX', 0, getNumberValidator());
481
- Factory.addGetterSetter(Shape, 'fillPatternY', 0, getNumberValidator());
482
- Factory.addGetterSetter(Shape, 'fillLinearGradientColorStops');
483
- Factory.addGetterSetter(Shape, 'strokeLinearGradientColorStops');
484
- Factory.addGetterSetter(Shape, 'fillRadialGradientStartRadius', 0);
485
- Factory.addGetterSetter(Shape, 'fillRadialGradientEndRadius', 0);
486
- Factory.addGetterSetter(Shape, 'fillRadialGradientColorStops');
487
- Factory.addGetterSetter(Shape, 'fillPatternRepeat', 'repeat');
488
- Factory.addGetterSetter(Shape, 'fillEnabled', true);
489
- Factory.addGetterSetter(Shape, 'strokeEnabled', true);
490
- Factory.addGetterSetter(Shape, 'shadowEnabled', true);
491
- Factory.addGetterSetter(Shape, 'dashEnabled', true);
492
- Factory.addGetterSetter(Shape, 'strokeScaleEnabled', true);
493
- Factory.addGetterSetter(Shape, 'fillPriority', 'color');
494
- Factory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);
495
- Factory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, getNumberValidator());
496
- Factory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, getNumberValidator());
497
- Factory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);
498
- Factory.addGetterSetter(Shape, 'fillPatternScaleX', 1, getNumberValidator());
499
- Factory.addGetterSetter(Shape, 'fillPatternScaleY', 1, getNumberValidator());
500
- Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientStartPoint', [
501
- 'x',
502
- 'y',
503
- ]);
504
- Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientStartPoint', [
505
- 'x',
506
- 'y',
507
- ]);
508
- Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointX', 0);
509
- Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointX', 0);
510
- Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointY', 0);
511
- Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointY', 0);
512
- Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientEndPoint', [
513
- 'x',
514
- 'y',
515
- ]);
516
- Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientEndPoint', [
517
- 'x',
518
- 'y',
519
- ]);
520
- Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointX', 0);
521
- Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointX', 0);
522
- Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointY', 0);
523
- Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointY', 0);
524
- Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientStartPoint', [
525
- 'x',
526
- 'y',
527
- ]);
528
- Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointX', 0);
529
- Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointY', 0);
530
- Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint', [
531
- 'x',
532
- 'y',
533
- ]);
534
- Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);
535
- Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);
536
- Factory.addGetterSetter(Shape, 'fillPatternRotation', 0);
537
- Factory.addGetterSetter(Shape, 'fillRule', undefined, getStringValidator());
538
- Factory.backCompat(Shape, {
539
- dashArray: 'dash',
540
- getDashArray: 'getDash',
541
- setDashArray: 'getDash',
542
- drawFunc: 'sceneFunc',
543
- getDrawFunc: 'getSceneFunc',
544
- setDrawFunc: 'setSceneFunc',
545
- drawHitFunc: 'hitFunc',
546
- getDrawHitFunc: 'getHitFunc',
547
- setDrawHitFunc: 'setHitFunc',
548
- });
package/lib/Stage.d.ts DELETED
@@ -1,86 +0,0 @@
1
- import type { ContainerConfig } from './Container.ts';
2
- import { Container } from './Container.ts';
3
- import { SceneCanvas, HitCanvas } from './Canvas.ts';
4
- import type { GetSet, Vector2d } from './types.ts';
5
- import type { Shape } from './Shape.ts';
6
- import type { Layer } from './Layer.ts';
7
- export interface StageConfig extends ContainerConfig {
8
- container?: HTMLDivElement | string;
9
- }
10
- export declare const stages: Stage[];
11
- export declare class Stage extends Container<Layer, StageConfig> {
12
- content: HTMLDivElement;
13
- pointerPos: Vector2d | null;
14
- _pointerPositions: (Vector2d & {
15
- id?: number;
16
- })[];
17
- _changedPointerPositions: (Vector2d & {
18
- id: number;
19
- })[];
20
- bufferCanvas: SceneCanvas;
21
- bufferHitCanvas: HitCanvas;
22
- _mouseTargetShape: Shape;
23
- _touchTargetShape: Shape;
24
- _pointerTargetShape: Shape;
25
- _mouseClickStartShape: Shape;
26
- _touchClickStartShape: Shape;
27
- _pointerClickStartShape: Shape;
28
- _mouseClickEndShape: Shape;
29
- _touchClickEndShape: Shape;
30
- _pointerClickEndShape: Shape;
31
- _mouseDblTimeout: any;
32
- _touchDblTimeout: any;
33
- _pointerDblTimeout: any;
34
- constructor(config: StageConfig);
35
- _validateAdd(child: any): void;
36
- _checkVisibility(): void;
37
- setContainer(container: any): this;
38
- shouldDrawHit(): boolean;
39
- clear(): this;
40
- clone(obj?: any): this;
41
- destroy(): this;
42
- getPointerPosition(): Vector2d | null;
43
- _getPointerById(id?: number): (Vector2d & {
44
- id?: number;
45
- }) | undefined;
46
- getPointersPositions(): (Vector2d & {
47
- id?: number;
48
- })[];
49
- getStage(): this;
50
- getContent(): HTMLDivElement;
51
- _toKonvaCanvas(config: any): SceneCanvas;
52
- getIntersection(pos: Vector2d): Shape<import("./Shape.ts").ShapeConfig> | null;
53
- _resizeDOM(): void;
54
- add(layer: Layer, ...rest: any[]): this;
55
- getParent(): null;
56
- getLayer(): null;
57
- hasPointerCapture(pointerId: number): boolean;
58
- setPointerCapture(pointerId: number): void;
59
- releaseCapture(pointerId: number): void;
60
- getLayers(): Layer[];
61
- _bindContentEvents(): void;
62
- _pointerenter(evt: PointerEvent): void;
63
- _pointerover(evt: any): void;
64
- _getTargetShape(evenType: any): Shape<import("./Shape.ts").ShapeConfig> | null;
65
- _pointerleave(evt: any): void;
66
- _pointerdown(evt: TouchEvent | MouseEvent | PointerEvent): void;
67
- _pointermove(evt: TouchEvent | MouseEvent | PointerEvent): void;
68
- _pointerup(evt: any): void;
69
- _contextmenu(evt: any): void;
70
- _wheel(evt: any): void;
71
- _pointercancel(evt: PointerEvent): void;
72
- _lostpointercapture(evt: PointerEvent): void;
73
- setPointersPositions(evt: any): void;
74
- _setPointerPosition(evt: any): void;
75
- _getContentPosition(): {
76
- top: number;
77
- left: number;
78
- scaleX: number;
79
- scaleY: number;
80
- };
81
- _buildDOM(): void;
82
- cache(): this;
83
- clearCache(): this;
84
- batchDraw(): this;
85
- container: GetSet<HTMLDivElement, this>;
86
- }