konva 10.9.1 → 10.11.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 +22 -10
- package/konva.js +19184 -18924
- package/konva.min.js +50 -50
- package/lib/Animation.js +3 -3
- package/lib/Canvas.js +11 -3
- package/lib/Container.js +5 -4
- package/lib/Context.d.ts +1 -2
- package/lib/Context.js +12 -39
- package/lib/Core.js +2 -2
- package/lib/DragAndDrop.js +1 -1
- package/lib/Factory.js +2 -2
- package/lib/FastLayer.js +3 -3
- package/lib/Global.d.ts +0 -1
- package/lib/Global.js +13 -7
- package/lib/Group.js +5 -5
- package/lib/Layer.d.ts +1 -1
- package/lib/Layer.js +8 -8
- package/lib/Node.d.ts +3 -1
- package/lib/Node.js +105 -66
- package/lib/PointerEvents.js +1 -1
- package/lib/Shape.d.ts +8 -1
- package/lib/Shape.js +129 -32
- package/lib/Stage.js +8 -8
- package/lib/Tween.js +4 -4
- package/lib/Util.d.ts +67 -3
- package/lib/Util.js +123 -42
- package/lib/Validators.js +2 -2
- package/lib/_CoreInternals.d.ts +15 -11
- package/lib/_CoreInternals.js +16 -14
- package/lib/_FullInternals.d.ts +14 -10
- package/lib/_FullInternals.js +38 -38
- package/lib/canvas-backend.js +6 -15
- package/lib/filters/Blur.js +3 -3
- package/lib/filters/Brighten.js +3 -3
- package/lib/filters/Brightness.js +2 -2
- package/lib/filters/Contrast.js +3 -3
- package/lib/filters/Emboss.js +10 -9
- package/lib/filters/Enhance.js +3 -3
- package/lib/filters/HSL.js +3 -3
- package/lib/filters/HSV.js +3 -3
- package/lib/filters/Kaleidoscope.js +3 -3
- package/lib/filters/Mask.js +3 -3
- package/lib/filters/Noise.js +3 -3
- package/lib/filters/Pixelate.js +4 -4
- package/lib/filters/Posterize.js +3 -3
- package/lib/filters/RGB.js +3 -3
- package/lib/filters/RGBA.js +3 -3
- package/lib/filters/Threshold.js +3 -3
- package/lib/index.js +1 -1
- package/lib/napi-backend.d.ts +2 -0
- package/lib/napi-backend.js +15 -0
- package/lib/shapes/Arc.js +5 -5
- package/lib/shapes/Arrow.js +5 -5
- package/lib/shapes/Circle.js +4 -4
- package/lib/shapes/Ellipse.js +4 -4
- package/lib/shapes/Image.js +5 -5
- package/lib/shapes/Label.js +7 -7
- package/lib/shapes/Line.js +6 -6
- package/lib/shapes/Path.js +5 -5
- package/lib/shapes/Rect.js +5 -5
- package/lib/shapes/RegularPolygon.js +5 -5
- package/lib/shapes/Ring.js +4 -4
- package/lib/shapes/Sprite.js +5 -5
- package/lib/shapes/Star.js +4 -4
- package/lib/shapes/Text.d.ts +0 -1
- package/lib/shapes/Text.js +32 -30
- package/lib/shapes/TextPath.js +7 -7
- package/lib/shapes/Transformer.js +12 -11
- package/lib/shapes/Wedge.js +5 -5
- package/lib/skia-backend.js +17 -25
- package/package.json +31 -34
package/lib/_CoreInternals.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transform } from './Util.ts';
|
|
1
|
+
import { Transform, setCanvasBackend, getCanvasBackend } from './Util.ts';
|
|
2
2
|
import { Node } from './Node.ts';
|
|
3
3
|
import { Container } from './Container.ts';
|
|
4
4
|
import { Stage } from './Stage.ts';
|
|
@@ -22,7 +22,6 @@ export declare const Konva: {
|
|
|
22
22
|
autoDrawEnabled: boolean;
|
|
23
23
|
hitOnDragEnabled: boolean;
|
|
24
24
|
capturePointerEventsEnabled: boolean;
|
|
25
|
-
_renderBackend: string;
|
|
26
25
|
legacyTextRendering: boolean;
|
|
27
26
|
pixelRatio: number;
|
|
28
27
|
dragDistance: number;
|
|
@@ -62,6 +61,8 @@ export declare const Konva: {
|
|
|
62
61
|
* }
|
|
63
62
|
*/
|
|
64
63
|
beginUpdateBatch: typeof Node._beginUpdateBatch;
|
|
64
|
+
setCanvasBackend: typeof setCanvasBackend;
|
|
65
|
+
getCanvasBackend: typeof getCanvasBackend;
|
|
65
66
|
Util: {
|
|
66
67
|
_isElement(obj: any): obj is Element;
|
|
67
68
|
_isFunction(obj: any): boolean;
|
|
@@ -72,15 +73,17 @@ export declare const Konva: {
|
|
|
72
73
|
_isBoolean(obj: any): obj is boolean;
|
|
73
74
|
isObject(val: any): val is object;
|
|
74
75
|
isValidSelector(selector: any): boolean;
|
|
75
|
-
_sign(number: number): 1 |
|
|
76
|
+
_sign(number: number): -1 | 1;
|
|
76
77
|
requestAnimFrame(callback: Function, win?: Window | null): void;
|
|
77
78
|
createCanvasElement(): HTMLCanvasElement;
|
|
78
79
|
createImageElement(): HTMLImageElement;
|
|
80
|
+
createDOMMatrix(init?: number[]): DOMMatrix;
|
|
81
|
+
createPath2D(path?: string): Path2D;
|
|
79
82
|
_urlToImage(url: string, callback: Function, onError?: (error: Error) => void): void;
|
|
80
83
|
_rgbToHex(r: number, g: number, b: number): string;
|
|
81
84
|
_hexToRgb(hex: string): import("./types.ts").RGB;
|
|
82
85
|
getRandomColor(): string;
|
|
83
|
-
isCanvasFarblingActive()
|
|
86
|
+
isCanvasFarblingActive: () => boolean;
|
|
84
87
|
getHitColor(): string;
|
|
85
88
|
getHitColorKey(r: number, g: number, b: number): string;
|
|
86
89
|
getSnappedHexColor(hex: string): string;
|
|
@@ -153,7 +156,7 @@ export declare const Konva: {
|
|
|
153
156
|
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
|
|
154
157
|
_prepareToStringify<T>(obj: any, ancestors?: Set<object>): T;
|
|
155
158
|
_assign<T, U>(target: T, source: U): T & U;
|
|
156
|
-
_getEventType(type: string):
|
|
159
|
+
_getEventType(type: string): 'mouse' | 'touch' | 'pointer';
|
|
157
160
|
_getFirstPointerId(evt: any): any;
|
|
158
161
|
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
|
|
159
162
|
_cornerRadii(cornerRadius: number | number[], width: number, height: number): [number, number, number, number];
|
|
@@ -176,10 +179,10 @@ export declare const Konva: {
|
|
|
176
179
|
startPointerPos: import("./types.ts").Vector2d;
|
|
177
180
|
offset: import("./types.ts").Vector2d;
|
|
178
181
|
pointerId?: number;
|
|
179
|
-
pointerEventType?: Stage[
|
|
182
|
+
pointerEventType?: Stage['_pointerEventType'];
|
|
180
183
|
lastPos?: import("./types.ts").Vector2d;
|
|
181
184
|
startEvent?: any;
|
|
182
|
-
dragStatus:
|
|
185
|
+
dragStatus: 'ready' | 'dragging' | 'stopped';
|
|
183
186
|
}>;
|
|
184
187
|
_listenToWindow(win: Window): void;
|
|
185
188
|
_batchEvents(callback: () => void, win?: Window): void;
|
|
@@ -189,20 +192,20 @@ export declare const Konva: {
|
|
|
189
192
|
startPointerPos: import("./types.ts").Vector2d;
|
|
190
193
|
offset: import("./types.ts").Vector2d;
|
|
191
194
|
pointerId?: number;
|
|
192
|
-
pointerEventType?: Stage[
|
|
195
|
+
pointerEventType?: Stage['_pointerEventType'];
|
|
193
196
|
lastPos?: import("./types.ts").Vector2d;
|
|
194
197
|
startEvent?: any;
|
|
195
|
-
dragStatus:
|
|
198
|
+
dragStatus: 'ready' | 'dragging' | 'stopped';
|
|
196
199
|
}): void;
|
|
197
200
|
_endDragAfter(evt: any, only?: {
|
|
198
201
|
node: Node;
|
|
199
202
|
startPointerPos: import("./types.ts").Vector2d;
|
|
200
203
|
offset: import("./types.ts").Vector2d;
|
|
201
204
|
pointerId?: number;
|
|
202
|
-
pointerEventType?: Stage[
|
|
205
|
+
pointerEventType?: Stage['_pointerEventType'];
|
|
203
206
|
lastPos?: import("./types.ts").Vector2d;
|
|
204
207
|
startEvent?: any;
|
|
205
|
-
dragStatus:
|
|
208
|
+
dragStatus: 'ready' | 'dragging' | 'stopped';
|
|
206
209
|
}): void;
|
|
207
210
|
};
|
|
208
211
|
Shape: typeof Shape;
|
|
@@ -234,6 +237,7 @@ export declare const Konva: {
|
|
|
234
237
|
};
|
|
235
238
|
export declare namespace Konva {
|
|
236
239
|
type Vector2d = import('./types.ts').Vector2d;
|
|
240
|
+
type CanvasBackend = import('./Util.ts').CanvasBackend;
|
|
237
241
|
type IRect = import('./types.ts').IRect;
|
|
238
242
|
type GetSet<Type, This> = import('./types.ts').GetSet<Type, This>;
|
|
239
243
|
type Filter = import('./Node.ts').Filter;
|
package/lib/_CoreInternals.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// what is core parts of Konva?
|
|
2
|
-
import { Konva as Global } from
|
|
3
|
-
import { Util, Transform } from
|
|
4
|
-
import { Node } from
|
|
5
|
-
import { Container } from
|
|
6
|
-
import { Stage, stages } from
|
|
7
|
-
import { Layer } from
|
|
8
|
-
import { FastLayer } from
|
|
9
|
-
import { Group } from
|
|
10
|
-
import { DD } from
|
|
11
|
-
import { Shape, shapes } from
|
|
12
|
-
import { Animation } from
|
|
13
|
-
import { Tween, Easings } from
|
|
14
|
-
import { Context } from
|
|
15
|
-
import { Canvas } from
|
|
2
|
+
import { Konva as Global } from './Global.js';
|
|
3
|
+
import { Util, Transform, setCanvasBackend, getCanvasBackend } from './Util.js';
|
|
4
|
+
import { Node } from './Node.js';
|
|
5
|
+
import { Container } from './Container.js';
|
|
6
|
+
import { Stage, stages } from './Stage.js';
|
|
7
|
+
import { Layer } from './Layer.js';
|
|
8
|
+
import { FastLayer } from './FastLayer.js';
|
|
9
|
+
import { Group } from './Group.js';
|
|
10
|
+
import { DD } from './DragAndDrop.js';
|
|
11
|
+
import { Shape, shapes } from './Shape.js';
|
|
12
|
+
import { Animation } from './Animation.js';
|
|
13
|
+
import { Tween, Easings } from './Tween.js';
|
|
14
|
+
import { Context } from './Context.js';
|
|
15
|
+
import { Canvas } from './Canvas.js';
|
|
16
16
|
export const Konva = Util._assign(Global, {
|
|
17
17
|
/**
|
|
18
18
|
* Defer automatic Konva.Transformer updates across many synchronous node changes
|
|
@@ -40,6 +40,8 @@ export const Konva = Util._assign(Global, {
|
|
|
40
40
|
* }
|
|
41
41
|
*/
|
|
42
42
|
beginUpdateBatch: Node._beginUpdateBatch,
|
|
43
|
+
setCanvasBackend,
|
|
44
|
+
getCanvasBackend,
|
|
43
45
|
Util,
|
|
44
46
|
Transform,
|
|
45
47
|
Node,
|
package/lib/_FullInternals.d.ts
CHANGED
|
@@ -28,7 +28,6 @@ export declare const Konva: {
|
|
|
28
28
|
autoDrawEnabled: boolean;
|
|
29
29
|
hitOnDragEnabled: boolean;
|
|
30
30
|
capturePointerEventsEnabled: boolean;
|
|
31
|
-
_renderBackend: string;
|
|
32
31
|
legacyTextRendering: boolean;
|
|
33
32
|
pixelRatio: number;
|
|
34
33
|
dragDistance: number;
|
|
@@ -43,6 +42,8 @@ export declare const Konva: {
|
|
|
43
42
|
_injectGlobal(Konva: any): void;
|
|
44
43
|
} & {
|
|
45
44
|
beginUpdateBatch: typeof import("./Node.ts").Node._beginUpdateBatch;
|
|
45
|
+
setCanvasBackend: typeof import("./Util.ts").setCanvasBackend;
|
|
46
|
+
getCanvasBackend: typeof import("./Util.ts").getCanvasBackend;
|
|
46
47
|
Util: {
|
|
47
48
|
_isElement(obj: any): obj is Element;
|
|
48
49
|
_isFunction(obj: any): boolean;
|
|
@@ -53,15 +54,17 @@ export declare const Konva: {
|
|
|
53
54
|
_isBoolean(obj: any): obj is boolean;
|
|
54
55
|
isObject(val: any): val is object;
|
|
55
56
|
isValidSelector(selector: any): boolean;
|
|
56
|
-
_sign(number: number): 1 |
|
|
57
|
+
_sign(number: number): -1 | 1;
|
|
57
58
|
requestAnimFrame(callback: Function, win?: Window | null): void;
|
|
58
59
|
createCanvasElement(): HTMLCanvasElement;
|
|
59
60
|
createImageElement(): HTMLImageElement;
|
|
61
|
+
createDOMMatrix(init?: number[]): DOMMatrix;
|
|
62
|
+
createPath2D(path?: string): Path2D;
|
|
60
63
|
_urlToImage(url: string, callback: Function, onError?: (error: Error) => void): void;
|
|
61
64
|
_rgbToHex(r: number, g: number, b: number): string;
|
|
62
65
|
_hexToRgb(hex: string): import("./types.ts").RGB;
|
|
63
66
|
getRandomColor(): string;
|
|
64
|
-
isCanvasFarblingActive()
|
|
67
|
+
isCanvasFarblingActive: () => boolean;
|
|
65
68
|
getHitColor(): string;
|
|
66
69
|
getHitColorKey(r: number, g: number, b: number): string;
|
|
67
70
|
getSnappedHexColor(hex: string): string;
|
|
@@ -134,7 +137,7 @@ export declare const Konva: {
|
|
|
134
137
|
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
|
|
135
138
|
_prepareToStringify<T>(obj: any, ancestors?: Set<object>): T;
|
|
136
139
|
_assign<T, U>(target: T, source: U): T & U;
|
|
137
|
-
_getEventType(type: string):
|
|
140
|
+
_getEventType(type: string): 'mouse' | 'touch' | 'pointer';
|
|
138
141
|
_getFirstPointerId(evt: any): any;
|
|
139
142
|
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
|
|
140
143
|
_cornerRadii(cornerRadius: number | number[], width: number, height: number): [number, number, number, number];
|
|
@@ -157,10 +160,10 @@ export declare const Konva: {
|
|
|
157
160
|
startPointerPos: import("./types.ts").Vector2d;
|
|
158
161
|
offset: import("./types.ts").Vector2d;
|
|
159
162
|
pointerId?: number;
|
|
160
|
-
pointerEventType?: import("./Stage.ts").Stage[
|
|
163
|
+
pointerEventType?: import("./Stage.ts").Stage['_pointerEventType'];
|
|
161
164
|
lastPos?: import("./types.ts").Vector2d;
|
|
162
165
|
startEvent?: any;
|
|
163
|
-
dragStatus:
|
|
166
|
+
dragStatus: 'ready' | 'dragging' | 'stopped';
|
|
164
167
|
}>;
|
|
165
168
|
_listenToWindow(win: Window): void;
|
|
166
169
|
_batchEvents(callback: () => void, win?: Window): void;
|
|
@@ -170,20 +173,20 @@ export declare const Konva: {
|
|
|
170
173
|
startPointerPos: import("./types.ts").Vector2d;
|
|
171
174
|
offset: import("./types.ts").Vector2d;
|
|
172
175
|
pointerId?: number;
|
|
173
|
-
pointerEventType?: import("./Stage.ts").Stage[
|
|
176
|
+
pointerEventType?: import("./Stage.ts").Stage['_pointerEventType'];
|
|
174
177
|
lastPos?: import("./types.ts").Vector2d;
|
|
175
178
|
startEvent?: any;
|
|
176
|
-
dragStatus:
|
|
179
|
+
dragStatus: 'ready' | 'dragging' | 'stopped';
|
|
177
180
|
}): void;
|
|
178
181
|
_endDragAfter(evt: any, only?: {
|
|
179
182
|
node: import("./Node.ts").Node;
|
|
180
183
|
startPointerPos: import("./types.ts").Vector2d;
|
|
181
184
|
offset: import("./types.ts").Vector2d;
|
|
182
185
|
pointerId?: number;
|
|
183
|
-
pointerEventType?: import("./Stage.ts").Stage[
|
|
186
|
+
pointerEventType?: import("./Stage.ts").Stage['_pointerEventType'];
|
|
184
187
|
lastPos?: import("./types.ts").Vector2d;
|
|
185
188
|
startEvent?: any;
|
|
186
|
-
dragStatus:
|
|
189
|
+
dragStatus: 'ready' | 'dragging' | 'stopped';
|
|
187
190
|
}): void;
|
|
188
191
|
};
|
|
189
192
|
Shape: typeof import("./Shape.ts").Shape;
|
|
@@ -260,6 +263,7 @@ export declare const Konva: {
|
|
|
260
263
|
};
|
|
261
264
|
export declare namespace Konva {
|
|
262
265
|
type Vector2d = Core.Vector2d;
|
|
266
|
+
type CanvasBackend = Core.CanvasBackend;
|
|
263
267
|
type IRect = Core.IRect;
|
|
264
268
|
type GetSet<Type, This> = Core.GetSet<Type, This>;
|
|
265
269
|
type Filter = Core.Filter;
|
package/lib/_FullInternals.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
// we need to import core of the Konva and then extend it with all additional objects
|
|
2
|
-
import { Konva as Core } from
|
|
2
|
+
import { Konva as Core } from './_CoreInternals.js';
|
|
3
3
|
// shapes
|
|
4
|
-
import { Arc } from
|
|
5
|
-
import { Arrow } from
|
|
6
|
-
import { Circle } from
|
|
7
|
-
import { Ellipse } from
|
|
8
|
-
import { Image } from
|
|
9
|
-
import { Label, Tag } from
|
|
10
|
-
import { Line } from
|
|
11
|
-
import { Path } from
|
|
12
|
-
import { Rect } from
|
|
13
|
-
import { RegularPolygon } from
|
|
14
|
-
import { Ring } from
|
|
15
|
-
import { Sprite } from
|
|
16
|
-
import { Star } from
|
|
17
|
-
import { Text } from
|
|
18
|
-
import { TextPath } from
|
|
19
|
-
import { Transformer } from
|
|
20
|
-
import { Wedge } from
|
|
4
|
+
import { Arc } from './shapes/Arc.js';
|
|
5
|
+
import { Arrow } from './shapes/Arrow.js';
|
|
6
|
+
import { Circle } from './shapes/Circle.js';
|
|
7
|
+
import { Ellipse } from './shapes/Ellipse.js';
|
|
8
|
+
import { Image } from './shapes/Image.js';
|
|
9
|
+
import { Label, Tag } from './shapes/Label.js';
|
|
10
|
+
import { Line } from './shapes/Line.js';
|
|
11
|
+
import { Path } from './shapes/Path.js';
|
|
12
|
+
import { Rect } from './shapes/Rect.js';
|
|
13
|
+
import { RegularPolygon } from './shapes/RegularPolygon.js';
|
|
14
|
+
import { Ring } from './shapes/Ring.js';
|
|
15
|
+
import { Sprite } from './shapes/Sprite.js';
|
|
16
|
+
import { Star } from './shapes/Star.js';
|
|
17
|
+
import { Text } from './shapes/Text.js';
|
|
18
|
+
import { TextPath } from './shapes/TextPath.js';
|
|
19
|
+
import { Transformer } from './shapes/Transformer.js';
|
|
20
|
+
import { Wedge } from './shapes/Wedge.js';
|
|
21
21
|
// filters
|
|
22
|
-
import { Blur } from
|
|
23
|
-
import { Brighten } from
|
|
24
|
-
import { Brightness } from
|
|
25
|
-
import { Contrast } from
|
|
26
|
-
import { Emboss } from
|
|
27
|
-
import { Enhance } from
|
|
28
|
-
import { Grayscale } from
|
|
29
|
-
import { HSL } from
|
|
30
|
-
import { HSV } from
|
|
31
|
-
import { Invert } from
|
|
32
|
-
import { Kaleidoscope } from
|
|
33
|
-
import { Mask } from
|
|
34
|
-
import { Noise } from
|
|
35
|
-
import { Pixelate } from
|
|
36
|
-
import { Posterize } from
|
|
37
|
-
import { RGB } from
|
|
38
|
-
import { RGBA } from
|
|
39
|
-
import { Sepia } from
|
|
40
|
-
import { Solarize } from
|
|
41
|
-
import { Threshold } from
|
|
22
|
+
import { Blur } from './filters/Blur.js';
|
|
23
|
+
import { Brighten } from './filters/Brighten.js';
|
|
24
|
+
import { Brightness } from './filters/Brightness.js';
|
|
25
|
+
import { Contrast } from './filters/Contrast.js';
|
|
26
|
+
import { Emboss } from './filters/Emboss.js';
|
|
27
|
+
import { Enhance } from './filters/Enhance.js';
|
|
28
|
+
import { Grayscale } from './filters/Grayscale.js';
|
|
29
|
+
import { HSL } from './filters/HSL.js';
|
|
30
|
+
import { HSV } from './filters/HSV.js';
|
|
31
|
+
import { Invert } from './filters/Invert.js';
|
|
32
|
+
import { Kaleidoscope } from './filters/Kaleidoscope.js';
|
|
33
|
+
import { Mask } from './filters/Mask.js';
|
|
34
|
+
import { Noise } from './filters/Noise.js';
|
|
35
|
+
import { Pixelate } from './filters/Pixelate.js';
|
|
36
|
+
import { Posterize } from './filters/Posterize.js';
|
|
37
|
+
import { RGB } from './filters/RGB.js';
|
|
38
|
+
import { RGBA } from './filters/RGBA.js';
|
|
39
|
+
import { Sepia } from './filters/Sepia.js';
|
|
40
|
+
import { Solarize } from './filters/Solarize.js';
|
|
41
|
+
import { Threshold } from './filters/Threshold.js';
|
|
42
42
|
export const Konva = Core.Util._assign(Core, {
|
|
43
43
|
Arc,
|
|
44
44
|
Arrow,
|
package/lib/canvas-backend.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
var _b;
|
|
3
|
-
import { Konva } from
|
|
4
|
-
// @ts-ignore
|
|
3
|
+
import { Konva } from './_CoreInternals.js';
|
|
5
4
|
import * as Canvas from 'canvas';
|
|
6
5
|
const canvas = Canvas['default'] || Canvas;
|
|
7
6
|
// @ts-ignore
|
|
@@ -15,19 +14,11 @@ global.DOMMatrix = canvas.DOMMatrix;
|
|
|
15
14
|
return `Path2D`;
|
|
16
15
|
}
|
|
17
16
|
});
|
|
18
|
-
Konva.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return node;
|
|
24
|
-
};
|
|
25
|
-
// create image in Node env
|
|
26
|
-
Konva.Util.createImageElement = () => {
|
|
27
|
-
const node = new canvas.Image();
|
|
28
|
-
return node;
|
|
29
|
-
};
|
|
30
|
-
Konva._renderBackend = 'node-canvas';
|
|
17
|
+
Konva.setCanvasBackend({
|
|
18
|
+
name: 'node-canvas',
|
|
19
|
+
createCanvas: () => canvas.createCanvas(300, 300),
|
|
20
|
+
createImage: () => new canvas.Image(),
|
|
21
|
+
});
|
|
31
22
|
// the core Konva object, without shapes and filters. `import 'konva'` extends
|
|
32
23
|
// this same object with them
|
|
33
24
|
export default Konva;
|
package/lib/filters/Blur.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node, _registerCSSFilterFallback } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node, _registerCSSFilterFallback } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
/*
|
|
5
5
|
the Gauss filter
|
|
6
6
|
master repo: https://github.com/pavelpower/kineticjsGaussFilter
|
package/lib/filters/Brighten.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
/**
|
|
5
5
|
* Brighten Filter.
|
|
6
6
|
* @deprecated Use {@link Konva.Filters.Brightness} instead for CSS-compatible behavior.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _registerCSSFilterFallback } from
|
|
1
|
+
import { _registerCSSFilterFallback } from '../Node.js';
|
|
2
2
|
// The shared brightness accessor is registered by Brighten.
|
|
3
|
-
import
|
|
3
|
+
import './Brighten.js';
|
|
4
4
|
/**
|
|
5
5
|
* Brightness Filter.
|
|
6
6
|
* CSS-compatible brightness multiplier. An unset brightness leaves pixels unchanged.
|
package/lib/filters/Contrast.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node, _registerCSSFilterFallback } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node, _registerCSSFilterFallback } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
/**
|
|
5
5
|
* Contrast Filter.
|
|
6
6
|
* @function
|
package/lib/filters/Emboss.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Util } from
|
|
3
|
-
import { Node } from
|
|
4
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Util } from '../Util.js';
|
|
3
|
+
import { Node } from '../Node.js';
|
|
4
|
+
import { getNumberValidator } from '../Validators.js';
|
|
5
5
|
/**
|
|
6
6
|
* Emboss Filter.
|
|
7
7
|
* @function
|
|
@@ -16,13 +16,14 @@ import { getNumberValidator } from "../Validators.js";
|
|
|
16
16
|
* node.embossBlend(true);
|
|
17
17
|
*/
|
|
18
18
|
export const Emboss = function (imageData) {
|
|
19
|
-
var _a, _b, _c, _d
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
var _e, _f, _g, _h;
|
|
20
21
|
const data = imageData.data;
|
|
21
22
|
const w = imageData.width;
|
|
22
23
|
const h = imageData.height;
|
|
23
24
|
// Inputs from Konva node
|
|
24
|
-
const strength01 = Math.min(1, Math.max(0, (
|
|
25
|
-
const whiteLevel01 = Math.min(1, Math.max(0, (
|
|
25
|
+
const strength01 = Math.min(1, Math.max(0, (_e = (_a = this.embossStrength) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _e !== void 0 ? _e : 0.5)); // [0..1]
|
|
26
|
+
const whiteLevel01 = Math.min(1, Math.max(0, (_f = (_b = this.embossWhiteLevel) === null || _b === void 0 ? void 0 : _b.call(this)) !== null && _f !== void 0 ? _f : 0.5)); // [0..1]
|
|
26
27
|
// Convert string direction to degrees
|
|
27
28
|
const directionMap = {
|
|
28
29
|
'top-left': 315,
|
|
@@ -34,13 +35,13 @@ export const Emboss = function (imageData) {
|
|
|
34
35
|
'bottom-left': 45,
|
|
35
36
|
left: 0,
|
|
36
37
|
};
|
|
37
|
-
const direction = (
|
|
38
|
+
const direction = (_g = (_c = this.embossDirection) === null || _c === void 0 ? void 0 : _c.call(this)) !== null && _g !== void 0 ? _g : 'top-left';
|
|
38
39
|
let directionDeg = directionMap[direction]; // degrees
|
|
39
40
|
if (directionDeg === undefined) {
|
|
40
41
|
Util.warn('Unknown emboss direction: "' + direction + '". Using "top-left".');
|
|
41
42
|
directionDeg = directionMap['top-left'];
|
|
42
43
|
}
|
|
43
|
-
const blend = !!((_h = (
|
|
44
|
+
const blend = !!((_h = (_d = this.embossBlend) === null || _d === void 0 ? void 0 : _d.call(this)) !== null && _h !== void 0 ? _h : false);
|
|
44
45
|
// Internal mapping:
|
|
45
46
|
// - "strength" was 0..10; we honor your 0..1 API and scale accordingly.
|
|
46
47
|
// - Sobel directional response is roughly in [-1020..1020] for 8-bit luminance; scale to ~±128.
|
package/lib/filters/Enhance.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
function remap(fromValue, fromMin, fromMax, toMin, toMax) {
|
|
5
5
|
// Compute the range of the data
|
|
6
6
|
const fromRange = fromMax - fromMin, toRange = toMax - toMin;
|
package/lib/filters/HSL.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
Factory.addGetterSetter(Node, 'hue', 0, getNumberValidator(), Factory.afterSetFilter);
|
|
5
5
|
/**
|
|
6
6
|
* get/set hsv hue in degrees. Use with {@link Konva.Filters.HSV} or {@link Konva.Filters.HSL} filter.
|
package/lib/filters/HSV.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
/**
|
|
5
5
|
* HSV Filter. Adjusts the hue, saturation and value
|
|
6
6
|
* @function
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
/*
|
|
5
5
|
* ToPolar Filter. Converts image data to polar coordinates. Performs
|
|
6
6
|
* w*h*4 pixel reads and w*h pixel writes. The r axis is placed along
|
package/lib/filters/Mask.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
function pixelAt(idata, x, y) {
|
|
5
5
|
let idx = (y * idata.width + x) * 4;
|
|
6
6
|
const d = [];
|
package/lib/filters/Noise.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
/**
|
|
5
5
|
* Noise Filter. Randomly adds or substracts to the color channels
|
|
6
6
|
* @function
|
package/lib/filters/Pixelate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Util } from
|
|
3
|
-
import { Node } from
|
|
4
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Util } from '../Util.js';
|
|
3
|
+
import { Node } from '../Node.js';
|
|
4
|
+
import { getNumberValidator } from '../Validators.js';
|
|
5
5
|
/**
|
|
6
6
|
* Pixelate Filter. Averages groups of pixels and redraws
|
|
7
7
|
* them as larger pixels
|
package/lib/filters/Posterize.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
/**
|
|
5
5
|
* Posterize Filter. Adjusts the channels so that there are no more
|
|
6
6
|
* than n different values for that channel. This is also applied
|
package/lib/filters/RGB.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
3
|
-
import { RGBComponent } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
|
+
import { RGBComponent } from '../Validators.js';
|
|
4
4
|
/**
|
|
5
5
|
* RGB Filter
|
|
6
6
|
* @function
|
package/lib/filters/RGBA.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
3
|
// red, green and blue are registered there
|
|
4
|
-
import
|
|
4
|
+
import './RGB.js';
|
|
5
5
|
/**
|
|
6
6
|
* RGBA Filter
|
|
7
7
|
* @function
|
package/lib/filters/Threshold.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Node } from
|
|
3
|
-
import { getNumberValidator } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Node } from '../Node.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
4
|
/**
|
|
5
5
|
* Threshold Filter. Pushes any value above the mid point to
|
|
6
6
|
* the max and any value below the mid point to the min.
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Konva } from
|
|
1
|
+
import { Konva } from './_FullInternals.js';
|
|
2
2
|
export default Konva;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Konva } from './_CoreInternals.js';
|
|
2
|
+
import { Canvas, DOMMatrix, Image, Path2D } from '@napi-rs/canvas';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
global.DOMMatrix = DOMMatrix;
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
global.Path2D = Path2D;
|
|
7
|
+
Konva.setCanvasBackend({
|
|
8
|
+
name: 'napi-rs-canvas',
|
|
9
|
+
createCanvas: () => new Canvas(300, 300),
|
|
10
|
+
createImage: () => new Image(),
|
|
11
|
+
createPath2D: (path) => new Path2D(path),
|
|
12
|
+
});
|
|
13
|
+
// the core Konva object, without shapes and filters. `import 'konva'` extends
|
|
14
|
+
// this same object with them
|
|
15
|
+
export default Konva;
|
package/lib/shapes/Arc.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Shape } from
|
|
3
|
-
import { Konva } from
|
|
4
|
-
import { getNumberValidator, getBooleanValidator } from
|
|
5
|
-
import { _registerNode } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Shape } from '../Shape.js';
|
|
3
|
+
import { Konva } from '../Global.js';
|
|
4
|
+
import { getNumberValidator, getBooleanValidator } from '../Validators.js';
|
|
5
|
+
import { _registerNode } from '../Global.js';
|
|
6
6
|
/**
|
|
7
7
|
* Arc constructor
|
|
8
8
|
* @constructor
|
package/lib/shapes/Arrow.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Factory } from
|
|
2
|
-
import { Line } from
|
|
3
|
-
import { getNumberValidator } from
|
|
4
|
-
import { _registerNode } from
|
|
5
|
-
import { Path } from
|
|
1
|
+
import { Factory } from '../Factory.js';
|
|
2
|
+
import { Line } from './Line.js';
|
|
3
|
+
import { getNumberValidator } from '../Validators.js';
|
|
4
|
+
import { _registerNode } from '../Global.js';
|
|
5
|
+
import { Path } from './Path.js';
|
|
6
6
|
/**
|
|
7
7
|
* Arrow constructor
|
|
8
8
|
* @constructor
|