konva 10.3.2 → 10.4.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 +5 -1
- package/konva.js +1327 -1572
- package/konva.min.js +4 -4
- package/lib/Animation.d.ts +63 -3
- package/lib/Animation.js +86 -65
- package/lib/BezierFunctions.d.ts +10 -0
- package/lib/BezierFunctions.js +32 -0
- package/lib/Canvas.d.ts +53 -0
- package/lib/Canvas.js +93 -34
- package/lib/Container.d.ts +156 -9
- package/lib/Container.js +260 -25
- package/lib/Context.d.ts +247 -0
- package/lib/Context.js +312 -74
- package/lib/Core.js +1 -0
- package/lib/DragAndDrop.d.ts +1 -0
- package/lib/DragAndDrop.js +66 -17
- package/lib/Factory.d.ts +24 -1
- package/lib/Factory.js +14 -20
- package/lib/FastLayer.d.ts +14 -1
- package/lib/FastLayer.js +14 -1
- package/lib/Global.d.ts +114 -3
- package/lib/Global.js +134 -5
- package/lib/Group.d.ts +11 -0
- package/lib/Group.js +11 -0
- package/lib/Layer.d.ts +128 -3
- package/lib/Layer.js +260 -49
- package/lib/Node.d.ts +692 -30
- package/lib/Node.js +1534 -202
- package/lib/PointerEvents.d.ts +2 -1
- package/lib/PointerEvents.js +19 -1
- package/lib/Shape.d.ts +99 -14
- package/lib/Shape.js +1101 -67
- package/lib/Stage.d.ts +81 -1
- package/lib/Stage.js +166 -7
- package/lib/Tween.d.ts +159 -4
- package/lib/Tween.js +243 -24
- package/lib/Util.d.ts +147 -4
- package/lib/Util.js +332 -82
- package/lib/Validators.d.ts +0 -2
- package/lib/Validators.js +3 -25
- package/lib/_CoreInternals.d.ts +10 -6
- package/lib/_CoreInternals.js +1 -0
- package/lib/_FullInternals.d.ts +15 -6
- package/lib/_FullInternals.js +7 -0
- package/lib/canvas-backend.js +6 -0
- package/lib/filters/Blur.d.ts +18 -0
- package/lib/filters/Blur.js +97 -24
- package/lib/filters/Brighten.d.ts +21 -0
- package/lib/filters/Brighten.js +24 -0
- package/lib/filters/Brightness.d.ts +11 -0
- package/lib/filters/Brightness.js +16 -0
- package/lib/filters/Contrast.d.ts +10 -0
- package/lib/filters/Contrast.js +21 -0
- package/lib/filters/Emboss.d.ts +20 -0
- package/lib/filters/Emboss.js +68 -8
- package/lib/filters/Enhance.d.ts +14 -0
- package/lib/filters/Enhance.js +34 -0
- package/lib/filters/Grayscale.d.ts +9 -0
- package/lib/filters/Grayscale.js +12 -0
- package/lib/filters/HSL.d.ts +17 -0
- package/lib/filters/HSL.js +48 -5
- package/lib/filters/HSV.d.ts +18 -0
- package/lib/filters/HSV.js +49 -5
- package/lib/filters/Invert.d.ts +9 -0
- package/lib/filters/Invert.js +12 -0
- package/lib/filters/Kaleidoscope.d.ts +12 -0
- package/lib/filters/Kaleidoscope.js +83 -0
- package/lib/filters/Mask.d.ts +11 -0
- package/lib/filters/Mask.js +18 -0
- package/lib/filters/Noise.d.ts +19 -0
- package/lib/filters/Noise.js +19 -0
- package/lib/filters/Pixelate.d.ts +20 -0
- package/lib/filters/Pixelate.js +28 -1
- package/lib/filters/Posterize.d.ts +21 -0
- package/lib/filters/Posterize.js +22 -0
- package/lib/filters/RGB.d.ts +21 -0
- package/lib/filters/RGB.js +43 -28
- package/lib/filters/RGBA.d.ts +23 -0
- package/lib/filters/RGBA.js +28 -41
- package/lib/filters/Sepia.d.ts +9 -0
- package/lib/filters/Sepia.js +10 -0
- package/lib/filters/Solarize.d.ts +10 -0
- package/lib/filters/Solarize.js +11 -0
- package/lib/filters/Threshold.d.ts +22 -0
- package/lib/filters/Threshold.js +22 -0
- package/lib/shapes/Arc.d.ts +40 -0
- package/lib/shapes/Arc.js +89 -6
- package/lib/shapes/Arrow.d.ts +24 -1
- package/lib/shapes/Arrow.js +83 -0
- package/lib/shapes/Circle.d.ts +18 -0
- package/lib/shapes/Circle.js +36 -9
- package/lib/shapes/Ellipse.d.ts +34 -2
- package/lib/shapes/Ellipse.js +67 -9
- package/lib/shapes/Image.d.ts +49 -0
- package/lib/shapes/Image.js +151 -22
- package/lib/shapes/Label.d.ts +65 -1
- package/lib/shapes/Label.js +113 -20
- package/lib/shapes/Line.d.ts +50 -8
- package/lib/shapes/Line.js +116 -20
- package/lib/shapes/Path.d.ts +40 -6
- package/lib/shapes/Path.js +187 -128
- package/lib/shapes/Rect.d.ts +18 -0
- package/lib/shapes/Rect.js +36 -0
- package/lib/shapes/RegularPolygon.d.ts +22 -0
- package/lib/shapes/RegularPolygon.js +70 -0
- package/lib/shapes/Ring.d.ts +19 -0
- package/lib/shapes/Ring.js +51 -5
- package/lib/shapes/Sprite.d.ts +78 -0
- package/lib/shapes/Sprite.js +238 -25
- package/lib/shapes/Star.d.ts +23 -0
- package/lib/shapes/Star.js +62 -0
- package/lib/shapes/Text.d.ts +59 -1
- package/lib/shapes/Text.js +481 -97
- package/lib/shapes/TextPath.d.ts +49 -3
- package/lib/shapes/TextPath.js +278 -34
- package/lib/shapes/Transformer.d.ts +108 -11
- package/lib/shapes/Transformer.js +744 -102
- package/lib/shapes/Wedge.d.ts +22 -0
- package/lib/shapes/Wedge.js +67 -3
- package/lib/skia-backend.js +9 -0
- package/lib/types.d.ts +2 -23
- package/lib/types.js +1 -21
- package/package.json +24 -21
package/lib/PointerEvents.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KonvaEventObject } from './Node.ts';
|
|
1
|
+
import type { KonvaEventObject, Node } from './Node.ts';
|
|
2
2
|
import type { Shape } from './Shape.ts';
|
|
3
3
|
import type { Stage } from './Stage.ts';
|
|
4
4
|
export interface KonvaPointerEvent extends KonvaEventObject<PointerEvent> {
|
|
@@ -8,4 +8,5 @@ export declare function getCapturedShape(pointerId: number): Shape<import("./Sha
|
|
|
8
8
|
export declare function createEvent(evt: PointerEvent): KonvaPointerEvent;
|
|
9
9
|
export declare function hasPointerCapture(pointerId: number, shape: Shape | Stage): boolean;
|
|
10
10
|
export declare function setPointerCapture(pointerId: number, shape: Shape | Stage): void;
|
|
11
|
+
export declare function releaseCapturesOf(node: Node): void;
|
|
11
12
|
export declare function releaseCapture(pointerId: number, target?: Shape | Stage): void;
|
package/lib/PointerEvents.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Konva } from "./Global.js";
|
|
2
2
|
const Captures = new Map();
|
|
3
|
+
// we may use this module for capturing touch events too
|
|
4
|
+
// so make sure we don't do something super specific to pointer
|
|
3
5
|
const SUPPORT_POINTER_EVENTS = Konva._global['PointerEvent'] !== undefined;
|
|
4
6
|
export function getCapturedShape(pointerId) {
|
|
5
7
|
return Captures.get(pointerId);
|
|
@@ -21,18 +23,33 @@ export function setPointerCapture(pointerId, shape) {
|
|
|
21
23
|
return;
|
|
22
24
|
Captures.set(pointerId, shape);
|
|
23
25
|
if (SUPPORT_POINTER_EVENTS) {
|
|
26
|
+
// capture on the DOM level too, so the stage keeps receiving the events
|
|
27
|
+
// of that pointer even when it moves outside of the stage container
|
|
28
|
+
// https://github.com/konvajs/konva/issues/1992
|
|
24
29
|
try {
|
|
25
30
|
(_a = stage.content) === null || _a === void 0 ? void 0 : _a.setPointerCapture(pointerId);
|
|
26
31
|
}
|
|
27
32
|
catch (e) {
|
|
33
|
+
// capture is possible only for an active pointer;
|
|
34
|
+
// ids of mouse and touch events (999 and touch identifiers) and
|
|
35
|
+
// programmatic calls outside of a pointer event land here
|
|
28
36
|
}
|
|
29
37
|
shape._fire('gotpointercapture', createEvent(new PointerEvent('gotpointercapture')));
|
|
30
38
|
}
|
|
31
39
|
}
|
|
40
|
+
// a destroyed node must not keep receiving the events of its pointer
|
|
41
|
+
export function releaseCapturesOf(node) {
|
|
42
|
+
Captures.forEach((shape, pointerId) => {
|
|
43
|
+
if (shape === node) {
|
|
44
|
+
releaseCapture(pointerId);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
32
48
|
export function releaseCapture(pointerId, target) {
|
|
33
49
|
var _a;
|
|
34
50
|
const shape = Captures.get(pointerId);
|
|
35
|
-
|
|
51
|
+
// a node can only release its own capture
|
|
52
|
+
if (!shape || (target && shape !== target))
|
|
36
53
|
return;
|
|
37
54
|
const stage = shape.getStage();
|
|
38
55
|
Captures.delete(pointerId);
|
|
@@ -41,6 +58,7 @@ export function releaseCapture(pointerId, target) {
|
|
|
41
58
|
(_a = stage === null || stage === void 0 ? void 0 : stage.content) === null || _a === void 0 ? void 0 : _a.releasePointerCapture(pointerId);
|
|
42
59
|
}
|
|
43
60
|
catch (e) {
|
|
61
|
+
// same as in setPointerCapture: the pointer may not be active
|
|
44
62
|
}
|
|
45
63
|
shape._fire('lostpointercapture', createEvent(new PointerEvent('lostpointercapture')));
|
|
46
64
|
}
|
package/lib/Shape.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NodeConfig } from './Node.ts';
|
|
1
|
+
import type { GetClientRectConfig, NodeConfig } from './Node.ts';
|
|
2
2
|
import { Node } from './Node.ts';
|
|
3
3
|
import type { Context } from './Context.ts';
|
|
4
4
|
import type { GetSet, Vector2d } from './types.ts';
|
|
@@ -28,6 +28,13 @@ export type ShapeConfig = NodeConfig & {
|
|
|
28
28
|
fillLinearGradientEndPointX?: number;
|
|
29
29
|
fillLinearGradientEndPointY?: number;
|
|
30
30
|
fillLinearGradientColorStops?: Array<number | string>;
|
|
31
|
+
strokeLinearGradientStartPoint?: Vector2d;
|
|
32
|
+
strokeLinearGradientStartPointX?: number;
|
|
33
|
+
strokeLinearGradientStartPointY?: number;
|
|
34
|
+
strokeLinearGradientEndPoint?: Vector2d;
|
|
35
|
+
strokeLinearGradientEndPointX?: number;
|
|
36
|
+
strokeLinearGradientEndPointY?: number;
|
|
37
|
+
strokeLinearGradientColorStops?: Array<number | string>;
|
|
31
38
|
fillRadialGradientStartPoint?: Vector2d;
|
|
32
39
|
fillRadialGradientStartPointX?: number;
|
|
33
40
|
fillRadialGradientStartPointY?: number;
|
|
@@ -65,16 +72,37 @@ export type ShapeConfig = NodeConfig & {
|
|
|
65
72
|
dashEnabled?: boolean;
|
|
66
73
|
perfectDrawEnabled?: boolean;
|
|
67
74
|
};
|
|
68
|
-
export
|
|
69
|
-
skipTransform?: boolean;
|
|
70
|
-
skipShadow?: boolean;
|
|
71
|
-
skipStroke?: boolean;
|
|
72
|
-
relativeTo?: Node;
|
|
73
|
-
}
|
|
75
|
+
export type ShapeGetClientRectConfig = GetClientRectConfig;
|
|
74
76
|
export type FillFuncOutput = void | [Path2D | CanvasFillRule] | [Path2D, CanvasFillRule];
|
|
75
77
|
export declare const shapes: {
|
|
76
78
|
[key: string]: Shape;
|
|
77
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Shape constructor. Shapes are primitive objects such as rectangles,
|
|
82
|
+
* circles, text, lines, etc.
|
|
83
|
+
* @constructor
|
|
84
|
+
* @memberof Konva
|
|
85
|
+
* @augments Konva.Node
|
|
86
|
+
* @param {Object} config
|
|
87
|
+
* @@shapeParams
|
|
88
|
+
* @@nodeParams
|
|
89
|
+
* @example
|
|
90
|
+
* var customShape = new Konva.Shape({
|
|
91
|
+
* x: 5,
|
|
92
|
+
* y: 10,
|
|
93
|
+
* fill: 'red',
|
|
94
|
+
* // a Konva.Canvas renderer is passed into the sceneFunc function
|
|
95
|
+
* sceneFunc (context, shape) {
|
|
96
|
+
* context.beginPath();
|
|
97
|
+
* context.moveTo(200, 50);
|
|
98
|
+
* context.lineTo(420, 80);
|
|
99
|
+
* context.quadraticCurveTo(300, 100, 260, 170);
|
|
100
|
+
* context.closePath();
|
|
101
|
+
* // Konva specific method
|
|
102
|
+
* context.fillStrokeShape(shape);
|
|
103
|
+
* }
|
|
104
|
+
*});
|
|
105
|
+
*/
|
|
78
106
|
export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<Config> {
|
|
79
107
|
_centroid: boolean;
|
|
80
108
|
colorKey: string;
|
|
@@ -83,10 +111,22 @@ export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Nod
|
|
|
83
111
|
_fillFuncHit: (ctx: Context) => void;
|
|
84
112
|
_strokeFuncHit: (ctx: Context) => void;
|
|
85
113
|
constructor(config?: Config);
|
|
114
|
+
/**
|
|
115
|
+
* @deprecated
|
|
116
|
+
*/
|
|
86
117
|
getContext(): Context;
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated
|
|
120
|
+
*/
|
|
87
121
|
getCanvas(): SceneCanvas;
|
|
88
122
|
getSceneFunc(): any;
|
|
89
123
|
getHitFunc(): any;
|
|
124
|
+
/**
|
|
125
|
+
* returns whether or not a shadow will be rendered
|
|
126
|
+
* @method
|
|
127
|
+
* @name Konva.Shape#hasShadow
|
|
128
|
+
* @returns {Boolean}
|
|
129
|
+
*/
|
|
90
130
|
hasShadow(): any;
|
|
91
131
|
_hasShadow(): boolean;
|
|
92
132
|
_getFillPattern(): any;
|
|
@@ -97,14 +137,53 @@ export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Nod
|
|
|
97
137
|
__getRadialGradient(): CanvasGradient | undefined;
|
|
98
138
|
getShadowRGBA(): any;
|
|
99
139
|
_getShadowRGBA(): string | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* returns whether or not the shape will be filled
|
|
142
|
+
* @method
|
|
143
|
+
* @name Konva.Shape#hasFill
|
|
144
|
+
* @returns {Boolean}
|
|
145
|
+
*/
|
|
100
146
|
hasFill(): any;
|
|
147
|
+
_hasFill(): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* returns whether or not the shape will be stroked
|
|
150
|
+
* @method
|
|
151
|
+
* @name Konva.Shape#hasStroke
|
|
152
|
+
* @returns {Boolean}
|
|
153
|
+
*/
|
|
101
154
|
hasStroke(): any;
|
|
155
|
+
_hasStroke(): boolean;
|
|
102
156
|
hasHitStroke(): any;
|
|
157
|
+
/**
|
|
158
|
+
* determines if point is in the shape, regardless if other shapes are on top of it. Note: because
|
|
159
|
+
* this method clears a temporary canvas and then redraws the shape, it performs very poorly if executed many times
|
|
160
|
+
* consecutively. Please use the {@link Konva.Stage#getIntersection} method if at all possible
|
|
161
|
+
* because it performs much better. A shape that is invisible, not listening or not on a stage
|
|
162
|
+
* never intersects
|
|
163
|
+
* @method
|
|
164
|
+
* @name Konva.Shape#intersects
|
|
165
|
+
* @param {Object} point
|
|
166
|
+
* @param {Number} point.x
|
|
167
|
+
* @param {Number} point.y
|
|
168
|
+
* @returns {Boolean}
|
|
169
|
+
*/
|
|
103
170
|
intersects(point: Vector2d): boolean;
|
|
104
171
|
destroy(): this;
|
|
105
172
|
_useBufferCanvas(forceFill?: boolean): boolean;
|
|
106
173
|
setStrokeHitEnabled(val: number): void;
|
|
107
174
|
getStrokeHitEnabled(): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* return self rectangle (x, y, width, height) of shape.
|
|
177
|
+
* This method are not taken into account transformation and styles.
|
|
178
|
+
* @method
|
|
179
|
+
* @name Konva.Shape#getSelfRect
|
|
180
|
+
* @returns {Object} rect with {x, y, width, height} properties
|
|
181
|
+
* @example
|
|
182
|
+
*
|
|
183
|
+
* rect.getSelfRect(); // return {x:0, y:0, width:rect.width(), height:rect.height()}
|
|
184
|
+
* circle.getSelfRect(); // return {x: - circle.width() / 2, y: - circle.height() / 2, width:circle.width(), height:circle.height()}
|
|
185
|
+
*
|
|
186
|
+
*/
|
|
108
187
|
getSelfRect(): {
|
|
109
188
|
x: number;
|
|
110
189
|
y: number;
|
|
@@ -118,7 +197,19 @@ export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Nod
|
|
|
118
197
|
y: number;
|
|
119
198
|
};
|
|
120
199
|
drawScene(can?: SceneCanvas, top?: Node, bufferCanvas?: SceneCanvas): this;
|
|
121
|
-
drawHit(can?: HitCanvas, top?: Node
|
|
200
|
+
drawHit(can?: HitCanvas, top?: Node): this;
|
|
201
|
+
/**
|
|
202
|
+
* draw hit graph using the cached scene canvas
|
|
203
|
+
* @method
|
|
204
|
+
* @name Konva.Shape#drawHitFromCache
|
|
205
|
+
* @param {Integer} alphaThreshold alpha channel threshold that determines whether or not
|
|
206
|
+
* a pixel should be drawn onto the hit graph. Must be a value between 0 and 255.
|
|
207
|
+
* The default is 0
|
|
208
|
+
* @returns {Konva.Shape}
|
|
209
|
+
* @example
|
|
210
|
+
* shape.cache();
|
|
211
|
+
* shape.drawHitFromCache();
|
|
212
|
+
*/
|
|
122
213
|
drawHitFromCache(alphaThreshold?: number): this;
|
|
123
214
|
hasPointerCapture(pointerId: number): boolean;
|
|
124
215
|
setPointerCapture(pointerId: number): void;
|
|
@@ -137,12 +228,6 @@ export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Nod
|
|
|
137
228
|
fillLinearGradientEndPoint: GetSet<Vector2d, this>;
|
|
138
229
|
fillLinearGradientEndPointX: GetSet<number, this>;
|
|
139
230
|
fillLinearGradientEndPointY: GetSet<number, this>;
|
|
140
|
-
fillLinearRadialStartPoint: GetSet<Vector2d, this>;
|
|
141
|
-
fillLinearRadialStartPointX: GetSet<number, this>;
|
|
142
|
-
fillLinearRadialStartPointY: GetSet<number, this>;
|
|
143
|
-
fillLinearRadialEndPoint: GetSet<Vector2d, this>;
|
|
144
|
-
fillLinearRadialEndPointX: GetSet<number, this>;
|
|
145
|
-
fillLinearRadialEndPointY: GetSet<number, this>;
|
|
146
231
|
fillPatternImage: GetSet<HTMLImageElement | HTMLCanvasElement, this>;
|
|
147
232
|
fillRadialGradientStartRadius: GetSet<number, this>;
|
|
148
233
|
fillRadialGradientEndRadius: GetSet<number, this>;
|