konva 10.3.3 → 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 +1 -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 +12 -16
package/lib/shapes/Wedge.d.ts
CHANGED
|
@@ -7,6 +7,28 @@ export interface WedgeConfig extends ShapeConfig {
|
|
|
7
7
|
radius: number;
|
|
8
8
|
clockwise?: boolean;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Wedge constructor
|
|
12
|
+
* @constructor
|
|
13
|
+
* @memberof Konva
|
|
14
|
+
* @augments Konva.Shape
|
|
15
|
+
* @param {Object} config
|
|
16
|
+
* @param {Number} config.angle in degrees
|
|
17
|
+
* @param {Number} config.radius
|
|
18
|
+
* @param {Boolean} [config.clockwise]
|
|
19
|
+
* @@shapeParams
|
|
20
|
+
* @@nodeParams
|
|
21
|
+
* @example
|
|
22
|
+
* // draw a wedge that's pointing downwards
|
|
23
|
+
* var wedge = new Konva.Wedge({
|
|
24
|
+
* radius: 40,
|
|
25
|
+
* fill: 'red',
|
|
26
|
+
* stroke: 'black',
|
|
27
|
+
* strokeWidth: 5,
|
|
28
|
+
* angle: 60,
|
|
29
|
+
* rotation: -120
|
|
30
|
+
* });
|
|
31
|
+
*/
|
|
10
32
|
export declare class Wedge extends Shape<WedgeConfig> {
|
|
11
33
|
_sceneFunc(context: Context): void;
|
|
12
34
|
getWidth(): number;
|
package/lib/shapes/Wedge.js
CHANGED
|
@@ -3,19 +3,41 @@ import { Shape } from "../Shape.js";
|
|
|
3
3
|
import { Konva } from "../Global.js";
|
|
4
4
|
import { getNumberValidator } from "../Validators.js";
|
|
5
5
|
import { _registerNode } from "../Global.js";
|
|
6
|
+
/**
|
|
7
|
+
* Wedge constructor
|
|
8
|
+
* @constructor
|
|
9
|
+
* @memberof Konva
|
|
10
|
+
* @augments Konva.Shape
|
|
11
|
+
* @param {Object} config
|
|
12
|
+
* @param {Number} config.angle in degrees
|
|
13
|
+
* @param {Number} config.radius
|
|
14
|
+
* @param {Boolean} [config.clockwise]
|
|
15
|
+
* @@shapeParams
|
|
16
|
+
* @@nodeParams
|
|
17
|
+
* @example
|
|
18
|
+
* // draw a wedge that's pointing downwards
|
|
19
|
+
* var wedge = new Konva.Wedge({
|
|
20
|
+
* radius: 40,
|
|
21
|
+
* fill: 'red',
|
|
22
|
+
* stroke: 'black',
|
|
23
|
+
* strokeWidth: 5,
|
|
24
|
+
* angle: 60,
|
|
25
|
+
* rotation: -120
|
|
26
|
+
* });
|
|
27
|
+
*/
|
|
6
28
|
export class Wedge extends Shape {
|
|
7
29
|
_sceneFunc(context) {
|
|
8
30
|
context.beginPath();
|
|
9
|
-
context.arc(0, 0, this.radius(), 0, Konva.getAngle(this.angle()), this.clockwise());
|
|
31
|
+
context.arc(0, 0, Math.abs(this.radius()), 0, Konva.getAngle(this.angle()), this.clockwise());
|
|
10
32
|
context.lineTo(0, 0);
|
|
11
33
|
context.closePath();
|
|
12
34
|
context.fillStrokeShape(this);
|
|
13
35
|
}
|
|
14
36
|
getWidth() {
|
|
15
|
-
return this.radius() * 2;
|
|
37
|
+
return Math.abs(this.radius()) * 2;
|
|
16
38
|
}
|
|
17
39
|
getHeight() {
|
|
18
|
-
return this.radius() * 2;
|
|
40
|
+
return Math.abs(this.radius()) * 2;
|
|
19
41
|
}
|
|
20
42
|
setWidth(width) {
|
|
21
43
|
this.radius(width / 2);
|
|
@@ -28,8 +50,50 @@ Wedge.prototype.className = 'Wedge';
|
|
|
28
50
|
Wedge.prototype._centroid = true;
|
|
29
51
|
Wedge.prototype._attrsAffectingSize = ['radius'];
|
|
30
52
|
_registerNode(Wedge);
|
|
53
|
+
/**
|
|
54
|
+
* get/set radius
|
|
55
|
+
* @name Konva.Wedge#radius
|
|
56
|
+
* @method
|
|
57
|
+
* @param {Number} radius
|
|
58
|
+
* @returns {Number}
|
|
59
|
+
* @example
|
|
60
|
+
* // get radius
|
|
61
|
+
* var radius = wedge.radius();
|
|
62
|
+
*
|
|
63
|
+
* // set radius
|
|
64
|
+
* wedge.radius(10);
|
|
65
|
+
*/
|
|
31
66
|
Factory.addGetterSetter(Wedge, 'radius', 0, getNumberValidator());
|
|
67
|
+
/**
|
|
68
|
+
* get/set angle in degrees
|
|
69
|
+
* @name Konva.Wedge#angle
|
|
70
|
+
* @method
|
|
71
|
+
* @param {Number} angle
|
|
72
|
+
* @returns {Number}
|
|
73
|
+
* @example
|
|
74
|
+
* // get angle
|
|
75
|
+
* var angle = wedge.angle();
|
|
76
|
+
*
|
|
77
|
+
* // set angle
|
|
78
|
+
* wedge.angle(20);
|
|
79
|
+
*/
|
|
32
80
|
Factory.addGetterSetter(Wedge, 'angle', 0, getNumberValidator());
|
|
81
|
+
/**
|
|
82
|
+
* get/set clockwise flag
|
|
83
|
+
* @name Konva.Wedge#clockwise
|
|
84
|
+
* @method
|
|
85
|
+
* @param {Boolean} clockwise
|
|
86
|
+
* @returns {Boolean}
|
|
87
|
+
* @example
|
|
88
|
+
* // get clockwise flag
|
|
89
|
+
* var clockwise = wedge.clockwise();
|
|
90
|
+
*
|
|
91
|
+
* // draw wedge counter-clockwise
|
|
92
|
+
* wedge.clockwise(false);
|
|
93
|
+
*
|
|
94
|
+
* // draw wedge clockwise
|
|
95
|
+
* wedge.clockwise(true);
|
|
96
|
+
*/
|
|
33
97
|
Factory.addGetterSetter(Wedge, 'clockwise', false);
|
|
34
98
|
Factory.backCompat(Wedge, {
|
|
35
99
|
angleDeg: 'angle',
|
package/lib/skia-backend.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Konva } from "./_CoreInternals.js";
|
|
2
|
+
// @ts-ignore
|
|
2
3
|
import { Canvas, DOMMatrix, Image, Path2D } from 'skia-canvas';
|
|
4
|
+
// @ts-ignore
|
|
3
5
|
global.DOMMatrix = DOMMatrix;
|
|
6
|
+
// @ts-ignore
|
|
4
7
|
global.Path2D = Path2D;
|
|
5
8
|
Path2D.prototype.toString = () => '[object Path2D]';
|
|
6
9
|
Konva.Util['createCanvasElement'] = () => {
|
|
@@ -10,15 +13,21 @@ Konva.Util['createCanvasElement'] = () => {
|
|
|
10
13
|
}
|
|
11
14
|
node.toString = () => '[object HTMLCanvasElement]';
|
|
12
15
|
const ctx = node.getContext('2d');
|
|
16
|
+
// Override the getter to return the canvas node directly
|
|
17
|
+
// because in skia-canvas canvas is using weak ref to the canvas node
|
|
18
|
+
// and somehow on many tests it fails to get the canvas node
|
|
13
19
|
Object.defineProperty(ctx, 'canvas', {
|
|
14
20
|
get: () => node,
|
|
15
21
|
});
|
|
16
22
|
return node;
|
|
17
23
|
};
|
|
24
|
+
// create image in Node env
|
|
18
25
|
Konva.Util.createImageElement = () => {
|
|
19
26
|
const node = new Image();
|
|
20
27
|
node.toString = () => '[object HTMLImageElement]';
|
|
21
28
|
return node;
|
|
22
29
|
};
|
|
23
30
|
Konva._renderBackend = 'skia-canvas';
|
|
31
|
+
// the core Konva object, without shapes and filters. `import 'konva'` extends
|
|
32
|
+
// this same object with them
|
|
24
33
|
export default Konva;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export interface GetSet<Type, This> {
|
|
1
|
+
export interface GetSet<Type, This, SetType = Type> {
|
|
2
2
|
(): Type;
|
|
3
|
-
(v:
|
|
3
|
+
(v: SetType | null | undefined): This;
|
|
4
4
|
}
|
|
5
5
|
export interface Vector2d {
|
|
6
6
|
x: number;
|
|
@@ -25,27 +25,6 @@ export interface IFrame {
|
|
|
25
25
|
frameRate: number;
|
|
26
26
|
}
|
|
27
27
|
export type AnimationFn = (frame: IFrame) => boolean | void;
|
|
28
|
-
export declare const KonvaNodeEvent: {
|
|
29
|
-
readonly mouseover: "mouseover";
|
|
30
|
-
readonly mouseout: "mouseout";
|
|
31
|
-
readonly mousemove: "mousemove";
|
|
32
|
-
readonly mouseleave: "mouseleave";
|
|
33
|
-
readonly mouseenter: "mouseenter";
|
|
34
|
-
readonly mousedown: "mousedown";
|
|
35
|
-
readonly mouseup: "mouseup";
|
|
36
|
-
readonly wheel: "wheel";
|
|
37
|
-
readonly contextmenu: "contextmenu";
|
|
38
|
-
readonly click: "click";
|
|
39
|
-
readonly dblclick: "dblclick";
|
|
40
|
-
readonly touchstart: "touchstart";
|
|
41
|
-
readonly touchmove: "touchmove";
|
|
42
|
-
readonly touchend: "touchend";
|
|
43
|
-
readonly tap: "tap";
|
|
44
|
-
readonly dbltap: "dbltap";
|
|
45
|
-
readonly dragstart: "dragstart";
|
|
46
|
-
readonly dragmove: "dragmove";
|
|
47
|
-
readonly dragend: "dragend";
|
|
48
|
-
};
|
|
49
28
|
export interface RGB {
|
|
50
29
|
r: number;
|
|
51
30
|
g: number;
|
package/lib/types.js
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
mouseover: 'mouseover',
|
|
3
|
-
mouseout: 'mouseout',
|
|
4
|
-
mousemove: 'mousemove',
|
|
5
|
-
mouseleave: 'mouseleave',
|
|
6
|
-
mouseenter: 'mouseenter',
|
|
7
|
-
mousedown: 'mousedown',
|
|
8
|
-
mouseup: 'mouseup',
|
|
9
|
-
wheel: 'wheel',
|
|
10
|
-
contextmenu: 'contextmenu',
|
|
11
|
-
click: 'click',
|
|
12
|
-
dblclick: 'dblclick',
|
|
13
|
-
touchstart: 'touchstart',
|
|
14
|
-
touchmove: 'touchmove',
|
|
15
|
-
touchend: 'touchend',
|
|
16
|
-
tap: 'tap',
|
|
17
|
-
dbltap: 'dbltap',
|
|
18
|
-
dragstart: 'dragstart',
|
|
19
|
-
dragmove: 'dragmove',
|
|
20
|
-
dragend: 'dragend',
|
|
21
|
-
};
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "konva",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.0",
|
|
4
4
|
"description": "HTML5 2d canvas library for interactive graphics, design editors, whiteboards, and diagrams.",
|
|
5
5
|
"author": "Anton Lavrenov",
|
|
6
6
|
"type": "module",
|
|
@@ -30,27 +30,30 @@
|
|
|
30
30
|
"./skia-backend": {
|
|
31
31
|
"types": "./lib/skia-backend.d.ts",
|
|
32
32
|
"default": "./lib/skia-backend.js"
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
34
35
|
},
|
|
35
36
|
"main": "./lib/index.js",
|
|
36
37
|
"types": "./lib/index.d.ts",
|
|
37
38
|
"scripts": {
|
|
38
39
|
"start": "npm run test:watch",
|
|
39
40
|
"compile": "npm run clean && npm run tsc && npm run rollup",
|
|
41
|
+
"prepublishOnly": "npm run build",
|
|
40
42
|
"build": "npm run compile && gulp build",
|
|
41
43
|
"fmt": "prettier --write .",
|
|
42
44
|
"fmt:check": "prettier --check .",
|
|
43
45
|
"test:import": "npm run build && node ./test/import-test.cjs && node ./test/import-test.mjs",
|
|
44
|
-
"test": "npm run test:browser && npm run test:node && npm run test:import",
|
|
45
|
-
"test:
|
|
46
|
+
"test": "npm run test:types && npm run test:browser && npm run test:node && npm run test:import",
|
|
47
|
+
"test:types": "tsc -p test/types/tsconfig.json",
|
|
48
|
+
"test:build": "rimraf ./.parcel-cache && PARCEL_WORKER_BACKEND=process parcel build ./test/unit-tests.html --dist-dir ./test-build --target none --public-url ./ --no-source-maps",
|
|
46
49
|
"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security -a no-sandbox -a disable-setuid-sandbox",
|
|
47
50
|
"test:watch": "rimraf ./.parcel-cache && PARCEL_WORKERS=0 parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html ./test/bunnies.html",
|
|
48
|
-
"test:node:canvas": "mocha -r tsx -r ./test/node-canvas-global-setup.mjs --extension ts --recursive './test/unit/'
|
|
49
|
-
"test:node:skia": "mocha -r tsx -r ./test/node-skia-global-setup.mjs --extension ts --recursive './test/unit/'
|
|
51
|
+
"test:node:canvas": "mocha -r tsx -r ./test/node-canvas-global-setup.mjs --extension ts --recursive './test/unit/'",
|
|
52
|
+
"test:node:skia": "mocha -r tsx -r ./test/node-skia-global-setup.mjs --extension ts --recursive './test/unit/'",
|
|
50
53
|
"test:node": "npm run test:node:canvas && npm run test:node:skia",
|
|
51
|
-
"tsc": "tsc
|
|
54
|
+
"tsc": "tsc",
|
|
52
55
|
"rollup": "rollup -c",
|
|
53
|
-
"clean": "rimraf ./lib
|
|
56
|
+
"clean": "rimraf ./lib ./test-build",
|
|
54
57
|
"watch": "rollup -c -w",
|
|
55
58
|
"size": "size-limit"
|
|
56
59
|
},
|
|
@@ -73,7 +76,7 @@
|
|
|
73
76
|
],
|
|
74
77
|
"size-limit": [
|
|
75
78
|
{
|
|
76
|
-
"limit": "
|
|
79
|
+
"limit": "48 KB",
|
|
77
80
|
"path": "./lib/index.js"
|
|
78
81
|
},
|
|
79
82
|
{
|
|
@@ -90,16 +93,11 @@
|
|
|
90
93
|
"@types/mocha": "^10.0.10",
|
|
91
94
|
"canvas": "^3.2.1",
|
|
92
95
|
"chai": "6.2.2",
|
|
93
|
-
"filehound": "^1.17.6",
|
|
94
96
|
"gulp": "^5.0.1",
|
|
95
|
-
"gulp-concat": "^2.6.1",
|
|
96
97
|
"gulp-connect": "^5.7.0",
|
|
97
|
-
"gulp-exec": "^5.0.0",
|
|
98
98
|
"gulp-jsdoc3": "^3.0.0",
|
|
99
99
|
"gulp-rename": "^2.1.0",
|
|
100
100
|
"gulp-replace": "^1.1.4",
|
|
101
|
-
"gulp-typescript": "^5.0.1",
|
|
102
|
-
"gulp-uglify": "^3.0.2",
|
|
103
101
|
"gulp-uglify-es": "^3.0.0",
|
|
104
102
|
"gulp-util": "^3.0.8",
|
|
105
103
|
"mocha": "^10",
|
|
@@ -112,8 +110,6 @@
|
|
|
112
110
|
"rollup-plugin-typescript2": "^0.37.0",
|
|
113
111
|
"size-limit": "^11.2.0",
|
|
114
112
|
"skia-canvas": "^3.0.4",
|
|
115
|
-
"ts-mocha": "^11.1.0",
|
|
116
|
-
"ts-node": "^10.9.2",
|
|
117
113
|
"tsx": "^4.21.0",
|
|
118
114
|
"typescript": "^5.9.3"
|
|
119
115
|
},
|