konva 9.3.14 → 9.3.16
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/konva.js +754 -737
- package/konva.min.js +3 -3
- package/lib/Animation.js +1 -1
- package/lib/BezierFunctions.js +1 -2
- package/lib/Canvas.js +9 -9
- package/lib/Container.d.ts +1 -1
- package/lib/Container.js +29 -29
- package/lib/Context.d.ts +2 -2
- package/lib/Context.js +26 -26
- package/lib/DragAndDrop.d.ts +2 -2
- package/lib/DragAndDrop.js +6 -4
- package/lib/Factory.js +16 -16
- package/lib/Global.js +1 -1
- package/lib/Group.js +1 -1
- package/lib/Layer.js +17 -17
- package/lib/Node.d.ts +4 -4
- package/lib/Node.js +87 -87
- package/lib/PointerEvents.js +5 -6
- package/lib/Shape.js +31 -31
- package/lib/Stage.d.ts +3 -3
- package/lib/Stage.js +28 -28
- package/lib/Tween.js +21 -21
- package/lib/Util.d.ts +4 -4
- package/lib/Util.js +62 -62
- package/lib/Validators.js +16 -17
- package/lib/_CoreInternals.d.ts +8 -8
- package/lib/_FullInternals.d.ts +8 -8
- package/lib/filters/Blur.js +6 -6
- package/lib/filters/Brighten.js +1 -1
- package/lib/filters/Contrast.js +2 -2
- package/lib/filters/Emboss.js +19 -19
- package/lib/filters/Enhance.js +4 -4
- package/lib/filters/Grayscale.js +1 -1
- package/lib/filters/HSL.js +6 -6
- package/lib/filters/HSV.js +7 -7
- package/lib/filters/Invert.js +1 -1
- package/lib/filters/Kaleidoscope.js +20 -20
- package/lib/filters/Mask.js +57 -57
- package/lib/filters/Noise.js +2 -2
- package/lib/filters/Pixelate.js +1 -1
- package/lib/filters/Posterize.js +1 -1
- package/lib/filters/RGB.js +1 -1
- package/lib/filters/RGBA.js +3 -3
- package/lib/filters/Sepia.js +1 -1
- package/lib/filters/Solarize.js +8 -7
- package/lib/filters/Threshold.js +2 -2
- package/lib/shapes/Arc.js +1 -1
- package/lib/shapes/Arrow.js +10 -10
- package/lib/shapes/Ellipse.js +1 -1
- package/lib/shapes/Image.js +3 -3
- package/lib/shapes/Label.d.ts +1 -1
- package/lib/shapes/Label.js +6 -6
- package/lib/shapes/Line.d.ts +1 -1
- package/lib/shapes/Line.js +14 -14
- package/lib/shapes/Path.d.ts +8 -8
- package/lib/shapes/Path.js +68 -68
- package/lib/shapes/Rect.js +1 -1
- package/lib/shapes/RegularPolygon.js +6 -6
- package/lib/shapes/Ring.js +1 -1
- package/lib/shapes/Sprite.js +9 -9
- package/lib/shapes/Star.js +5 -5
- package/lib/shapes/Text.d.ts +13 -13
- package/lib/shapes/Text.js +52 -38
- package/lib/shapes/TextPath.d.ts +2 -2
- package/lib/shapes/TextPath.js +23 -23
- package/lib/shapes/Transformer.d.ts +1 -1
- package/lib/shapes/Transformer.js +63 -63
- package/package.json +2 -5
package/lib/Util.js
CHANGED
|
@@ -27,7 +27,7 @@ class Transform {
|
|
|
27
27
|
tr.m[5] = this.m[5];
|
|
28
28
|
}
|
|
29
29
|
point(point) {
|
|
30
|
-
|
|
30
|
+
const m = this.m;
|
|
31
31
|
return {
|
|
32
32
|
x: m[0] * point.x + m[2] * point.y + m[4],
|
|
33
33
|
y: m[1] * point.x + m[3] * point.y + m[5],
|
|
@@ -46,12 +46,12 @@ class Transform {
|
|
|
46
46
|
return this;
|
|
47
47
|
}
|
|
48
48
|
rotate(rad) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
const c = Math.cos(rad);
|
|
50
|
+
const s = Math.sin(rad);
|
|
51
|
+
const m11 = this.m[0] * c + this.m[2] * s;
|
|
52
|
+
const m12 = this.m[1] * c + this.m[3] * s;
|
|
53
|
+
const m21 = this.m[0] * -s + this.m[2] * c;
|
|
54
|
+
const m22 = this.m[1] * -s + this.m[3] * c;
|
|
55
55
|
this.m[0] = m11;
|
|
56
56
|
this.m[1] = m12;
|
|
57
57
|
this.m[2] = m21;
|
|
@@ -65,10 +65,10 @@ class Transform {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
skew(sx, sy) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
const m11 = this.m[0] + this.m[2] * sy;
|
|
69
|
+
const m12 = this.m[1] + this.m[3] * sy;
|
|
70
|
+
const m21 = this.m[2] + this.m[0] * sx;
|
|
71
|
+
const m22 = this.m[3] + this.m[1] * sx;
|
|
72
72
|
this.m[0] = m11;
|
|
73
73
|
this.m[1] = m12;
|
|
74
74
|
this.m[2] = m21;
|
|
@@ -76,12 +76,12 @@ class Transform {
|
|
|
76
76
|
return this;
|
|
77
77
|
}
|
|
78
78
|
multiply(matrix) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
const m11 = this.m[0] * matrix.m[0] + this.m[2] * matrix.m[1];
|
|
80
|
+
const m12 = this.m[1] * matrix.m[0] + this.m[3] * matrix.m[1];
|
|
81
|
+
const m21 = this.m[0] * matrix.m[2] + this.m[2] * matrix.m[3];
|
|
82
|
+
const m22 = this.m[1] * matrix.m[2] + this.m[3] * matrix.m[3];
|
|
83
|
+
const dx = this.m[0] * matrix.m[4] + this.m[2] * matrix.m[5] + this.m[4];
|
|
84
|
+
const dy = this.m[1] * matrix.m[4] + this.m[3] * matrix.m[5] + this.m[5];
|
|
85
85
|
this.m[0] = m11;
|
|
86
86
|
this.m[1] = m12;
|
|
87
87
|
this.m[2] = m21;
|
|
@@ -91,13 +91,13 @@ class Transform {
|
|
|
91
91
|
return this;
|
|
92
92
|
}
|
|
93
93
|
invert() {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
const d = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]);
|
|
95
|
+
const m0 = this.m[3] * d;
|
|
96
|
+
const m1 = -this.m[1] * d;
|
|
97
|
+
const m2 = -this.m[2] * d;
|
|
98
|
+
const m3 = this.m[0] * d;
|
|
99
|
+
const m4 = d * (this.m[2] * this.m[5] - this.m[3] * this.m[4]);
|
|
100
|
+
const m5 = d * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);
|
|
101
101
|
this.m[0] = m0;
|
|
102
102
|
this.m[1] = m1;
|
|
103
103
|
this.m[2] = m2;
|
|
@@ -110,14 +110,14 @@ class Transform {
|
|
|
110
110
|
return this.m;
|
|
111
111
|
}
|
|
112
112
|
decompose() {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
const a = this.m[0];
|
|
114
|
+
const b = this.m[1];
|
|
115
|
+
const c = this.m[2];
|
|
116
|
+
const d = this.m[3];
|
|
117
|
+
const e = this.m[4];
|
|
118
|
+
const f = this.m[5];
|
|
119
|
+
const delta = a * d - b * c;
|
|
120
|
+
const result = {
|
|
121
121
|
x: e,
|
|
122
122
|
y: f,
|
|
123
123
|
rotation: 0,
|
|
@@ -127,7 +127,7 @@ class Transform {
|
|
|
127
127
|
skewY: 0,
|
|
128
128
|
};
|
|
129
129
|
if (a != 0 || b != 0) {
|
|
130
|
-
|
|
130
|
+
const r = Math.sqrt(a * a + b * b);
|
|
131
131
|
result.rotation = b > 0 ? Math.acos(a / r) : -Math.acos(a / r);
|
|
132
132
|
result.scaleX = r;
|
|
133
133
|
result.scaleY = delta / r;
|
|
@@ -135,7 +135,7 @@ class Transform {
|
|
|
135
135
|
result.skewY = 0;
|
|
136
136
|
}
|
|
137
137
|
else if (c != 0 || d != 0) {
|
|
138
|
-
|
|
138
|
+
const s = Math.sqrt(c * c + d * d);
|
|
139
139
|
result.rotation =
|
|
140
140
|
Math.PI / 2 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s));
|
|
141
141
|
result.scaleX = delta / s;
|
|
@@ -150,7 +150,7 @@ class Transform {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
exports.Transform = Transform;
|
|
153
|
-
|
|
153
|
+
let OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
|
|
154
154
|
aliceblue: [240, 248, 255],
|
|
155
155
|
antiquewhite: [250, 235, 215],
|
|
156
156
|
aqua: [0, 255, 255],
|
|
@@ -336,7 +336,7 @@ exports.Util = {
|
|
|
336
336
|
if (typeof selector !== 'string') {
|
|
337
337
|
return false;
|
|
338
338
|
}
|
|
339
|
-
|
|
339
|
+
const firstChar = selector[0];
|
|
340
340
|
return (firstChar === '#' ||
|
|
341
341
|
firstChar === '.' ||
|
|
342
342
|
firstChar === firstChar.toUpperCase());
|
|
@@ -365,7 +365,7 @@ exports.Util = {
|
|
|
365
365
|
}
|
|
366
366
|
},
|
|
367
367
|
createCanvasElement() {
|
|
368
|
-
|
|
368
|
+
const canvas = document.createElement('canvas');
|
|
369
369
|
try {
|
|
370
370
|
canvas.style = canvas.style || {};
|
|
371
371
|
}
|
|
@@ -384,7 +384,7 @@ exports.Util = {
|
|
|
384
384
|
return false;
|
|
385
385
|
},
|
|
386
386
|
_urlToImage(url, callback) {
|
|
387
|
-
|
|
387
|
+
const imageObj = exports.Util.createImageElement();
|
|
388
388
|
imageObj.onload = function () {
|
|
389
389
|
callback(imageObj);
|
|
390
390
|
};
|
|
@@ -395,7 +395,7 @@ exports.Util = {
|
|
|
395
395
|
},
|
|
396
396
|
_hexToRgb(hex) {
|
|
397
397
|
hex = hex.replace(HASH, EMPTY_STRING);
|
|
398
|
-
|
|
398
|
+
const bigint = parseInt(hex, 16);
|
|
399
399
|
return {
|
|
400
400
|
r: (bigint >> 16) & 255,
|
|
401
401
|
g: (bigint >> 8) & 255,
|
|
@@ -403,14 +403,14 @@ exports.Util = {
|
|
|
403
403
|
};
|
|
404
404
|
},
|
|
405
405
|
getRandomColor() {
|
|
406
|
-
|
|
406
|
+
let randColor = ((Math.random() * 0xffffff) << 0).toString(16);
|
|
407
407
|
while (randColor.length < 6) {
|
|
408
408
|
randColor = ZERO + randColor;
|
|
409
409
|
}
|
|
410
410
|
return HASH + randColor;
|
|
411
411
|
},
|
|
412
412
|
getRGB(color) {
|
|
413
|
-
|
|
413
|
+
let rgb;
|
|
414
414
|
if (color in COLORS) {
|
|
415
415
|
rgb = COLORS[color];
|
|
416
416
|
return {
|
|
@@ -450,7 +450,7 @@ exports.Util = {
|
|
|
450
450
|
exports.Util._hslColorToRGBA(str));
|
|
451
451
|
},
|
|
452
452
|
_namedColorToRBA(str) {
|
|
453
|
-
|
|
453
|
+
const c = COLORS[str.toLowerCase()];
|
|
454
454
|
if (!c) {
|
|
455
455
|
return null;
|
|
456
456
|
}
|
|
@@ -464,7 +464,7 @@ exports.Util = {
|
|
|
464
464
|
_rgbColorToRGBA(str) {
|
|
465
465
|
if (str.indexOf('rgb(') === 0) {
|
|
466
466
|
str = str.match(/rgb\(([^)]+)\)/)[1];
|
|
467
|
-
|
|
467
|
+
const parts = str.split(/ *, */).map(Number);
|
|
468
468
|
return {
|
|
469
469
|
r: parts[0],
|
|
470
470
|
g: parts[1],
|
|
@@ -476,7 +476,7 @@ exports.Util = {
|
|
|
476
476
|
_rgbaColorToRGBA(str) {
|
|
477
477
|
if (str.indexOf('rgba(') === 0) {
|
|
478
478
|
str = str.match(/rgba\(([^)]+)\)/)[1];
|
|
479
|
-
|
|
479
|
+
const parts = str.split(/ *, */).map((n, index) => {
|
|
480
480
|
if (n.slice(-1) === '%') {
|
|
481
481
|
return index === 3 ? parseInt(n) / 100 : (parseInt(n) / 100) * 255;
|
|
482
482
|
}
|
|
@@ -593,8 +593,8 @@ exports.Util = {
|
|
|
593
593
|
r2.y + r2.height < r1.y);
|
|
594
594
|
},
|
|
595
595
|
cloneObject(obj) {
|
|
596
|
-
|
|
597
|
-
for (
|
|
596
|
+
const retObj = {};
|
|
597
|
+
for (const key in obj) {
|
|
598
598
|
if (this._isPlainObject(obj[key])) {
|
|
599
599
|
retObj[key] = this.cloneObject(obj[key]);
|
|
600
600
|
}
|
|
@@ -643,7 +643,7 @@ exports.Util = {
|
|
|
643
643
|
console.warn(KONVA_WARNING + str);
|
|
644
644
|
},
|
|
645
645
|
each(obj, func) {
|
|
646
|
-
for (
|
|
646
|
+
for (const key in obj) {
|
|
647
647
|
func(key, obj[key]);
|
|
648
648
|
}
|
|
649
649
|
},
|
|
@@ -651,15 +651,15 @@ exports.Util = {
|
|
|
651
651
|
return left <= val && val < right;
|
|
652
652
|
},
|
|
653
653
|
_getProjectionToSegment(x1, y1, x2, y2, x3, y3) {
|
|
654
|
-
|
|
655
|
-
|
|
654
|
+
let x, y, dist;
|
|
655
|
+
const pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
|
|
656
656
|
if (pd2 == 0) {
|
|
657
657
|
x = x1;
|
|
658
658
|
y = y1;
|
|
659
659
|
dist = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);
|
|
660
660
|
}
|
|
661
661
|
else {
|
|
662
|
-
|
|
662
|
+
const u = ((x3 - x1) * (x2 - x1) + (y3 - y1) * (y2 - y1)) / pd2;
|
|
663
663
|
if (u < 0) {
|
|
664
664
|
x = x1;
|
|
665
665
|
y = y1;
|
|
@@ -679,15 +679,15 @@ exports.Util = {
|
|
|
679
679
|
return [x, y, dist];
|
|
680
680
|
},
|
|
681
681
|
_getProjectionToLine(pt, line, isClosed) {
|
|
682
|
-
|
|
683
|
-
|
|
682
|
+
const pc = exports.Util.cloneObject(pt);
|
|
683
|
+
let dist = Number.MAX_VALUE;
|
|
684
684
|
line.forEach(function (p1, i) {
|
|
685
685
|
if (!isClosed && i === line.length - 1) {
|
|
686
686
|
return;
|
|
687
687
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
688
|
+
const p2 = line[(i + 1) % line.length];
|
|
689
|
+
const proj = exports.Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);
|
|
690
|
+
const px = proj[0], py = proj[1], pdist = proj[2];
|
|
691
691
|
if (pdist < dist) {
|
|
692
692
|
pc.x = px;
|
|
693
693
|
pc.y = py;
|
|
@@ -697,9 +697,9 @@ exports.Util = {
|
|
|
697
697
|
return pc;
|
|
698
698
|
},
|
|
699
699
|
_prepareArrayForTween(startArray, endArray, isClosed) {
|
|
700
|
-
|
|
700
|
+
let n, start = [], end = [];
|
|
701
701
|
if (startArray.length > endArray.length) {
|
|
702
|
-
|
|
702
|
+
const temp = endArray;
|
|
703
703
|
endArray = startArray;
|
|
704
704
|
startArray = temp;
|
|
705
705
|
}
|
|
@@ -715,18 +715,18 @@ exports.Util = {
|
|
|
715
715
|
y: endArray[n + 1],
|
|
716
716
|
});
|
|
717
717
|
}
|
|
718
|
-
|
|
718
|
+
const newStart = [];
|
|
719
719
|
end.forEach(function (point) {
|
|
720
|
-
|
|
720
|
+
const pr = exports.Util._getProjectionToLine(point, start, isClosed);
|
|
721
721
|
newStart.push(pr.x);
|
|
722
722
|
newStart.push(pr.y);
|
|
723
723
|
});
|
|
724
724
|
return newStart;
|
|
725
725
|
},
|
|
726
726
|
_prepareToStringify(obj) {
|
|
727
|
-
|
|
727
|
+
let desc;
|
|
728
728
|
obj.visitedByCircularReferenceRemoval = true;
|
|
729
|
-
for (
|
|
729
|
+
for (const key in obj) {
|
|
730
730
|
if (!(obj.hasOwnProperty(key) && obj[key] && typeof obj[key] == 'object')) {
|
|
731
731
|
continue;
|
|
732
732
|
}
|
|
@@ -753,7 +753,7 @@ exports.Util = {
|
|
|
753
753
|
return obj;
|
|
754
754
|
},
|
|
755
755
|
_assign(target, source) {
|
|
756
|
-
for (
|
|
756
|
+
for (const key in source) {
|
|
757
757
|
target[key] = source[key];
|
|
758
758
|
}
|
|
759
759
|
return target;
|
package/lib/Validators.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RGBComponent = RGBComponent;
|
|
4
|
+
exports.alphaComponent = alphaComponent;
|
|
5
|
+
exports.getNumberValidator = getNumberValidator;
|
|
6
|
+
exports.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;
|
|
7
|
+
exports.getNumberOrAutoValidator = getNumberOrAutoValidator;
|
|
8
|
+
exports.getStringValidator = getStringValidator;
|
|
9
|
+
exports.getStringOrGradientValidator = getStringOrGradientValidator;
|
|
10
|
+
exports.getFunctionValidator = getFunctionValidator;
|
|
11
|
+
exports.getNumberArrayValidator = getNumberArrayValidator;
|
|
12
|
+
exports.getBooleanValidator = getBooleanValidator;
|
|
13
|
+
exports.getComponentValidator = getComponentValidator;
|
|
4
14
|
const Global_1 = require("./Global");
|
|
5
15
|
const Util_1 = require("./Util");
|
|
6
16
|
function _formatValue(val) {
|
|
@@ -24,7 +34,6 @@ function RGBComponent(val) {
|
|
|
24
34
|
}
|
|
25
35
|
return Math.round(val);
|
|
26
36
|
}
|
|
27
|
-
exports.RGBComponent = RGBComponent;
|
|
28
37
|
function alphaComponent(val) {
|
|
29
38
|
if (val > 1) {
|
|
30
39
|
return 1;
|
|
@@ -34,7 +43,6 @@ function alphaComponent(val) {
|
|
|
34
43
|
}
|
|
35
44
|
return val;
|
|
36
45
|
}
|
|
37
|
-
exports.alphaComponent = alphaComponent;
|
|
38
46
|
function getNumberValidator() {
|
|
39
47
|
if (Global_1.Konva.isUnminified) {
|
|
40
48
|
return function (val, attr) {
|
|
@@ -48,12 +56,11 @@ function getNumberValidator() {
|
|
|
48
56
|
};
|
|
49
57
|
}
|
|
50
58
|
}
|
|
51
|
-
exports.getNumberValidator = getNumberValidator;
|
|
52
59
|
function getNumberOrArrayOfNumbersValidator(noOfElements) {
|
|
53
60
|
if (Global_1.Konva.isUnminified) {
|
|
54
61
|
return function (val, attr) {
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
const isNumber = Util_1.Util._isNumber(val);
|
|
63
|
+
const isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements;
|
|
57
64
|
if (!isNumber && !isValidArray) {
|
|
58
65
|
Util_1.Util.warn(_formatValue(val) +
|
|
59
66
|
' is a not valid value for "' +
|
|
@@ -66,12 +73,11 @@ function getNumberOrArrayOfNumbersValidator(noOfElements) {
|
|
|
66
73
|
};
|
|
67
74
|
}
|
|
68
75
|
}
|
|
69
|
-
exports.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;
|
|
70
76
|
function getNumberOrAutoValidator() {
|
|
71
77
|
if (Global_1.Konva.isUnminified) {
|
|
72
78
|
return function (val, attr) {
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
const isNumber = Util_1.Util._isNumber(val);
|
|
80
|
+
const isAuto = val === 'auto';
|
|
75
81
|
if (!(isNumber || isAuto)) {
|
|
76
82
|
Util_1.Util.warn(_formatValue(val) +
|
|
77
83
|
' is a not valid value for "' +
|
|
@@ -82,7 +88,6 @@ function getNumberOrAutoValidator() {
|
|
|
82
88
|
};
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
|
-
exports.getNumberOrAutoValidator = getNumberOrAutoValidator;
|
|
86
91
|
function getStringValidator() {
|
|
87
92
|
if (Global_1.Konva.isUnminified) {
|
|
88
93
|
return function (val, attr) {
|
|
@@ -96,7 +101,6 @@ function getStringValidator() {
|
|
|
96
101
|
};
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
|
-
exports.getStringValidator = getStringValidator;
|
|
100
104
|
function getStringOrGradientValidator() {
|
|
101
105
|
if (Global_1.Konva.isUnminified) {
|
|
102
106
|
return function (val, attr) {
|
|
@@ -113,7 +117,6 @@ function getStringOrGradientValidator() {
|
|
|
113
117
|
};
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
|
-
exports.getStringOrGradientValidator = getStringOrGradientValidator;
|
|
117
120
|
function getFunctionValidator() {
|
|
118
121
|
if (Global_1.Konva.isUnminified) {
|
|
119
122
|
return function (val, attr) {
|
|
@@ -127,7 +130,6 @@ function getFunctionValidator() {
|
|
|
127
130
|
};
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
|
-
exports.getFunctionValidator = getFunctionValidator;
|
|
131
133
|
function getNumberArrayValidator() {
|
|
132
134
|
if (Global_1.Konva.isUnminified) {
|
|
133
135
|
return function (val, attr) {
|
|
@@ -156,11 +158,10 @@ function getNumberArrayValidator() {
|
|
|
156
158
|
};
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
|
-
exports.getNumberArrayValidator = getNumberArrayValidator;
|
|
160
161
|
function getBooleanValidator() {
|
|
161
162
|
if (Global_1.Konva.isUnminified) {
|
|
162
163
|
return function (val, attr) {
|
|
163
|
-
|
|
164
|
+
const isBool = val === true || val === false;
|
|
164
165
|
if (!isBool) {
|
|
165
166
|
Util_1.Util.warn(_formatValue(val) +
|
|
166
167
|
' is a not valid value for "' +
|
|
@@ -171,7 +172,6 @@ function getBooleanValidator() {
|
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
|
-
exports.getBooleanValidator = getBooleanValidator;
|
|
175
175
|
function getComponentValidator(components) {
|
|
176
176
|
if (Global_1.Konva.isUnminified) {
|
|
177
177
|
return function (val, attr) {
|
|
@@ -189,4 +189,3 @@ function getComponentValidator(components) {
|
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
exports.getComponentValidator = getComponentValidator;
|
package/lib/_CoreInternals.d.ts
CHANGED
|
@@ -48,11 +48,11 @@ export declare const Konva: {
|
|
|
48
48
|
_isElement(obj: any): obj is Element;
|
|
49
49
|
_isFunction(obj: any): boolean;
|
|
50
50
|
_isPlainObject(obj: any): boolean;
|
|
51
|
-
_isArray(obj: any): obj is any
|
|
51
|
+
_isArray(obj: any): obj is Array<any>;
|
|
52
52
|
_isNumber(obj: any): obj is number;
|
|
53
53
|
_isString(obj: any): obj is string;
|
|
54
54
|
_isBoolean(obj: any): obj is boolean;
|
|
55
|
-
isObject(val: any): val is
|
|
55
|
+
isObject(val: any): val is object;
|
|
56
56
|
isValidSelector(selector: any): boolean;
|
|
57
57
|
_sign(number: number): 1 | -1;
|
|
58
58
|
requestAnimFrame(callback: Function): void;
|
|
@@ -120,7 +120,7 @@ export declare const Konva: {
|
|
|
120
120
|
} | undefined;
|
|
121
121
|
haveIntersection(r1: import("./types").IRect, r2: import("./types.js").IRect): boolean;
|
|
122
122
|
cloneObject<Any>(obj: Any): Any;
|
|
123
|
-
cloneArray(arr: any
|
|
123
|
+
cloneArray(arr: Array<any>): any[];
|
|
124
124
|
degToRad(deg: number): number;
|
|
125
125
|
radToDeg(rad: number): number;
|
|
126
126
|
_degToRad(deg: number): number;
|
|
@@ -130,13 +130,13 @@ export declare const Konva: {
|
|
|
130
130
|
throw(str: string): never;
|
|
131
131
|
error(str: string): void;
|
|
132
132
|
warn(str: string): void;
|
|
133
|
-
each(obj:
|
|
133
|
+
each(obj: object, func: Function): void;
|
|
134
134
|
_inRange(val: number, left: number, right: number): boolean;
|
|
135
135
|
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
|
|
136
|
-
_getProjectionToLine(pt: import("./types").Vector2d, line: import("./types").Vector2d
|
|
136
|
+
_getProjectionToLine(pt: import("./types").Vector2d, line: Array<import("./types").Vector2d>, isClosed: boolean): import("./types.js").Vector2d;
|
|
137
137
|
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
|
|
138
138
|
_prepareToStringify<T>(obj: any): T | null;
|
|
139
|
-
_assign<
|
|
139
|
+
_assign<T, U>(target: T, source: U): T & U;
|
|
140
140
|
_getFirstPointerId(evt: any): any;
|
|
141
141
|
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
|
|
142
142
|
drawRoundedRectPath(context: Context, width: number, height: number, cornerRadius: number | number[]): void;
|
|
@@ -154,10 +154,10 @@ export declare const Konva: {
|
|
|
154
154
|
justDragged: boolean;
|
|
155
155
|
readonly node: Node<import("./Node.js").NodeConfig> | undefined;
|
|
156
156
|
_dragElements: Map<number, {
|
|
157
|
-
node: Node
|
|
157
|
+
node: Node;
|
|
158
158
|
startPointerPos: import("./types.js").Vector2d;
|
|
159
159
|
offset: import("./types.js").Vector2d;
|
|
160
|
-
pointerId?: number
|
|
160
|
+
pointerId?: number;
|
|
161
161
|
dragStatus: "ready" | "dragging" | "stopped";
|
|
162
162
|
}>;
|
|
163
163
|
_drag(evt: any): void;
|
package/lib/_FullInternals.d.ts
CHANGED
|
@@ -53,11 +53,11 @@ export declare const Konva: {
|
|
|
53
53
|
_isElement(obj: any): obj is Element;
|
|
54
54
|
_isFunction(obj: any): boolean;
|
|
55
55
|
_isPlainObject(obj: any): boolean;
|
|
56
|
-
_isArray(obj: any): obj is any
|
|
56
|
+
_isArray(obj: any): obj is Array<any>;
|
|
57
57
|
_isNumber(obj: any): obj is number;
|
|
58
58
|
_isString(obj: any): obj is string;
|
|
59
59
|
_isBoolean(obj: any): obj is boolean;
|
|
60
|
-
isObject(val: any): val is
|
|
60
|
+
isObject(val: any): val is object;
|
|
61
61
|
isValidSelector(selector: any): boolean;
|
|
62
62
|
_sign(number: number): 1 | -1;
|
|
63
63
|
requestAnimFrame(callback: Function): void;
|
|
@@ -125,7 +125,7 @@ export declare const Konva: {
|
|
|
125
125
|
} | undefined;
|
|
126
126
|
haveIntersection(r1: import("./types").IRect, r2: import("./types.js").IRect): boolean;
|
|
127
127
|
cloneObject<Any>(obj: Any): Any;
|
|
128
|
-
cloneArray(arr: any
|
|
128
|
+
cloneArray(arr: Array<any>): any[];
|
|
129
129
|
degToRad(deg: number): number;
|
|
130
130
|
radToDeg(rad: number): number;
|
|
131
131
|
_degToRad(deg: number): number;
|
|
@@ -135,13 +135,13 @@ export declare const Konva: {
|
|
|
135
135
|
throw(str: string): never;
|
|
136
136
|
error(str: string): void;
|
|
137
137
|
warn(str: string): void;
|
|
138
|
-
each(obj:
|
|
138
|
+
each(obj: object, func: Function): void;
|
|
139
139
|
_inRange(val: number, left: number, right: number): boolean;
|
|
140
140
|
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
|
|
141
|
-
_getProjectionToLine(pt: import("./types").Vector2d, line: import("./types").Vector2d
|
|
141
|
+
_getProjectionToLine(pt: import("./types").Vector2d, line: Array<import("./types").Vector2d>, isClosed: boolean): import("./types.js").Vector2d;
|
|
142
142
|
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
|
|
143
143
|
_prepareToStringify<T>(obj: any): T | null;
|
|
144
|
-
_assign<
|
|
144
|
+
_assign<T, U>(target: T, source: U): T & U;
|
|
145
145
|
_getFirstPointerId(evt: any): any;
|
|
146
146
|
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
|
|
147
147
|
drawRoundedRectPath(context: import("./Context.js").Context, width: number, height: number, cornerRadius: number | number[]): void;
|
|
@@ -159,10 +159,10 @@ export declare const Konva: {
|
|
|
159
159
|
justDragged: boolean;
|
|
160
160
|
readonly node: import("./Node").Node<import("./Node.js").NodeConfig> | undefined;
|
|
161
161
|
_dragElements: Map<number, {
|
|
162
|
-
node: import("./Node
|
|
162
|
+
node: import("./Node.js").Node;
|
|
163
163
|
startPointerPos: import("./types.js").Vector2d;
|
|
164
164
|
offset: import("./types.js").Vector2d;
|
|
165
|
-
pointerId?: number
|
|
165
|
+
pointerId?: number;
|
|
166
166
|
dragStatus: "ready" | "dragging" | "stopped";
|
|
167
167
|
}>;
|
|
168
168
|
_drag(evt: any): void;
|
package/lib/filters/Blur.js
CHANGED
|
@@ -11,7 +11,7 @@ function BlurStack() {
|
|
|
11
11
|
this.a = 0;
|
|
12
12
|
this.next = null;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const mul_table = [
|
|
15
15
|
512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292,
|
|
16
16
|
512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292,
|
|
17
17
|
273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259,
|
|
@@ -30,7 +30,7 @@ var mul_table = [
|
|
|
30
30
|
329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,
|
|
31
31
|
289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259,
|
|
32
32
|
];
|
|
33
|
-
|
|
33
|
+
const shg_table = [
|
|
34
34
|
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17,
|
|
35
35
|
17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
|
|
36
36
|
19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
|
@@ -47,9 +47,9 @@ var shg_table = [
|
|
|
47
47
|
24, 24, 24, 24, 24, 24, 24,
|
|
48
48
|
];
|
|
49
49
|
function filterGaussBlurRGBA(imageData, radius) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const pixels = imageData.data, width = imageData.width, height = imageData.height;
|
|
51
|
+
let x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
|
|
52
|
+
let div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), stackEnd = null, stack = stackStart, stackIn = null, stackOut = null, mul_sum = mul_table[radius], shg_sum = shg_table[radius];
|
|
53
53
|
for (i = 1; i < div; i++) {
|
|
54
54
|
stack = stack.next = new BlurStack();
|
|
55
55
|
if (i === radiusPlus1) {
|
|
@@ -229,7 +229,7 @@ function filterGaussBlurRGBA(imageData, radius) {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
const Blur = function Blur(imageData) {
|
|
232
|
-
|
|
232
|
+
const radius = Math.round(this.blurRadius());
|
|
233
233
|
if (radius > 0) {
|
|
234
234
|
filterGaussBlurRGBA(imageData, radius);
|
|
235
235
|
}
|
package/lib/filters/Brighten.js
CHANGED
|
@@ -5,7 +5,7 @@ const Factory_1 = require("../Factory");
|
|
|
5
5
|
const Node_1 = require("../Node");
|
|
6
6
|
const Validators_1 = require("../Validators");
|
|
7
7
|
const Brighten = function (imageData) {
|
|
8
|
-
|
|
8
|
+
let brightness = this.brightness() * 255, data = imageData.data, len = data.length, i;
|
|
9
9
|
for (i = 0; i < len; i += 4) {
|
|
10
10
|
data[i] += brightness;
|
|
11
11
|
data[i + 1] += brightness;
|
package/lib/filters/Contrast.js
CHANGED
|
@@ -5,8 +5,8 @@ const Factory_1 = require("../Factory");
|
|
|
5
5
|
const Node_1 = require("../Node");
|
|
6
6
|
const Validators_1 = require("../Validators");
|
|
7
7
|
const Contrast = function (imageData) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const adjust = Math.pow((this.contrast() + 100) / 100, 2);
|
|
9
|
+
let data = imageData.data, nPixels = data.length, red = 150, green = 150, blue = 150, i;
|
|
10
10
|
for (i = 0; i < nPixels; i += 4) {
|
|
11
11
|
red = data[i];
|
|
12
12
|
green = data[i + 1];
|