modern-canvas 0.7.12 → 0.7.13
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/dist/index.cjs +179 -91
- package/dist/index.d.cts +44 -7
- package/dist/index.d.mts +44 -7
- package/dist/index.d.ts +44 -7
- package/dist/index.js +32 -32
- package/dist/index.mjs +179 -91
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1950,10 +1950,23 @@ class Rect2 {
|
|
|
1950
1950
|
switch (args.length) {
|
|
1951
1951
|
case 0:
|
|
1952
1952
|
break;
|
|
1953
|
-
case 1:
|
|
1954
|
-
|
|
1955
|
-
|
|
1953
|
+
case 1: {
|
|
1954
|
+
const arg = args[0];
|
|
1955
|
+
if (arg instanceof Rect2) {
|
|
1956
|
+
position.set(arg.position);
|
|
1957
|
+
size.set(arg.size);
|
|
1958
|
+
} else {
|
|
1959
|
+
const xx = arg.map((p) => p[0]);
|
|
1960
|
+
const yy = arg.map((p) => p[1]);
|
|
1961
|
+
const minX = Math.min(...xx);
|
|
1962
|
+
const maxX = Math.max(...xx);
|
|
1963
|
+
const minY = Math.min(...yy);
|
|
1964
|
+
const maxY = Math.max(...yy);
|
|
1965
|
+
position.set(minX, minY);
|
|
1966
|
+
size.set(maxX - minX, maxY - minY);
|
|
1967
|
+
}
|
|
1956
1968
|
break;
|
|
1969
|
+
}
|
|
1957
1970
|
case 2:
|
|
1958
1971
|
position.set(args[0]);
|
|
1959
1972
|
size.set(args[1]);
|
|
@@ -1975,6 +1988,14 @@ class Rect2 {
|
|
|
1975
1988
|
);
|
|
1976
1989
|
return this;
|
|
1977
1990
|
}
|
|
1991
|
+
toMinmax() {
|
|
1992
|
+
return {
|
|
1993
|
+
minX: this.position.x,
|
|
1994
|
+
minY: this.position.y,
|
|
1995
|
+
maxX: this.end.x,
|
|
1996
|
+
maxY: this.end.y
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1978
1999
|
toArray() {
|
|
1979
2000
|
return [this.x, this.y, this.width, this.height];
|
|
1980
2001
|
}
|
|
@@ -2141,6 +2162,30 @@ class Transform2D extends Matrix3 {
|
|
|
2141
2162
|
b * x + d * y + ty
|
|
2142
2163
|
];
|
|
2143
2164
|
}
|
|
2165
|
+
decompose(pivot = { x: 0, y: 0 }, output = {
|
|
2166
|
+
position: { x: 0, y: 0 },
|
|
2167
|
+
scale: { x: 0, y: 0 },
|
|
2168
|
+
skew: { x: 0, y: 0 },
|
|
2169
|
+
rotation: 0
|
|
2170
|
+
}) {
|
|
2171
|
+
const { a, b, c, d, tx, ty } = this.toObject();
|
|
2172
|
+
const skewX = -Math.atan2(-c, d);
|
|
2173
|
+
const skewY = Math.atan2(b, a);
|
|
2174
|
+
const delta = Math.abs(skewX + skewY);
|
|
2175
|
+
if (delta < 1e-5 || Math.abs(PI_2 - delta) < 1e-5) {
|
|
2176
|
+
output.rotation = skewY;
|
|
2177
|
+
output.skew.x = output.skew.y = 0;
|
|
2178
|
+
} else {
|
|
2179
|
+
output.rotation = 0;
|
|
2180
|
+
output.skew.x = skewX;
|
|
2181
|
+
output.skew.y = skewY;
|
|
2182
|
+
}
|
|
2183
|
+
output.scale.x = Math.sqrt(a * a + b * b);
|
|
2184
|
+
output.scale.y = Math.sqrt(c * c + d * d);
|
|
2185
|
+
output.position.x = tx + (pivot.x * a + pivot.y * c);
|
|
2186
|
+
output.position.y = ty + (pivot.x * b + pivot.y * d);
|
|
2187
|
+
return output;
|
|
2188
|
+
}
|
|
2144
2189
|
inverse() {
|
|
2145
2190
|
return this.clone().invert();
|
|
2146
2191
|
}
|
|
@@ -2149,7 +2194,17 @@ class Transform2D extends Matrix3 {
|
|
|
2149
2194
|
return a === 1 && b === 0 && c === 0 && d === 1 && tx === 0 && ty === 0;
|
|
2150
2195
|
}
|
|
2151
2196
|
toObject() {
|
|
2152
|
-
const [
|
|
2197
|
+
const [
|
|
2198
|
+
a,
|
|
2199
|
+
c,
|
|
2200
|
+
tx,
|
|
2201
|
+
b,
|
|
2202
|
+
d,
|
|
2203
|
+
ty,
|
|
2204
|
+
,
|
|
2205
|
+
,
|
|
2206
|
+
tz
|
|
2207
|
+
] = this._array;
|
|
2153
2208
|
return { a, c, tx, b, d, ty, tz };
|
|
2154
2209
|
}
|
|
2155
2210
|
}
|
|
@@ -6891,10 +6946,10 @@ __decorateClass$O([
|
|
|
6891
6946
|
modernIdoc.property()
|
|
6892
6947
|
], exports.Effect.prototype, "effectMode", 2);
|
|
6893
6948
|
__decorateClass$O([
|
|
6894
|
-
modernIdoc.property()
|
|
6949
|
+
modernIdoc.property({ fallback: "" })
|
|
6895
6950
|
], exports.Effect.prototype, "glsl", 2);
|
|
6896
6951
|
__decorateClass$O([
|
|
6897
|
-
modernIdoc.property()
|
|
6952
|
+
modernIdoc.property({ fallback: "" })
|
|
6898
6953
|
], exports.Effect.prototype, "glslSrc", 2);
|
|
6899
6954
|
exports.Effect = __decorateClass$O([
|
|
6900
6955
|
customNode("Effect")
|
|
@@ -7170,25 +7225,27 @@ exports.Node2D = class Node2D extends exports.CanvasItem {
|
|
|
7170
7225
|
const parent = this.getParent();
|
|
7171
7226
|
if (parent?.globalTransform) {
|
|
7172
7227
|
this._parentTransformDirtyId = parent.globalTransform.dirtyId;
|
|
7173
|
-
this.
|
|
7228
|
+
this.globalPosition.set(
|
|
7229
|
+
parent.globalPosition.x + this.position.x,
|
|
7230
|
+
parent.globalPosition.y + this.position.y
|
|
7231
|
+
);
|
|
7232
|
+
this.globalScale.set(
|
|
7233
|
+
parent.globalScale.x * this.scale.x,
|
|
7234
|
+
parent.globalScale.y * this.scale.y
|
|
7235
|
+
);
|
|
7236
|
+
this.globalSkew.set(
|
|
7237
|
+
parent.globalSkew.x * this.skew.x,
|
|
7238
|
+
parent.globalSkew.y * this.skew.y
|
|
7239
|
+
);
|
|
7174
7240
|
this.globalRotation = parent.globalRotation + this.rotation;
|
|
7175
7241
|
parent.globalTransform.multiply(this.transform, this.globalTransform);
|
|
7176
7242
|
} else {
|
|
7243
|
+
this.globalPosition.copy(this.position);
|
|
7177
7244
|
this.globalScale.copy(this.scale);
|
|
7245
|
+
this.globalSkew.copy(this.skew);
|
|
7178
7246
|
this.globalRotation = this.rotation;
|
|
7179
7247
|
this.globalTransform.copy(this.transform);
|
|
7180
7248
|
}
|
|
7181
|
-
const [
|
|
7182
|
-
a,
|
|
7183
|
-
c,
|
|
7184
|
-
tx,
|
|
7185
|
-
b,
|
|
7186
|
-
d,
|
|
7187
|
-
ty
|
|
7188
|
-
] = this.globalTransform.toArray();
|
|
7189
|
-
this.globalPosition.set(tx, ty);
|
|
7190
|
-
this.globalSkew.x = Math.atan2(c, a) - this.globalRotation;
|
|
7191
|
-
this.globalSkew.y = Math.atan2(b, d) - this.globalRotation;
|
|
7192
7249
|
this.requestRelayout();
|
|
7193
7250
|
}
|
|
7194
7251
|
_transformVertices(vertices, vertTransform) {
|
|
@@ -7575,28 +7632,28 @@ void main(void) {
|
|
|
7575
7632
|
}`
|
|
7576
7633
|
}));
|
|
7577
7634
|
__decorateClass$H([
|
|
7578
|
-
modernIdoc.property()
|
|
7635
|
+
modernIdoc.property({ fallback: 1 })
|
|
7579
7636
|
], exports.ColorAdjustEffect.prototype, "saturation", 2);
|
|
7580
7637
|
__decorateClass$H([
|
|
7581
|
-
modernIdoc.property()
|
|
7638
|
+
modernIdoc.property({ fallback: 1 })
|
|
7582
7639
|
], exports.ColorAdjustEffect.prototype, "contrast", 2);
|
|
7583
7640
|
__decorateClass$H([
|
|
7584
|
-
modernIdoc.property()
|
|
7641
|
+
modernIdoc.property({ fallback: 1 })
|
|
7585
7642
|
], exports.ColorAdjustEffect.prototype, "brightness", 2);
|
|
7586
7643
|
__decorateClass$H([
|
|
7587
|
-
modernIdoc.property()
|
|
7644
|
+
modernIdoc.property({ fallback: 1 })
|
|
7588
7645
|
], exports.ColorAdjustEffect.prototype, "red", 2);
|
|
7589
7646
|
__decorateClass$H([
|
|
7590
|
-
modernIdoc.property()
|
|
7647
|
+
modernIdoc.property({ fallback: 1 })
|
|
7591
7648
|
], exports.ColorAdjustEffect.prototype, "green", 2);
|
|
7592
7649
|
__decorateClass$H([
|
|
7593
|
-
modernIdoc.property()
|
|
7650
|
+
modernIdoc.property({ fallback: 1 })
|
|
7594
7651
|
], exports.ColorAdjustEffect.prototype, "blue", 2);
|
|
7595
7652
|
__decorateClass$H([
|
|
7596
|
-
modernIdoc.property()
|
|
7653
|
+
modernIdoc.property({ fallback: 1 })
|
|
7597
7654
|
], exports.ColorAdjustEffect.prototype, "alpha", 2);
|
|
7598
7655
|
__decorateClass$H([
|
|
7599
|
-
modernIdoc.property()
|
|
7656
|
+
modernIdoc.property({ fallback: 1 })
|
|
7600
7657
|
], exports.ColorAdjustEffect.prototype, "gamma", 2);
|
|
7601
7658
|
exports.ColorAdjustEffect = __decorateClass$H([
|
|
7602
7659
|
customNode("ColorAdjustEffect")
|
|
@@ -7782,10 +7839,10 @@ void main(void) {
|
|
|
7782
7839
|
}`
|
|
7783
7840
|
}));
|
|
7784
7841
|
__decorateClass$F([
|
|
7785
|
-
modernIdoc.property()
|
|
7842
|
+
modernIdoc.property({ default: () => [] })
|
|
7786
7843
|
], exports.ColorOverlayEffect.prototype, "colors", 2);
|
|
7787
7844
|
__decorateClass$F([
|
|
7788
|
-
modernIdoc.property()
|
|
7845
|
+
modernIdoc.property({ fallback: 0.5 })
|
|
7789
7846
|
], exports.ColorOverlayEffect.prototype, "alpha", 2);
|
|
7790
7847
|
exports.ColorOverlayEffect = __decorateClass$F([
|
|
7791
7848
|
customNode("ColorOverlayEffect")
|
|
@@ -7867,10 +7924,10 @@ void main(void) {
|
|
|
7867
7924
|
}`
|
|
7868
7925
|
}));
|
|
7869
7926
|
__decorateClass$E([
|
|
7870
|
-
modernIdoc.property()
|
|
7927
|
+
modernIdoc.property({ default: () => [] })
|
|
7871
7928
|
], exports.ColorRemoveEffect.prototype, "colors", 2);
|
|
7872
7929
|
__decorateClass$E([
|
|
7873
|
-
modernIdoc.property()
|
|
7930
|
+
modernIdoc.property({ fallback: 0.5 })
|
|
7874
7931
|
], exports.ColorRemoveEffect.prototype, "epsilon", 2);
|
|
7875
7932
|
exports.ColorRemoveEffect = __decorateClass$E([
|
|
7876
7933
|
customNode("ColorRemoveEffect")
|
|
@@ -7974,10 +8031,10 @@ void main(void) {
|
|
|
7974
8031
|
}`
|
|
7975
8032
|
}));
|
|
7976
8033
|
__decorateClass$D([
|
|
7977
|
-
modernIdoc.property()
|
|
8034
|
+
modernIdoc.property({ default: () => [] })
|
|
7978
8035
|
], exports.ColorReplaceEffect.prototype, "colors", 2);
|
|
7979
8036
|
__decorateClass$D([
|
|
7980
|
-
modernIdoc.property()
|
|
8037
|
+
modernIdoc.property({ fallback: 0.05 })
|
|
7981
8038
|
], exports.ColorReplaceEffect.prototype, "epsilon", 2);
|
|
7982
8039
|
exports.ColorReplaceEffect = __decorateClass$D([
|
|
7983
8040
|
customNode("ColorReplaceEffect")
|
|
@@ -8098,10 +8155,10 @@ void main(void) {
|
|
|
8098
8155
|
frag: frag$2
|
|
8099
8156
|
}));
|
|
8100
8157
|
__decorateClass$C([
|
|
8101
|
-
modernIdoc.property({
|
|
8158
|
+
modernIdoc.property({ fallback: 4 })
|
|
8102
8159
|
], exports.GaussianBlurEffect.prototype, "strength", 2);
|
|
8103
8160
|
__decorateClass$C([
|
|
8104
|
-
modernIdoc.property({
|
|
8161
|
+
modernIdoc.property({ fallback: 3 })
|
|
8105
8162
|
], exports.GaussianBlurEffect.prototype, "quality", 2);
|
|
8106
8163
|
exports.GaussianBlurEffect = __decorateClass$C([
|
|
8107
8164
|
customNode("GaussianBlurEffect")
|
|
@@ -8180,19 +8237,19 @@ void main(void) {
|
|
|
8180
8237
|
}`
|
|
8181
8238
|
}));
|
|
8182
8239
|
__decorateClass$B([
|
|
8183
|
-
modernIdoc.property()
|
|
8240
|
+
modernIdoc.property({ fallback: "#000000FF" })
|
|
8184
8241
|
], exports.DropShadowEffect.prototype, "color", 2);
|
|
8185
8242
|
__decorateClass$B([
|
|
8186
|
-
modernIdoc.property()
|
|
8243
|
+
modernIdoc.property({ fallback: 4 })
|
|
8187
8244
|
], exports.DropShadowEffect.prototype, "blur", 2);
|
|
8188
8245
|
__decorateClass$B([
|
|
8189
|
-
modernIdoc.property()
|
|
8246
|
+
modernIdoc.property({ fallback: 4 })
|
|
8190
8247
|
], exports.DropShadowEffect.prototype, "offsetX", 2);
|
|
8191
8248
|
__decorateClass$B([
|
|
8192
|
-
modernIdoc.property()
|
|
8249
|
+
modernIdoc.property({ fallback: 4 })
|
|
8193
8250
|
], exports.DropShadowEffect.prototype, "offsetY", 2);
|
|
8194
8251
|
__decorateClass$B([
|
|
8195
|
-
modernIdoc.property()
|
|
8252
|
+
modernIdoc.property({ fallback: false })
|
|
8196
8253
|
], exports.DropShadowEffect.prototype, "shadowOnly", 2);
|
|
8197
8254
|
exports.DropShadowEffect = __decorateClass$B([
|
|
8198
8255
|
customNode("DropShadowEffect")
|
|
@@ -8252,7 +8309,7 @@ void main(void) {
|
|
|
8252
8309
|
}`
|
|
8253
8310
|
}));
|
|
8254
8311
|
__decorateClass$A([
|
|
8255
|
-
modernIdoc.property()
|
|
8312
|
+
modernIdoc.property({ fallback: 5 })
|
|
8256
8313
|
], exports.EmbossEffect.prototype, "strength", 2);
|
|
8257
8314
|
exports.EmbossEffect = __decorateClass$A([
|
|
8258
8315
|
customNode("EmbossEffect")
|
|
@@ -8441,31 +8498,31 @@ void main(void) {
|
|
|
8441
8498
|
}`
|
|
8442
8499
|
}));
|
|
8443
8500
|
__decorateClass$z([
|
|
8444
|
-
modernIdoc.property()
|
|
8501
|
+
modernIdoc.property({ fallback: 10 })
|
|
8445
8502
|
], exports.GlitchEffect.prototype, "slices", 2);
|
|
8446
8503
|
__decorateClass$z([
|
|
8447
|
-
modernIdoc.property()
|
|
8504
|
+
modernIdoc.property({ fallback: 512 })
|
|
8448
8505
|
], exports.GlitchEffect.prototype, "sampleSize", 2);
|
|
8449
8506
|
__decorateClass$z([
|
|
8450
|
-
modernIdoc.property()
|
|
8507
|
+
modernIdoc.property({ fallback: 100 })
|
|
8451
8508
|
], exports.GlitchEffect.prototype, "offset", 2);
|
|
8452
8509
|
__decorateClass$z([
|
|
8453
|
-
modernIdoc.property()
|
|
8510
|
+
modernIdoc.property({ fallback: 0 })
|
|
8454
8511
|
], exports.GlitchEffect.prototype, "direction", 2);
|
|
8455
8512
|
__decorateClass$z([
|
|
8456
|
-
modernIdoc.property()
|
|
8513
|
+
modernIdoc.property({ fallback: 2 })
|
|
8457
8514
|
], exports.GlitchEffect.prototype, "fillMode", 2);
|
|
8458
8515
|
__decorateClass$z([
|
|
8459
|
-
modernIdoc.property()
|
|
8516
|
+
modernIdoc.property({ fallback: 0 })
|
|
8460
8517
|
], exports.GlitchEffect.prototype, "seed", 2);
|
|
8461
8518
|
__decorateClass$z([
|
|
8462
|
-
modernIdoc.property()
|
|
8519
|
+
modernIdoc.property({ default: () => [2, 2] })
|
|
8463
8520
|
], exports.GlitchEffect.prototype, "red", 2);
|
|
8464
8521
|
__decorateClass$z([
|
|
8465
|
-
modernIdoc.property()
|
|
8522
|
+
modernIdoc.property({ default: () => [-10, 4] })
|
|
8466
8523
|
], exports.GlitchEffect.prototype, "green", 2);
|
|
8467
8524
|
__decorateClass$z([
|
|
8468
|
-
modernIdoc.property()
|
|
8525
|
+
modernIdoc.property({ default: () => [10, -4] })
|
|
8469
8526
|
], exports.GlitchEffect.prototype, "blue", 2);
|
|
8470
8527
|
exports.GlitchEffect = __decorateClass$z([
|
|
8471
8528
|
customNode("GlitchEffect")
|
|
@@ -8658,25 +8715,25 @@ void main(void) {
|
|
|
8658
8715
|
}`
|
|
8659
8716
|
}));
|
|
8660
8717
|
__decorateClass$y([
|
|
8661
|
-
modernIdoc.property()
|
|
8718
|
+
modernIdoc.property({ fallback: 0 })
|
|
8662
8719
|
], exports.GodrayEffect.prototype, "time", 2);
|
|
8663
8720
|
__decorateClass$y([
|
|
8664
|
-
modernIdoc.property()
|
|
8721
|
+
modernIdoc.property({ fallback: 30 })
|
|
8665
8722
|
], exports.GodrayEffect.prototype, "angle", 2);
|
|
8666
8723
|
__decorateClass$y([
|
|
8667
|
-
modernIdoc.property()
|
|
8724
|
+
modernIdoc.property({ fallback: 0.5 })
|
|
8668
8725
|
], exports.GodrayEffect.prototype, "gain", 2);
|
|
8669
8726
|
__decorateClass$y([
|
|
8670
|
-
modernIdoc.property()
|
|
8727
|
+
modernIdoc.property({ fallback: 2.5 })
|
|
8671
8728
|
], exports.GodrayEffect.prototype, "lacunarity", 2);
|
|
8672
8729
|
__decorateClass$y([
|
|
8673
|
-
modernIdoc.property()
|
|
8730
|
+
modernIdoc.property({ fallback: true })
|
|
8674
8731
|
], exports.GodrayEffect.prototype, "parallel", 2);
|
|
8675
8732
|
__decorateClass$y([
|
|
8676
|
-
modernIdoc.property()
|
|
8733
|
+
modernIdoc.property({ default: () => [0, 0] })
|
|
8677
8734
|
], exports.GodrayEffect.prototype, "center", 2);
|
|
8678
8735
|
__decorateClass$y([
|
|
8679
|
-
modernIdoc.property()
|
|
8736
|
+
modernIdoc.property({ fallback: 1 })
|
|
8680
8737
|
], exports.GodrayEffect.prototype, "alpha", 2);
|
|
8681
8738
|
exports.GodrayEffect = __decorateClass$y([
|
|
8682
8739
|
customNode("GodrayEffect")
|
|
@@ -8780,13 +8837,13 @@ void main() {
|
|
|
8780
8837
|
}
|
|
8781
8838
|
};
|
|
8782
8839
|
__decorateClass$x([
|
|
8783
|
-
modernIdoc.property()
|
|
8840
|
+
modernIdoc.property({ fallback: 4 })
|
|
8784
8841
|
], exports.KawaseBlurEffect.prototype, "strength", 2);
|
|
8785
8842
|
__decorateClass$x([
|
|
8786
|
-
modernIdoc.property()
|
|
8843
|
+
modernIdoc.property({ fallback: 3 })
|
|
8787
8844
|
], exports.KawaseBlurEffect.prototype, "quality", 2);
|
|
8788
8845
|
__decorateClass$x([
|
|
8789
|
-
modernIdoc.property()
|
|
8846
|
+
modernIdoc.property({ default: () => [1, 1] })
|
|
8790
8847
|
], exports.KawaseBlurEffect.prototype, "pixelSize", 2);
|
|
8791
8848
|
exports.KawaseBlurEffect = __decorateClass$x([
|
|
8792
8849
|
customNode("KawaseBlurEffect")
|
|
@@ -8892,7 +8949,7 @@ __decorateClass$w([
|
|
|
8892
8949
|
modernIdoc.property({ protected: true })
|
|
8893
8950
|
], exports.MaskEffect.prototype, "texture", 2);
|
|
8894
8951
|
__decorateClass$w([
|
|
8895
|
-
modernIdoc.property({
|
|
8952
|
+
modernIdoc.property({ fallback: "" })
|
|
8896
8953
|
], exports.MaskEffect.prototype, "src", 2);
|
|
8897
8954
|
exports.MaskEffect = __decorateClass$w([
|
|
8898
8955
|
customNode("MaskEffect")
|
|
@@ -8994,25 +9051,25 @@ void main() {
|
|
|
8994
9051
|
__publicField$7(exports.OutlineEffect, "MIN_SAMPLES", 1);
|
|
8995
9052
|
__publicField$7(exports.OutlineEffect, "MAX_SAMPLES", 100);
|
|
8996
9053
|
__decorateClass$v([
|
|
8997
|
-
modernIdoc.property()
|
|
9054
|
+
modernIdoc.property({ fallback: "#000000ff" })
|
|
8998
9055
|
], exports.OutlineEffect.prototype, "color", 2);
|
|
8999
9056
|
__decorateClass$v([
|
|
9000
|
-
modernIdoc.property()
|
|
9057
|
+
modernIdoc.property({ fallback: 1 })
|
|
9001
9058
|
], exports.OutlineEffect.prototype, "width", 2);
|
|
9002
9059
|
__decorateClass$v([
|
|
9003
|
-
modernIdoc.property()
|
|
9060
|
+
modernIdoc.property({ fallback: "solid" })
|
|
9004
9061
|
], exports.OutlineEffect.prototype, "style", 2);
|
|
9005
9062
|
__decorateClass$v([
|
|
9006
9063
|
modernIdoc.property()
|
|
9007
9064
|
], exports.OutlineEffect.prototype, "image", 2);
|
|
9008
9065
|
__decorateClass$v([
|
|
9009
|
-
modernIdoc.property()
|
|
9066
|
+
modernIdoc.property({ fallback: 1 })
|
|
9010
9067
|
], exports.OutlineEffect.prototype, "opacity", 2);
|
|
9011
9068
|
__decorateClass$v([
|
|
9012
|
-
modernIdoc.property()
|
|
9069
|
+
modernIdoc.property({ fallback: 0.1 })
|
|
9013
9070
|
], exports.OutlineEffect.prototype, "quality", 2);
|
|
9014
9071
|
__decorateClass$v([
|
|
9015
|
-
modernIdoc.property()
|
|
9072
|
+
modernIdoc.property({ fallback: false })
|
|
9016
9073
|
], exports.OutlineEffect.prototype, "knockout", 2);
|
|
9017
9074
|
exports.OutlineEffect = __decorateClass$v([
|
|
9018
9075
|
customNode("OutlineEffect")
|
|
@@ -9083,7 +9140,7 @@ void main(void) {
|
|
|
9083
9140
|
}`
|
|
9084
9141
|
}));
|
|
9085
9142
|
__decorateClass$u([
|
|
9086
|
-
modernIdoc.property()
|
|
9143
|
+
modernIdoc.property({ fallback: 10 })
|
|
9087
9144
|
], exports.PixelateEffect.prototype, "strength", 2);
|
|
9088
9145
|
exports.PixelateEffect = __decorateClass$u([
|
|
9089
9146
|
customNode("PixelateEffect")
|
|
@@ -9214,13 +9271,13 @@ __decorateClass$t([
|
|
|
9214
9271
|
modernIdoc.property()
|
|
9215
9272
|
], exports.ZoomBlurEffect.prototype, "center", 2);
|
|
9216
9273
|
__decorateClass$t([
|
|
9217
|
-
modernIdoc.property()
|
|
9274
|
+
modernIdoc.property({ fallback: 20 })
|
|
9218
9275
|
], exports.ZoomBlurEffect.prototype, "innerRadius", 2);
|
|
9219
9276
|
__decorateClass$t([
|
|
9220
|
-
modernIdoc.property()
|
|
9277
|
+
modernIdoc.property({ fallback: -1 })
|
|
9221
9278
|
], exports.ZoomBlurEffect.prototype, "radius", 2);
|
|
9222
9279
|
__decorateClass$t([
|
|
9223
|
-
modernIdoc.property()
|
|
9280
|
+
modernIdoc.property({ fallback: 0.1 })
|
|
9224
9281
|
], exports.ZoomBlurEffect.prototype, "strength", 2);
|
|
9225
9282
|
exports.ZoomBlurEffect = __decorateClass$t([
|
|
9226
9283
|
customNode("ZoomBlurEffect")
|
|
@@ -9962,36 +10019,67 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
|
|
|
9962
10019
|
this._updateOverflow();
|
|
9963
10020
|
}
|
|
9964
10021
|
getRect() {
|
|
9965
|
-
|
|
10022
|
+
return this.getGlobalAabb();
|
|
10023
|
+
}
|
|
10024
|
+
_getPointArray() {
|
|
10025
|
+
const { width, height } = this.size;
|
|
9966
10026
|
const x1 = 0;
|
|
9967
10027
|
const y1 = 0;
|
|
9968
|
-
const x2 = x1 +
|
|
9969
|
-
const y2 = y1 +
|
|
9970
|
-
|
|
9971
|
-
const points = [
|
|
10028
|
+
const x2 = x1 + width;
|
|
10029
|
+
const y2 = y1 + height;
|
|
10030
|
+
return [
|
|
9972
10031
|
[x1, y1],
|
|
9973
10032
|
[x1, y2],
|
|
9974
10033
|
[x2, y1],
|
|
9975
10034
|
[x2, y2]
|
|
9976
|
-
]
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
b * p[0] + d * p[1] + ty
|
|
9980
|
-
];
|
|
9981
|
-
});
|
|
9982
|
-
const xx = points.map((p) => p[0]);
|
|
9983
|
-
const yy = points.map((p) => p[1]);
|
|
9984
|
-
const minX = Math.min(...xx);
|
|
9985
|
-
const maxX = Math.max(...xx);
|
|
9986
|
-
const minY = Math.min(...yy);
|
|
9987
|
-
const maxY = Math.max(...yy);
|
|
10035
|
+
];
|
|
10036
|
+
}
|
|
10037
|
+
getAabb() {
|
|
9988
10038
|
return new Rect2(
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
maxY - minY
|
|
10039
|
+
this._getPointArray().map((p) => {
|
|
10040
|
+
return this.transform.applyToPoint(p[0], p[1]);
|
|
10041
|
+
})
|
|
9993
10042
|
);
|
|
9994
10043
|
}
|
|
10044
|
+
getGlobalAabb() {
|
|
10045
|
+
return new Rect2(
|
|
10046
|
+
this._getPointArray().map((p) => {
|
|
10047
|
+
return this.globalTransform.applyToPoint(p[0], p[1]);
|
|
10048
|
+
})
|
|
10049
|
+
);
|
|
10050
|
+
}
|
|
10051
|
+
getObb() {
|
|
10052
|
+
const origin = this.getTransformOrigin();
|
|
10053
|
+
const _origin = this.transform.applyToPoint(origin.x, origin.y);
|
|
10054
|
+
const offset = [_origin[0] - origin.x, _origin[1] - origin.y];
|
|
10055
|
+
return {
|
|
10056
|
+
rect: new Rect2(
|
|
10057
|
+
this._getPointArray().map((p) => {
|
|
10058
|
+
return [
|
|
10059
|
+
p[0] + offset[0],
|
|
10060
|
+
p[1] + offset[1]
|
|
10061
|
+
];
|
|
10062
|
+
})
|
|
10063
|
+
),
|
|
10064
|
+
rotation: this.rotation
|
|
10065
|
+
};
|
|
10066
|
+
}
|
|
10067
|
+
getGlobalObb() {
|
|
10068
|
+
const origin = this.getTransformOrigin();
|
|
10069
|
+
const _origin = this.globalTransform.applyToPoint(origin.x, origin.y);
|
|
10070
|
+
const offset = [_origin[0] - origin.x, _origin[1] - origin.y];
|
|
10071
|
+
return {
|
|
10072
|
+
rect: new Rect2(
|
|
10073
|
+
this._getPointArray().map((p) => {
|
|
10074
|
+
return [
|
|
10075
|
+
p[0] + offset[0],
|
|
10076
|
+
p[1] + offset[1]
|
|
10077
|
+
];
|
|
10078
|
+
})
|
|
10079
|
+
),
|
|
10080
|
+
rotation: this.globalRotation
|
|
10081
|
+
};
|
|
10082
|
+
}
|
|
9995
10083
|
// protected _rectsOverlap(r1: any, r2: any): boolean {
|
|
9996
10084
|
// return (
|
|
9997
10085
|
// r1.x < r2.x + r2.width
|
package/dist/index.d.cts
CHANGED
|
@@ -498,9 +498,16 @@ declare class Rect2 {
|
|
|
498
498
|
readonly position: Vector2;
|
|
499
499
|
readonly size: Vector2;
|
|
500
500
|
constructor(from: Rect2);
|
|
501
|
+
constructor(pointArray: [number, number][]);
|
|
501
502
|
constructor(position: Vector2, size: Vector2);
|
|
502
503
|
constructor(x: number, y: number, width: number, height: number);
|
|
503
504
|
update(): this;
|
|
505
|
+
toMinmax(): {
|
|
506
|
+
minX: number;
|
|
507
|
+
minY: number;
|
|
508
|
+
maxX: number;
|
|
509
|
+
maxY: number;
|
|
510
|
+
};
|
|
504
511
|
toArray(): number[];
|
|
505
512
|
toJSON(): {
|
|
506
513
|
x: number;
|
|
@@ -510,7 +517,7 @@ declare class Rect2 {
|
|
|
510
517
|
};
|
|
511
518
|
}
|
|
512
519
|
|
|
513
|
-
interface
|
|
520
|
+
interface TransformObject {
|
|
514
521
|
a: number;
|
|
515
522
|
c: number;
|
|
516
523
|
tx: number;
|
|
@@ -519,6 +526,21 @@ interface Transform2DObject {
|
|
|
519
526
|
ty: number;
|
|
520
527
|
tz: number;
|
|
521
528
|
}
|
|
529
|
+
interface TransformableObject {
|
|
530
|
+
position: {
|
|
531
|
+
x: number;
|
|
532
|
+
y: number;
|
|
533
|
+
};
|
|
534
|
+
scale: {
|
|
535
|
+
x: number;
|
|
536
|
+
y: number;
|
|
537
|
+
};
|
|
538
|
+
skew: {
|
|
539
|
+
x: number;
|
|
540
|
+
y: number;
|
|
541
|
+
};
|
|
542
|
+
rotation: number;
|
|
543
|
+
}
|
|
522
544
|
/**
|
|
523
545
|
* Transform
|
|
524
546
|
*
|
|
@@ -552,10 +574,14 @@ declare class Transform2D extends Matrix3 {
|
|
|
552
574
|
protected _rotateToScale(rad: number): number;
|
|
553
575
|
protected _rotate3d(x: number, y: number, z: number, rad: number): number[];
|
|
554
576
|
makeRotation(theta: number): this;
|
|
555
|
-
applyToPoint(x: number, y: number): number
|
|
577
|
+
applyToPoint(x: number, y: number): [number, number];
|
|
578
|
+
decompose(pivot?: {
|
|
579
|
+
x: number;
|
|
580
|
+
y: number;
|
|
581
|
+
}, output?: TransformableObject): TransformableObject;
|
|
556
582
|
inverse(): this;
|
|
557
583
|
isIdentity(): boolean;
|
|
558
|
-
toObject():
|
|
584
|
+
toObject(): TransformObject;
|
|
559
585
|
}
|
|
560
586
|
|
|
561
587
|
declare const DEG_TO_RAD: number;
|
|
@@ -2125,6 +2151,17 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
|
|
|
2125
2151
|
getTransform(cb?: (transform: Transform2D) => void): Transform2D;
|
|
2126
2152
|
updateGlobalTransform(): void;
|
|
2127
2153
|
getRect(): Rect2;
|
|
2154
|
+
protected _getPointArray(): [number, number][];
|
|
2155
|
+
getAabb(): Rect2;
|
|
2156
|
+
getGlobalAabb(): Rect2;
|
|
2157
|
+
getObb(): {
|
|
2158
|
+
rect: Rect2;
|
|
2159
|
+
rotation: number;
|
|
2160
|
+
};
|
|
2161
|
+
getGlobalObb(): {
|
|
2162
|
+
rect: Rect2;
|
|
2163
|
+
rotation: number;
|
|
2164
|
+
};
|
|
2128
2165
|
protected _updateOverflow(): void;
|
|
2129
2166
|
protected _draw(): void;
|
|
2130
2167
|
protected _drawContent(): void;
|
|
@@ -2713,7 +2750,7 @@ interface ColorFilterEffectProperties {
|
|
|
2713
2750
|
}
|
|
2714
2751
|
declare class ColorFilterEffect extends Effect {
|
|
2715
2752
|
static material: Material;
|
|
2716
|
-
filter
|
|
2753
|
+
filter?: string;
|
|
2717
2754
|
protected _colorMatrix: ColorMatrix;
|
|
2718
2755
|
constructor(properties?: Partial<ColorFilterEffectProperties>, children?: Node[]);
|
|
2719
2756
|
apply(renderer: WebGLRenderer, source: Viewport): void;
|
|
@@ -2881,7 +2918,7 @@ interface MaskEffectProperties extends EffectProperties {
|
|
|
2881
2918
|
}
|
|
2882
2919
|
declare class MaskEffect extends Effect {
|
|
2883
2920
|
static material: Material;
|
|
2884
|
-
texture
|
|
2921
|
+
texture?: Texture2D<ImageBitmap>;
|
|
2885
2922
|
src: string;
|
|
2886
2923
|
constructor(properties?: Partial<MaskEffectProperties>, children?: Node[]);
|
|
2887
2924
|
load(): Promise<void>;
|
|
@@ -2932,7 +2969,7 @@ interface ZoomBlurEffectProperties extends EffectProperties {
|
|
|
2932
2969
|
}
|
|
2933
2970
|
declare class ZoomBlurEffect extends Effect {
|
|
2934
2971
|
static material: Material;
|
|
2935
|
-
center
|
|
2972
|
+
center?: number[];
|
|
2936
2973
|
innerRadius: number;
|
|
2937
2974
|
radius: number;
|
|
2938
2975
|
strength: number;
|
|
@@ -3269,4 +3306,4 @@ interface RenderOptions {
|
|
|
3269
3306
|
declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
|
|
3270
3307
|
|
|
3271
3308
|
export { AnimatedTexture, Animation, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, BaseElement2D, BaseElement2DBackground, BaseElement2DFill, BaseElement2DForeground, BaseElement2DOutline, BaseElement2DShadow, BaseElement2DShape, BaseElement2DStyle, BaseElement2DText, Camera2D, CanvasContext, CanvasItem, CanvasItemEditor, CanvasTexture, Color, ColorAdjustEffect, ColorFilterEffect, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, Control, CoreObject, DEG_TO_RAD, DEVICE_PIXEL_RATIO, DropShadowEffect, Effect, EffectMaterial, Element2D, Element2DStyle, EmbossEffect, Engine, FlexElement2D, FlexElement2DStyle, FlexLayout, FontLoader, GIFLoader, GaussianBlurEffect, Geometry, GlitchEffect, GodrayEffect, GradientTexture, HTMLAudio, HTMLAudioContext, HTMLSound, IN_BROWSER, Image2D, ImageTexture, IndexBuffer, Input, InputEvent, JSONLoader, KawaseBlurEffect, KawaseTransition, KeyboardInputEvent, LeftEraseTransition, Loader, Lottie2D, LottieLoader, MainLoop, MaskEffect, Material, Matrix, Matrix2, Matrix3, Matrix4, MouseInputEvent, Node, Node2D, OutlineEffect, PI, PI_2, PixelateEffect, PixelsTexture, PointerInputEvent, Projection2D, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Range, RawWeakMap, Rect2, RefCounted, Renderer, Resource, Ruler, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, Scaler, SceneTree, ScrollBar, TextLoader, Texture2D, TextureLoader, TextureRect2D, Ticker, TiltShiftTransition, Timeline, TimelineNode, Transform2D, TransformRect2D, Transition, TwistTransition, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, VertexAttribute, VertexBuffer, Video2D, VideoLoader, VideoTexture, Viewport, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, WebGLBufferModule, WebGLFramebufferModule, WebGLMaskModule, WebGLModule, WebGLProgramModule, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, WebGLTextureModule, WebGLVertexArrayModule, WebGLViewportModule, WebSound, WheelInputEvent, Window, XScrollBar, YScrollBar, ZoomBlurEffect, assets, clamp, clampFrag, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, frag, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCSSFilter, parseCSSTransform, parseCSSTransformOrigin, parseCssFunctions, parseCssProperty, render, timingFunctions, uid };
|
|
3272
|
-
export type { AnimationEffectMode, AnimationProperties, AssetHandler, AudioWaveformProperties, BaseElement2DEventMap, BaseElement2DProperties, BaseElement2DStyleProperties, Batchable2D, CSSFilterKey, CSSFilters, Camera2DEventMap, Camera2DProperties, CanvasBatchable, CanvasItemEventMap, CanvasItemProperties, ColorAdjustEffectProperties, ColorFilterEffectProperties, ColorOverlayEffectProperties, ColorRemoveEffectProperties, ColorReplaceEffectProperties, ComputedLayout, ControlEventMap, ControlProperties, CoreObjectEventMap, CssFunction, CssFunctionArg, Cursor, CustomPropertyAccessor, DropShadowEffectProperties, Easing, EffectContext, EffectMode, EffectProperties, Element2DEventMap, Element2DProperties, Element2DStyleProperties, EmbossEffectProperties, EngineOptions, FillDraw, FlexBaseElement2DEventMap, FlexElement2DProperties, FlexElement2DStyleProperties, GaussianBlurEffectProperties, GeometryOptions, GlitchEffectProperties, GodrayEffectProperties, IAudioContext, IAudioNode, IPlayOptions, Image2DProperties, ImageFrame, ImageTextureOptions, IndexBufferOptions, InputEventKey, InputEventMap, InternalMode, KawaseBlurEffectProperties, Keyframe, Lottie2DProperties, MainLoopEventMap, MaskColor, MaskData, MaskEffectProperties, MaskObject, MaskRect, Maskable, MaterialOptions, MatrixLike, MatrixOperateOutput, Node2DEventMap, Node2DProperties, NodeEventMap, NodeProperties, NormalizedKeyframe, OutlineEffectProperties, PixelateEffectProperties, PlatformAudio, PlatformSound, ProcessMode, ProcessSortMode, RangeProperties, Rectangulable, RectangulableEventMap, RefCountedEventMap, RenderMode, RenderOptions, Renderable, ResourceEventMap, RulerProperties, ScalerEventMap, ScalerProperties, SceneTreeEventMap, ScrollBarProperties, StrokeDraw, Texture2DFilterMode, Texture2DPixelsSource, Texture2DSource, Texture2DWrapMode, TextureRect2DProperties, TimelineEventMap, TimelineNodeEventMap, TimelineNodeProperties, TimelineProperties, TimingFunctions,
|
|
3309
|
+
export type { AnimationEffectMode, AnimationProperties, AssetHandler, AudioWaveformProperties, BaseElement2DEventMap, BaseElement2DProperties, BaseElement2DStyleProperties, Batchable2D, CSSFilterKey, CSSFilters, Camera2DEventMap, Camera2DProperties, CanvasBatchable, CanvasItemEventMap, CanvasItemProperties, ColorAdjustEffectProperties, ColorFilterEffectProperties, ColorOverlayEffectProperties, ColorRemoveEffectProperties, ColorReplaceEffectProperties, ComputedLayout, ControlEventMap, ControlProperties, CoreObjectEventMap, CssFunction, CssFunctionArg, Cursor, CustomPropertyAccessor, DropShadowEffectProperties, Easing, EffectContext, EffectMode, EffectProperties, Element2DEventMap, Element2DProperties, Element2DStyleProperties, EmbossEffectProperties, EngineOptions, FillDraw, FlexBaseElement2DEventMap, FlexElement2DProperties, FlexElement2DStyleProperties, GaussianBlurEffectProperties, GeometryOptions, GlitchEffectProperties, GodrayEffectProperties, IAudioContext, IAudioNode, IPlayOptions, Image2DProperties, ImageFrame, ImageTextureOptions, IndexBufferOptions, InputEventKey, InputEventMap, InternalMode, KawaseBlurEffectProperties, Keyframe, Lottie2DProperties, MainLoopEventMap, MaskColor, MaskData, MaskEffectProperties, MaskObject, MaskRect, Maskable, MaterialOptions, MatrixLike, MatrixOperateOutput, Node2DEventMap, Node2DProperties, NodeEventMap, NodeProperties, NormalizedKeyframe, OutlineEffectProperties, PixelateEffectProperties, PlatformAudio, PlatformSound, ProcessMode, ProcessSortMode, RangeProperties, Rectangulable, RectangulableEventMap, RefCountedEventMap, RenderMode, RenderOptions, Renderable, ResourceEventMap, RulerProperties, ScalerEventMap, ScalerProperties, SceneTreeEventMap, ScrollBarProperties, StrokeDraw, Texture2DFilterMode, Texture2DPixelsSource, Texture2DSource, Texture2DWrapMode, TextureRect2DProperties, TimelineEventMap, TimelineNodeEventMap, TimelineNodeProperties, TimelineProperties, TimingFunctions, TransformObject, TransformRect2DProperties, TransformableObject, TransitionProperties, UVTransform, VectorLike, VectorOperateOutput, VertTransform, VertexAttributeOptions, VertexBufferOptions, Video2DProperties, VideoTextureOptions, VideoTextureSource, ViewportEventMap, ViewportFramebuffer, WebGLBufferMeta, WebGLBufferOptions, WebGLBufferTarget, WebGLBufferUsage, WebGLDrawMode, WebGLDrawOptions, WebGLExtensions, WebGLFramebufferMeta, WebGLFramebufferOptions, WebGLProgramMeta, WebGLProgramOptions, WebGLTarget, WebGLTextureFilterMode, WebGLTextureLocation, WebGLTextureMeta, WebGLTextureOptions, WebGLTextureSource, WebGLTextureTarget, WebGLTextureWrapMode, WebGLVertexArrayObjectMeta, WebGLVertexArrayObjectOptions, WebGLVertexAttrib, WebGLVertexAttribType, WebGLViewport, XScrollBarProperties, YScrollBarProperties, ZoomBlurEffectProperties };
|