konva 10.3.3 → 10.5.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 -1
- package/konva.js +1576 -1636
- 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 +2 -0
- package/lib/DragAndDrop.js +92 -21
- 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 +703 -32
- package/lib/Node.js +1545 -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 +85 -2
- package/lib/Stage.js +205 -14
- package/lib/Tween.d.ts +159 -4
- package/lib/Tween.js +243 -24
- package/lib/Util.d.ts +148 -4
- package/lib/Util.js +354 -82
- package/lib/Validators.d.ts +0 -2
- package/lib/Validators.js +3 -25
- package/lib/_CoreInternals.d.ts +12 -6
- package/lib/_CoreInternals.js +1 -0
- package/lib/_FullInternals.d.ts +17 -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 +56 -6
- package/lib/shapes/Path.js +203 -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 +124 -12
- package/lib/shapes/Transformer.js +864 -140
- 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 +12 -16
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Transform } from '../Util.ts';
|
|
2
2
|
import { Node } from '../Node.ts';
|
|
3
|
+
import { Shape } from '../Shape.ts';
|
|
3
4
|
import { Rect } from './Rect.ts';
|
|
4
5
|
import { Group } from '../Group.ts';
|
|
5
6
|
import type { ContainerConfig } from '../Container.ts';
|
|
@@ -38,10 +39,69 @@ export interface TransformerConfig extends ContainerConfig {
|
|
|
38
39
|
anchorDragBoundFunc?: (oldPos: Vector2d, newPos: Vector2d, evt: any) => Vector2d;
|
|
39
40
|
anchorStyleFunc?: (anchor: Rect) => void;
|
|
40
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Transformer constructor. Transformer is a special type of group that allow you transform Konva
|
|
44
|
+
* primitives and shapes. Transforming tool is not changing `width` and `height` properties of nodes
|
|
45
|
+
* when you resize them. Instead it changes `scaleX` and `scaleY` properties.
|
|
46
|
+
* @constructor
|
|
47
|
+
* @memberof Konva
|
|
48
|
+
* @param {Object} config
|
|
49
|
+
* @param {Boolean} [config.resizeEnabled] Default is true
|
|
50
|
+
* @param {Boolean} [config.rotateEnabled] Default is true
|
|
51
|
+
* @param {Boolean} [config.rotateLineVisible] Default is true
|
|
52
|
+
* @param {Array} [config.rotationSnaps] Array of angles for rotation snaps. Default is []
|
|
53
|
+
* @param {Number} [config.rotationSnapTolerance] Snapping tolerance. If closer than this it will snap. Default is 5
|
|
54
|
+
* @param {Number} [config.rotateAnchorOffset] Default is 50
|
|
55
|
+
* @param {Number} [config.rotateAnchorAngle] Angle of the rotate anchor around the box, in degrees. Default is 0 (top)
|
|
56
|
+
* @param {String} [config.rotateAnchorCursor] Default is crosshair
|
|
57
|
+
* @param {Number} [config.padding] Default is 0
|
|
58
|
+
* @param {Boolean} [config.borderEnabled] Should we draw border? Default is true
|
|
59
|
+
* @param {String} [config.borderStroke] Border stroke color
|
|
60
|
+
* @param {Number} [config.borderStrokeWidth] Border stroke size
|
|
61
|
+
* @param {Array} [config.borderDash] Array for border dash.
|
|
62
|
+
* @param {String} [config.anchorFill] Anchor fill color
|
|
63
|
+
* @param {String} [config.anchorStroke] Anchor stroke color
|
|
64
|
+
* @param {Number} [config.anchorCornerRadius] Anchor corner radius
|
|
65
|
+
* @param {Number} [config.anchorStrokeWidth] Anchor stroke size
|
|
66
|
+
* @param {Number} [config.anchorSize] Default is 10
|
|
67
|
+
* @param {Boolean} [config.keepRatio] Should we keep ratio when we are moving edges? Default is true
|
|
68
|
+
* @param {String} [config.shiftBehavior] How does transformer react on shift key press when we are moving edges? Default is 'default'
|
|
69
|
+
* @param {Boolean} [config.centeredScaling] Should we resize relative to node's center? Default is false
|
|
70
|
+
* @param {Array} [config.enabledAnchors] Array of names of enabled handles
|
|
71
|
+
* @param {Boolean} [config.flipEnabled] Can we flip/mirror shape on transform?. True by default
|
|
72
|
+
* @param {Function} [config.boundBoxFunc] Bounding box function, see {@link Konva.Transformer#boundBoxFunc}
|
|
73
|
+
* @param {Function} [config.anchorDragBoundFunc] Function bounding the position of a dragged anchor, see {@link Konva.Transformer#anchorDragBoundFunc}
|
|
74
|
+
* @param {Function} [config.anchorStyleFunc] Function styling every anchor, see {@link Konva.Transformer#anchorStyleFunc}
|
|
75
|
+
* @param {Boolean} [config.ignoreStroke] Should we ignore stroke size? Default is false
|
|
76
|
+
* @param {Boolean} [config.useSingleNodeRotation] When just one node attached, should we use its rotation for transformer?
|
|
77
|
+
* @param {Boolean} [config.shouldOverdrawWholeArea] Should we fill whole transformer area with fake transparent shape to enable dragging from empty spaces?
|
|
78
|
+
* @example
|
|
79
|
+
* var transformer = new Konva.Transformer({
|
|
80
|
+
* nodes: [rectangle],
|
|
81
|
+
* rotateAnchorOffset: 60,
|
|
82
|
+
* enabledAnchors: ['top-left', 'top-right', 'bottom-left', 'bottom-right']
|
|
83
|
+
* });
|
|
84
|
+
* layer.add(transformer);
|
|
85
|
+
*/
|
|
41
86
|
export declare class Transformer extends Group {
|
|
42
87
|
_nodes: Array<Node>;
|
|
88
|
+
_nodeRectCache?: Map<Node, {
|
|
89
|
+
rotation: number;
|
|
90
|
+
ignoreStroke: boolean;
|
|
91
|
+
version: number;
|
|
92
|
+
width: number;
|
|
93
|
+
height: number;
|
|
94
|
+
minX: number;
|
|
95
|
+
minY: number;
|
|
96
|
+
maxX: number;
|
|
97
|
+
maxY: number;
|
|
98
|
+
}>;
|
|
43
99
|
_movingAnchorName: string | null;
|
|
100
|
+
_pointerId?: number;
|
|
101
|
+
_anchors: Record<string, Rect>;
|
|
102
|
+
_back: Shape;
|
|
44
103
|
_transforming: boolean;
|
|
104
|
+
_fitting: boolean;
|
|
45
105
|
_transformWindow: Window | null;
|
|
46
106
|
_anchorDragOffset: Vector2d;
|
|
47
107
|
sin: number;
|
|
@@ -49,8 +109,18 @@ export declare class Transformer extends Group {
|
|
|
49
109
|
_cursorChange: boolean;
|
|
50
110
|
_elementsCreated: boolean;
|
|
51
111
|
_updateScheduled: boolean;
|
|
112
|
+
_lastNodeRect?: Readonly<Box>;
|
|
52
113
|
static isTransforming: () => boolean;
|
|
114
|
+
static _isLayerTransforming(layer: Node): boolean;
|
|
53
115
|
constructor(config?: TransformerConfig);
|
|
116
|
+
/**
|
|
117
|
+
* alias to `tr.nodes([shape])`/ This method is deprecated and will be removed soon.
|
|
118
|
+
* @method
|
|
119
|
+
* @name Konva.Transformer#attachTo
|
|
120
|
+
* @returns {Konva.Transformer}
|
|
121
|
+
* @example
|
|
122
|
+
* transformer.attachTo(shape);
|
|
123
|
+
*/
|
|
54
124
|
attachTo(node: Node): this;
|
|
55
125
|
setNode(node: Node): this;
|
|
56
126
|
getNode(): Node<import("../Node.ts").NodeConfig>;
|
|
@@ -58,17 +128,39 @@ export declare class Transformer extends Group {
|
|
|
58
128
|
setNodes(nodes?: Array<Node>): this;
|
|
59
129
|
_proxyDrag(node: Node): void;
|
|
60
130
|
getNodes(): Node<import("../Node.ts").NodeConfig>[];
|
|
131
|
+
/**
|
|
132
|
+
* return the name of current active anchor
|
|
133
|
+
* @method
|
|
134
|
+
* @name Konva.Transformer#getActiveAnchor
|
|
135
|
+
* @returns {String | Null}
|
|
136
|
+
* @example
|
|
137
|
+
* transformer.getActiveAnchor();
|
|
138
|
+
*/
|
|
61
139
|
getActiveAnchor(): string | null;
|
|
140
|
+
/**
|
|
141
|
+
* detach transformer from an attached node
|
|
142
|
+
* @method
|
|
143
|
+
* @name Konva.Transformer#detach
|
|
144
|
+
* @returns {Konva.Transformer}
|
|
145
|
+
* @example
|
|
146
|
+
* transformer.detach();
|
|
147
|
+
*/
|
|
62
148
|
detach(): void;
|
|
63
|
-
|
|
149
|
+
/**
|
|
150
|
+
* bind events to the Transformer. You can use events: `transform`, `transformstart`, `transformend`, `dragstart`, `dragmove`, `dragend`
|
|
151
|
+
* @method
|
|
152
|
+
* @name Konva.Transformer#on
|
|
153
|
+
* @param {String} evtStr e.g. 'transform'
|
|
154
|
+
* @param {Function} handler The handler function. The first argument of that function is event object. Event object has `target` as main target of the event, `currentTarget` as current node listener and `evt` as native browser event.
|
|
155
|
+
* @returns {Konva.Transformer}
|
|
156
|
+
* @example
|
|
157
|
+
* // add click listener
|
|
158
|
+
* tr.on('transformstart', function() {
|
|
159
|
+
* console.log('transform started');
|
|
160
|
+
* });
|
|
161
|
+
*/
|
|
162
|
+
_resetTransformCache(changedNode?: Node): void;
|
|
64
163
|
_getNodeRect(): any;
|
|
65
|
-
__getNodeShape(node: Node, rot?: number, relative?: Node): {
|
|
66
|
-
rotation: number;
|
|
67
|
-
x: number;
|
|
68
|
-
y: number;
|
|
69
|
-
width: number;
|
|
70
|
-
height: number;
|
|
71
|
-
};
|
|
72
164
|
__getNodeRect(): {
|
|
73
165
|
x: number;
|
|
74
166
|
y: number;
|
|
@@ -85,16 +177,36 @@ export declare class Transformer extends Group {
|
|
|
85
177
|
_createBack(): void;
|
|
86
178
|
_handleMouseDown(e: any): void;
|
|
87
179
|
_handleMouseMove(e: any): void;
|
|
180
|
+
_moveTransform(e: any): void;
|
|
88
181
|
_handleMouseUp(e: any): void;
|
|
89
|
-
getAbsoluteTransform(): Transform;
|
|
182
|
+
getAbsoluteTransform(top?: Node | null): Transform;
|
|
90
183
|
_removeEvents(e?: any): void;
|
|
91
184
|
_fitNodesInto(newAttrs: any, evt?: any, anchorProjected?: boolean): void;
|
|
92
185
|
_doFitNodesInto(newAttrs: any, evt?: any, anchorProjected?: boolean): void;
|
|
93
186
|
_scheduleUpdate(): void;
|
|
187
|
+
/**
|
|
188
|
+
* force update of Konva.Transformer.
|
|
189
|
+
* Use it when you updated attached Konva.Group and now you need to reset transformer size
|
|
190
|
+
* @method
|
|
191
|
+
* @name Konva.Transformer#forceUpdate
|
|
192
|
+
*/
|
|
94
193
|
forceUpdate(): void;
|
|
95
|
-
_batchChangeChild(selector: string, attrs: any): void;
|
|
96
194
|
update(): void;
|
|
195
|
+
_update(): void;
|
|
196
|
+
_updateElements(attrs: Box): void;
|
|
197
|
+
/**
|
|
198
|
+
* determine if transformer is in active transform
|
|
199
|
+
* @method
|
|
200
|
+
* @name Konva.Transformer#isTransforming
|
|
201
|
+
* @returns {Boolean}
|
|
202
|
+
*/
|
|
97
203
|
isTransforming(): boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Stop active transform action
|
|
206
|
+
* @method
|
|
207
|
+
* @name Konva.Transformer#stopTransform
|
|
208
|
+
* @returns {Boolean}
|
|
209
|
+
*/
|
|
98
210
|
stopTransform(): void;
|
|
99
211
|
destroy(): this;
|
|
100
212
|
add(...children: any[]): this;
|
|
@@ -104,7 +216,7 @@ export declare class Transformer extends Group {
|
|
|
104
216
|
children?: Array<any>;
|
|
105
217
|
};
|
|
106
218
|
clone(obj?: any): this;
|
|
107
|
-
getClientRect(): IRect;
|
|
219
|
+
getClientRect(config?: Parameters<Group['getClientRect']>[0]): IRect;
|
|
108
220
|
nodes: GetSet<Node[], this>;
|
|
109
221
|
enabledAnchors: GetSet<string[], this>;
|
|
110
222
|
rotationSnaps: GetSet<number[], this>;
|
|
@@ -131,7 +243,7 @@ export declare class Transformer extends Group {
|
|
|
131
243
|
flipEnabled: GetSet<boolean, this>;
|
|
132
244
|
ignoreStroke: GetSet<boolean, this>;
|
|
133
245
|
boundBoxFunc: GetSet<(oldBox: Box, newBox: Box) => Box, this>;
|
|
134
|
-
anchorDragBoundFunc: GetSet<(oldPos: Vector2d, newPos: Vector2d,
|
|
246
|
+
anchorDragBoundFunc: GetSet<(oldPos: Vector2d, newPos: Vector2d, evt: any) => Vector2d, this>;
|
|
135
247
|
anchorStyleFunc: GetSet<null | ((Node: Rect) => void), this>;
|
|
136
248
|
shouldOverdrawWholeArea: GetSet<boolean, this>;
|
|
137
249
|
useSingleNodeRotation: GetSet<boolean, this>;
|