konva 8.3.1 → 8.3.2
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/cmj/Util.js +6 -1
- package/cmj/shapes/Arc.js +16 -24
- package/cmj/shapes/Image.d.ts +1 -1
- package/cmj/shapes/Image.js +2 -1
- package/konva.js +28 -27
- package/konva.min.js +3 -3
- package/lib/Animation.js +0 -1
- package/lib/Canvas.js +0 -1
- package/lib/Container.js +0 -1
- package/lib/Context.js +0 -1
- package/lib/Core.js +0 -1
- package/lib/DragAndDrop.js +0 -1
- package/lib/Factory.js +0 -1
- package/lib/FastLayer.js +0 -1
- package/lib/Global.js +1 -2
- package/lib/Group.js +0 -1
- package/lib/Layer.js +0 -1
- package/lib/Node.js +0 -1
- package/lib/PointerEvents.js +0 -1
- package/lib/Shape.js +0 -1
- package/lib/Stage.js +0 -1
- package/lib/Tween.js +0 -1
- package/lib/Util.js +6 -2
- package/lib/Validators.js +0 -1
- package/lib/_CoreInternals.js +0 -1
- package/lib/_FullInternals.js +0 -1
- package/lib/filters/Blur.js +0 -1
- package/lib/filters/Brighten.js +0 -1
- package/lib/filters/Contrast.js +0 -1
- package/lib/filters/Emboss.js +0 -1
- package/lib/filters/Enhance.js +0 -1
- package/lib/filters/Grayscale.js +0 -1
- package/lib/filters/HSL.js +0 -1
- package/lib/filters/HSV.js +0 -1
- package/lib/filters/Invert.js +0 -1
- package/lib/filters/Kaleidoscope.js +0 -1
- package/lib/filters/Mask.js +0 -1
- package/lib/filters/Noise.js +0 -1
- package/lib/filters/Pixelate.js +0 -1
- package/lib/filters/Posterize.js +0 -1
- package/lib/filters/RGB.js +0 -1
- package/lib/filters/RGBA.js +0 -1
- package/lib/filters/Sepia.js +0 -1
- package/lib/filters/Solarize.js +0 -1
- package/lib/filters/Threshold.js +0 -1
- package/lib/index-node.js +0 -1
- package/lib/index.js +0 -1
- package/lib/shapes/Arc.js +16 -25
- package/lib/shapes/Arrow.js +0 -1
- package/lib/shapes/Circle.js +0 -1
- package/lib/shapes/Ellipse.js +0 -1
- package/lib/shapes/Image.d.ts +1 -1
- package/lib/shapes/Image.js +2 -2
- package/lib/shapes/Label.js +0 -1
- package/lib/shapes/Line.js +0 -1
- package/lib/shapes/Path.js +0 -1
- package/lib/shapes/Rect.js +0 -1
- package/lib/shapes/RegularPolygon.js +0 -1
- package/lib/shapes/Ring.js +0 -1
- package/lib/shapes/Sprite.js +0 -1
- package/lib/shapes/Star.js +0 -1
- package/lib/shapes/Text.js +0 -1
- package/lib/shapes/TextPath.js +0 -1
- package/lib/shapes/Transformer.js +0 -1
- package/lib/shapes/Wedge.js +0 -1
- package/lib/types.js +0 -1
- package/package.json +1 -1
- package/lib/Animation.js.map +0 -1
- package/lib/Canvas.js.map +0 -1
- package/lib/Container.js.map +0 -1
- package/lib/Context.js.map +0 -1
- package/lib/Core.js.map +0 -1
- package/lib/DragAndDrop.js.map +0 -1
- package/lib/Factory.js.map +0 -1
- package/lib/FastLayer.js.map +0 -1
- package/lib/Global.js.map +0 -1
- package/lib/Group.js.map +0 -1
- package/lib/Layer.js.map +0 -1
- package/lib/Node.js.map +0 -1
- package/lib/PointerEvents.js.map +0 -1
- package/lib/Shape.js.map +0 -1
- package/lib/Stage.js.map +0 -1
- package/lib/Tween.js.map +0 -1
- package/lib/Util.js.map +0 -1
- package/lib/Validators.js.map +0 -1
- package/lib/_CoreInternals.js.map +0 -1
- package/lib/_FullInternals.js.map +0 -1
- package/lib/filters/Blur.js.map +0 -1
- package/lib/filters/Brighten.js.map +0 -1
- package/lib/filters/Contrast.js.map +0 -1
- package/lib/filters/Emboss.js.map +0 -1
- package/lib/filters/Enhance.js.map +0 -1
- package/lib/filters/Grayscale.js.map +0 -1
- package/lib/filters/HSL.js.map +0 -1
- package/lib/filters/HSV.js.map +0 -1
- package/lib/filters/Invert.js.map +0 -1
- package/lib/filters/Kaleidoscope.js.map +0 -1
- package/lib/filters/Mask.js.map +0 -1
- package/lib/filters/Noise.js.map +0 -1
- package/lib/filters/Pixelate.js.map +0 -1
- package/lib/filters/Posterize.js.map +0 -1
- package/lib/filters/RGB.js.map +0 -1
- package/lib/filters/RGBA.js.map +0 -1
- package/lib/filters/Sepia.js.map +0 -1
- package/lib/filters/Solarize.js.map +0 -1
- package/lib/filters/Threshold.js.map +0 -1
- package/lib/index-node.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/shapes/Arc.js.map +0 -1
- package/lib/shapes/Arrow.js.map +0 -1
- package/lib/shapes/Circle.js.map +0 -1
- package/lib/shapes/Ellipse.js.map +0 -1
- package/lib/shapes/Image.js.map +0 -1
- package/lib/shapes/Label.js.map +0 -1
- package/lib/shapes/Line.js.map +0 -1
- package/lib/shapes/Path.js.map +0 -1
- package/lib/shapes/Rect.js.map +0 -1
- package/lib/shapes/RegularPolygon.js.map +0 -1
- package/lib/shapes/Ring.js.map +0 -1
- package/lib/shapes/Sprite.js.map +0 -1
- package/lib/shapes/Star.js.map +0 -1
- package/lib/shapes/Text.js.map +0 -1
- package/lib/shapes/TextPath.js.map +0 -1
- package/lib/shapes/Transformer.js.map +0 -1
- package/lib/shapes/Wedge.js.map +0 -1
- package/lib/types.js.map +0 -1
package/cmj/Util.js
CHANGED
|
@@ -478,7 +478,12 @@ exports.Util = {
|
|
|
478
478
|
_rgbaColorToRGBA(str) {
|
|
479
479
|
if (str.indexOf('rgba(') === 0) {
|
|
480
480
|
str = str.match(/rgba\(([^)]+)\)/)[1];
|
|
481
|
-
var parts = str.split(/ *, */).map(
|
|
481
|
+
var parts = str.split(/ *, */).map((n, index) => {
|
|
482
|
+
if (n.slice(-1) === '%') {
|
|
483
|
+
return index === 3 ? parseInt(n) / 100 : (parseInt(n) / 100) * 255;
|
|
484
|
+
}
|
|
485
|
+
return Number(n);
|
|
486
|
+
});
|
|
482
487
|
return {
|
|
483
488
|
r: parts[0],
|
|
484
489
|
g: parts[1],
|
package/cmj/shapes/Arc.js
CHANGED
|
@@ -28,31 +28,23 @@ class Arc extends Shape_1.Shape {
|
|
|
28
28
|
this.outerRadius(height / 2);
|
|
29
29
|
}
|
|
30
30
|
getSelfRect() {
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
for (let i = 0; i < end; i += inc) {
|
|
44
|
-
xs.push(Math.cos(i));
|
|
45
|
-
ys.push(Math.sin(i));
|
|
46
|
-
}
|
|
47
|
-
const minX = Math.round(radius * Math.min(...xs));
|
|
48
|
-
const maxX = Math.round(radius * Math.max(...xs));
|
|
49
|
-
const minY = Math.round(radius * Math.min(...ys));
|
|
50
|
-
const maxY = Math.round(radius * Math.max(...ys));
|
|
31
|
+
const innerRadius = this.innerRadius();
|
|
32
|
+
const outerRadius = this.outerRadius();
|
|
33
|
+
const clockwise = this.clockwise();
|
|
34
|
+
const angle = Global_1.Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());
|
|
35
|
+
const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
|
|
36
|
+
const boundRightRatio = 1;
|
|
37
|
+
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), 3 * Math.PI / 2));
|
|
38
|
+
const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
|
|
39
|
+
const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
|
|
40
|
+
const boundRight = boundRightRatio * (boundRightRatio > 0 ? outerRadius : innerRadius);
|
|
41
|
+
const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
|
|
42
|
+
const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
|
|
51
43
|
return {
|
|
52
|
-
x:
|
|
53
|
-
y:
|
|
54
|
-
width:
|
|
55
|
-
height:
|
|
44
|
+
x: Math.round(boundLeft),
|
|
45
|
+
y: Math.round(clockwise ? -1 * boundBottom : boundTop),
|
|
46
|
+
width: Math.round(boundRight - boundLeft),
|
|
47
|
+
height: Math.round(boundBottom - boundTop)
|
|
56
48
|
};
|
|
57
49
|
}
|
|
58
50
|
}
|
package/cmj/shapes/Image.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare class Image extends Shape<ImageConfig> {
|
|
|
13
13
|
_hitFunc(context: any): void;
|
|
14
14
|
getWidth(): any;
|
|
15
15
|
getHeight(): any;
|
|
16
|
-
static fromURL(url: any, callback: any): void;
|
|
16
|
+
static fromURL(url: any, callback: any, onError?: any): void;
|
|
17
17
|
image: GetSet<CanvasImageSource | undefined, this>;
|
|
18
18
|
crop: GetSet<IRect, this>;
|
|
19
19
|
cropX: GetSet<number, this>;
|
package/cmj/shapes/Image.js
CHANGED
|
@@ -81,7 +81,7 @@ class Image extends Shape_1.Shape {
|
|
|
81
81
|
var _a, _b;
|
|
82
82
|
return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
|
|
83
83
|
}
|
|
84
|
-
static fromURL(url, callback) {
|
|
84
|
+
static fromURL(url, callback, onError = null) {
|
|
85
85
|
var img = Util_1.Util.createImageElement();
|
|
86
86
|
img.onload = function () {
|
|
87
87
|
var image = new Image({
|
|
@@ -89,6 +89,7 @@ class Image extends Shape_1.Shape {
|
|
|
89
89
|
});
|
|
90
90
|
callback(image);
|
|
91
91
|
};
|
|
92
|
+
img.onerror = onError;
|
|
92
93
|
img.crossOrigin = 'Anonymous';
|
|
93
94
|
img.src = url;
|
|
94
95
|
}
|
package/konva.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
* Konva JavaScript Framework v8.3.
|
|
8
|
+
* Konva JavaScript Framework v8.3.2
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: Tue Jan 04 2022
|
|
12
12
|
*
|
|
13
13
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
|
14
14
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
: {};
|
|
36
36
|
const Konva$2 = {
|
|
37
37
|
_global: glob,
|
|
38
|
-
version: '8.3.
|
|
38
|
+
version: '8.3.2',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -794,7 +794,12 @@
|
|
|
794
794
|
_rgbaColorToRGBA(str) {
|
|
795
795
|
if (str.indexOf('rgba(') === 0) {
|
|
796
796
|
str = str.match(/rgba\(([^)]+)\)/)[1];
|
|
797
|
-
var parts = str.split(/ *, */).map(
|
|
797
|
+
var parts = str.split(/ *, */).map((n, index) => {
|
|
798
|
+
if (n.slice(-1) === '%') {
|
|
799
|
+
return index === 3 ? parseInt(n) / 100 : (parseInt(n) / 100) * 255;
|
|
800
|
+
}
|
|
801
|
+
return Number(n);
|
|
802
|
+
});
|
|
798
803
|
return {
|
|
799
804
|
r: parts[0],
|
|
800
805
|
g: parts[1],
|
|
@@ -9721,29 +9726,23 @@
|
|
|
9721
9726
|
this.outerRadius(height / 2);
|
|
9722
9727
|
}
|
|
9723
9728
|
getSelfRect() {
|
|
9724
|
-
const
|
|
9725
|
-
const
|
|
9726
|
-
const
|
|
9727
|
-
const
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
const
|
|
9733
|
-
const
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
ys.push(Math.sin(i));
|
|
9737
|
-
}
|
|
9738
|
-
const minX = Math.round(radius * Math.min(...xs));
|
|
9739
|
-
const maxX = Math.round(radius * Math.max(...xs));
|
|
9740
|
-
const minY = Math.round(radius * Math.min(...ys));
|
|
9741
|
-
const maxY = Math.round(radius * Math.max(...ys));
|
|
9729
|
+
const innerRadius = this.innerRadius();
|
|
9730
|
+
const outerRadius = this.outerRadius();
|
|
9731
|
+
const clockwise = this.clockwise();
|
|
9732
|
+
const angle = Konva$2.getAngle(clockwise ? 360 - this.angle() : this.angle());
|
|
9733
|
+
const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
|
|
9734
|
+
const boundRightRatio = 1;
|
|
9735
|
+
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), 3 * Math.PI / 2));
|
|
9736
|
+
const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
|
|
9737
|
+
const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
|
|
9738
|
+
const boundRight = boundRightRatio * (outerRadius );
|
|
9739
|
+
const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
|
|
9740
|
+
const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
|
|
9742
9741
|
return {
|
|
9743
|
-
x:
|
|
9744
|
-
y:
|
|
9745
|
-
width:
|
|
9746
|
-
height:
|
|
9742
|
+
x: Math.round(boundLeft),
|
|
9743
|
+
y: Math.round(clockwise ? -1 * boundBottom : boundTop),
|
|
9744
|
+
width: Math.round(boundRight - boundLeft),
|
|
9745
|
+
height: Math.round(boundBottom - boundTop)
|
|
9747
9746
|
};
|
|
9748
9747
|
}
|
|
9749
9748
|
}
|
|
@@ -11678,6 +11677,7 @@
|
|
|
11678
11677
|
* @memberof Konva.Image
|
|
11679
11678
|
* @param {String} url image source
|
|
11680
11679
|
* @param {Function} callback with Konva.Image instance as first argument
|
|
11680
|
+
* @param {Function} onError optional error handler
|
|
11681
11681
|
* @example
|
|
11682
11682
|
* Konva.Image.fromURL(imageURL, function(image){
|
|
11683
11683
|
* // image is Konva.Image instance
|
|
@@ -11685,7 +11685,7 @@
|
|
|
11685
11685
|
* layer.draw();
|
|
11686
11686
|
* });
|
|
11687
11687
|
*/
|
|
11688
|
-
static fromURL(url, callback) {
|
|
11688
|
+
static fromURL(url, callback, onError = null) {
|
|
11689
11689
|
var img = Util.createImageElement();
|
|
11690
11690
|
img.onload = function () {
|
|
11691
11691
|
var image = new Image({
|
|
@@ -11693,6 +11693,7 @@
|
|
|
11693
11693
|
});
|
|
11694
11694
|
callback(image);
|
|
11695
11695
|
};
|
|
11696
|
+
img.onerror = onError;
|
|
11696
11697
|
img.crossOrigin = 'Anonymous';
|
|
11697
11698
|
img.src = url;
|
|
11698
11699
|
}
|