modern-canvas 0.7.12 → 0.7.14
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 +243 -127
- package/dist/index.d.cts +64 -22
- package/dist/index.d.mts +64 -22
- package/dist/index.d.ts +64 -22
- package/dist/index.js +32 -32
- package/dist/index.mjs +243 -127
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1757,7 +1757,17 @@ class Matrix3 extends Matrix {
|
|
|
1757
1757
|
const t13 = n23 * n12 - n22 * n13;
|
|
1758
1758
|
const det = n11 * t11 + n21 * t12 + n31 * t13;
|
|
1759
1759
|
if (det === 0) {
|
|
1760
|
-
return this.set([
|
|
1760
|
+
return this.set([
|
|
1761
|
+
0,
|
|
1762
|
+
0,
|
|
1763
|
+
0,
|
|
1764
|
+
0,
|
|
1765
|
+
0,
|
|
1766
|
+
0,
|
|
1767
|
+
0,
|
|
1768
|
+
0,
|
|
1769
|
+
0
|
|
1770
|
+
]);
|
|
1761
1771
|
}
|
|
1762
1772
|
const detInv = 1 / det;
|
|
1763
1773
|
return this.set([
|
|
@@ -1944,10 +1954,23 @@ class Rect2 {
|
|
|
1944
1954
|
switch (args.length) {
|
|
1945
1955
|
case 0:
|
|
1946
1956
|
break;
|
|
1947
|
-
case 1:
|
|
1948
|
-
|
|
1949
|
-
|
|
1957
|
+
case 1: {
|
|
1958
|
+
const arg = args[0];
|
|
1959
|
+
if (arg instanceof Rect2) {
|
|
1960
|
+
position.set(arg.position);
|
|
1961
|
+
size.set(arg.size);
|
|
1962
|
+
} else {
|
|
1963
|
+
const xx = arg.map((p) => p.x);
|
|
1964
|
+
const yy = arg.map((p) => p.y);
|
|
1965
|
+
const minX = Math.min(...xx);
|
|
1966
|
+
const maxX = Math.max(...xx);
|
|
1967
|
+
const minY = Math.min(...yy);
|
|
1968
|
+
const maxY = Math.max(...yy);
|
|
1969
|
+
position.set(minX, minY);
|
|
1970
|
+
size.set(maxX - minX, maxY - minY);
|
|
1971
|
+
}
|
|
1950
1972
|
break;
|
|
1973
|
+
}
|
|
1951
1974
|
case 2:
|
|
1952
1975
|
position.set(args[0]);
|
|
1953
1976
|
size.set(args[1]);
|
|
@@ -1969,6 +1992,14 @@ class Rect2 {
|
|
|
1969
1992
|
);
|
|
1970
1993
|
return this;
|
|
1971
1994
|
}
|
|
1995
|
+
toMinmax() {
|
|
1996
|
+
return {
|
|
1997
|
+
minX: this.position.x,
|
|
1998
|
+
minY: this.position.y,
|
|
1999
|
+
maxX: this.end.x,
|
|
2000
|
+
maxY: this.end.y
|
|
2001
|
+
};
|
|
2002
|
+
}
|
|
1972
2003
|
toArray() {
|
|
1973
2004
|
return [this.x, this.y, this.width, this.height];
|
|
1974
2005
|
}
|
|
@@ -2128,22 +2159,68 @@ class Transform2D extends Matrix3 {
|
|
|
2128
2159
|
]);
|
|
2129
2160
|
return this;
|
|
2130
2161
|
}
|
|
2131
|
-
|
|
2162
|
+
decompose(pivot = { x: 0, y: 0 }, output = {
|
|
2163
|
+
position: { x: 0, y: 0 },
|
|
2164
|
+
scale: { x: 0, y: 0 },
|
|
2165
|
+
skew: { x: 0, y: 0 },
|
|
2166
|
+
rotation: 0
|
|
2167
|
+
}) {
|
|
2168
|
+
const { a, b, c, d, tx, ty } = this.toObject();
|
|
2169
|
+
const skewX = -Math.atan2(-c, d);
|
|
2170
|
+
const skewY = Math.atan2(b, a);
|
|
2171
|
+
const delta = Math.abs(skewX + skewY);
|
|
2172
|
+
if (delta < 1e-5 || Math.abs(PI_2 - delta) < 1e-5) {
|
|
2173
|
+
output.rotation = skewY;
|
|
2174
|
+
output.skew.x = output.skew.y = 0;
|
|
2175
|
+
} else {
|
|
2176
|
+
output.rotation = 0;
|
|
2177
|
+
output.skew.x = skewX;
|
|
2178
|
+
output.skew.y = skewY;
|
|
2179
|
+
}
|
|
2180
|
+
output.scale.x = Math.sqrt(a * a + b * b);
|
|
2181
|
+
output.scale.y = Math.sqrt(c * c + d * d);
|
|
2182
|
+
output.position.x = tx + (pivot.x * a + pivot.y * c);
|
|
2183
|
+
output.position.y = ty + (pivot.x * b + pivot.y * d);
|
|
2184
|
+
return output;
|
|
2185
|
+
}
|
|
2186
|
+
apply(pos, newPos) {
|
|
2187
|
+
newPos = newPos || new Vector2();
|
|
2132
2188
|
const { a, c, tx, b, d, ty } = this.toObject();
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2189
|
+
const x = pos.x;
|
|
2190
|
+
const y = pos.y;
|
|
2191
|
+
newPos.x = a * x + c * y + tx;
|
|
2192
|
+
newPos.y = b * x + d * y + ty;
|
|
2193
|
+
return newPos;
|
|
2137
2194
|
}
|
|
2138
2195
|
inverse() {
|
|
2139
2196
|
return this.clone().invert();
|
|
2140
2197
|
}
|
|
2198
|
+
applyInverse(pos, newPos) {
|
|
2199
|
+
newPos = newPos || new Vector2();
|
|
2200
|
+
const { a, b, c, d, tx, ty } = this.toObject();
|
|
2201
|
+
const id = 1 / (a * d + c * -b);
|
|
2202
|
+
const x = pos.x;
|
|
2203
|
+
const y = pos.y;
|
|
2204
|
+
newPos.x = d * id * x + -c * id * y + (ty * c - tx * d) * id;
|
|
2205
|
+
newPos.y = a * id * y + -b * id * x + (-ty * a + tx * b) * id;
|
|
2206
|
+
return newPos;
|
|
2207
|
+
}
|
|
2141
2208
|
isIdentity() {
|
|
2142
2209
|
const { a, b, c, d, tx, ty } = this.toObject();
|
|
2143
2210
|
return a === 1 && b === 0 && c === 0 && d === 1 && tx === 0 && ty === 0;
|
|
2144
2211
|
}
|
|
2145
2212
|
toObject() {
|
|
2146
|
-
const [
|
|
2213
|
+
const [
|
|
2214
|
+
a,
|
|
2215
|
+
c,
|
|
2216
|
+
tx,
|
|
2217
|
+
b,
|
|
2218
|
+
d,
|
|
2219
|
+
ty,
|
|
2220
|
+
,
|
|
2221
|
+
,
|
|
2222
|
+
tz
|
|
2223
|
+
] = this._array;
|
|
2147
2224
|
return { a, c, tx, b, d, ty, tz };
|
|
2148
2225
|
}
|
|
2149
2226
|
}
|
|
@@ -5575,7 +5652,7 @@ class CanvasContext extends Path2D {
|
|
|
5575
5652
|
}
|
|
5576
5653
|
buildUvs(start, vertices, uvs, texture, uvTransform) {
|
|
5577
5654
|
if (texture) {
|
|
5578
|
-
const _uvTransform = uvTransform ? typeof uvTransform === "function" ? uvTransform : (x, y) => uvTransform.
|
|
5655
|
+
const _uvTransform = uvTransform ? typeof uvTransform === "function" ? uvTransform : (x, y) => uvTransform.apply({ x, y }).toArray() : uvTransform;
|
|
5579
5656
|
const w = texture.width;
|
|
5580
5657
|
const h = texture.height;
|
|
5581
5658
|
for (let len = vertices.length, i = start; i < len; i += 2) {
|
|
@@ -6482,7 +6559,7 @@ let Viewport = class extends Node {
|
|
|
6482
6559
|
this.projection.flipY(flipY);
|
|
6483
6560
|
}
|
|
6484
6561
|
projection = new Projection2D();
|
|
6485
|
-
|
|
6562
|
+
worldTransform = new Transform2D();
|
|
6486
6563
|
_framebufferIndex = 0;
|
|
6487
6564
|
_framebuffers = [
|
|
6488
6565
|
{ texture: new ViewportTexture(), needsUpload: false },
|
|
@@ -6597,7 +6674,7 @@ let Viewport = class extends Node {
|
|
|
6597
6674
|
render(renderer, next) {
|
|
6598
6675
|
const oldViewport = this._tree?.getCurrentViewport();
|
|
6599
6676
|
renderer.program.uniforms.projectionMatrix = this.projection.toArray(true);
|
|
6600
|
-
renderer.program.uniforms.worldTransformMatrix = this.
|
|
6677
|
+
renderer.program.uniforms.worldTransformMatrix = this.worldTransform.toArray(true);
|
|
6601
6678
|
this.activate(renderer);
|
|
6602
6679
|
renderer.clear();
|
|
6603
6680
|
super.render(renderer, next);
|
|
@@ -6612,6 +6689,12 @@ let Viewport = class extends Node {
|
|
|
6612
6689
|
getRect() {
|
|
6613
6690
|
return new Rect2(this.x, this.y, this.width, this.height);
|
|
6614
6691
|
}
|
|
6692
|
+
toGlobal(worldPos, newPos) {
|
|
6693
|
+
return this.worldTransform.applyInverse(worldPos, newPos);
|
|
6694
|
+
}
|
|
6695
|
+
toWorld(globalPos, newPos) {
|
|
6696
|
+
return this.worldTransform.apply(globalPos, newPos);
|
|
6697
|
+
}
|
|
6615
6698
|
};
|
|
6616
6699
|
__decorateClass$P([
|
|
6617
6700
|
property({ fallback: 0 })
|
|
@@ -6885,10 +6968,10 @@ __decorateClass$O([
|
|
|
6885
6968
|
property()
|
|
6886
6969
|
], Effect.prototype, "effectMode", 2);
|
|
6887
6970
|
__decorateClass$O([
|
|
6888
|
-
property()
|
|
6971
|
+
property({ fallback: "" })
|
|
6889
6972
|
], Effect.prototype, "glsl", 2);
|
|
6890
6973
|
__decorateClass$O([
|
|
6891
|
-
property()
|
|
6974
|
+
property({ fallback: "" })
|
|
6892
6975
|
], Effect.prototype, "glslSrc", 2);
|
|
6893
6976
|
Effect = __decorateClass$O([
|
|
6894
6977
|
customNode("Effect")
|
|
@@ -7164,25 +7247,27 @@ let Node2D = class extends CanvasItem {
|
|
|
7164
7247
|
const parent = this.getParent();
|
|
7165
7248
|
if (parent?.globalTransform) {
|
|
7166
7249
|
this._parentTransformDirtyId = parent.globalTransform.dirtyId;
|
|
7167
|
-
this.
|
|
7250
|
+
this.globalPosition.set(
|
|
7251
|
+
parent.globalPosition.x + this.position.x,
|
|
7252
|
+
parent.globalPosition.y + this.position.y
|
|
7253
|
+
);
|
|
7254
|
+
this.globalScale.set(
|
|
7255
|
+
parent.globalScale.x * this.scale.x,
|
|
7256
|
+
parent.globalScale.y * this.scale.y
|
|
7257
|
+
);
|
|
7258
|
+
this.globalSkew.set(
|
|
7259
|
+
parent.globalSkew.x * this.skew.x,
|
|
7260
|
+
parent.globalSkew.y * this.skew.y
|
|
7261
|
+
);
|
|
7168
7262
|
this.globalRotation = parent.globalRotation + this.rotation;
|
|
7169
7263
|
parent.globalTransform.multiply(this.transform, this.globalTransform);
|
|
7170
7264
|
} else {
|
|
7265
|
+
this.globalPosition.copy(this.position);
|
|
7171
7266
|
this.globalScale.copy(this.scale);
|
|
7267
|
+
this.globalSkew.copy(this.skew);
|
|
7172
7268
|
this.globalRotation = this.rotation;
|
|
7173
7269
|
this.globalTransform.copy(this.transform);
|
|
7174
7270
|
}
|
|
7175
|
-
const [
|
|
7176
|
-
a,
|
|
7177
|
-
c,
|
|
7178
|
-
tx,
|
|
7179
|
-
b,
|
|
7180
|
-
d,
|
|
7181
|
-
ty
|
|
7182
|
-
] = this.globalTransform.toArray();
|
|
7183
|
-
this.globalPosition.set(tx, ty);
|
|
7184
|
-
this.globalSkew.x = Math.atan2(c, a) - this.globalRotation;
|
|
7185
|
-
this.globalSkew.y = Math.atan2(b, d) - this.globalRotation;
|
|
7186
7271
|
this.requestRelayout();
|
|
7187
7272
|
}
|
|
7188
7273
|
_transformVertices(vertices, vertTransform) {
|
|
@@ -7222,6 +7307,12 @@ let Node2D = class extends CanvasItem {
|
|
|
7222
7307
|
this.requestRelayout();
|
|
7223
7308
|
}
|
|
7224
7309
|
}
|
|
7310
|
+
toLocal(globalPos, newPos) {
|
|
7311
|
+
return this.globalTransform.applyInverse(globalPos, newPos);
|
|
7312
|
+
}
|
|
7313
|
+
toGlobal(localPos, newPos) {
|
|
7314
|
+
return this.globalTransform.apply(localPos, newPos);
|
|
7315
|
+
}
|
|
7225
7316
|
};
|
|
7226
7317
|
__decorateClass$J([
|
|
7227
7318
|
property({ protected: true, fallback: 0 })
|
|
@@ -7244,7 +7335,7 @@ var __decorateClass$I = (decorators, target, key, kind) => {
|
|
|
7244
7335
|
return result;
|
|
7245
7336
|
};
|
|
7246
7337
|
let Camera2D = class extends Node2D {
|
|
7247
|
-
zoom = new Vector2(1, 1).on("update", () => this.
|
|
7338
|
+
zoom = new Vector2(1, 1).on("update", () => this.updateWorldTransform());
|
|
7248
7339
|
maxZoom = new Vector2(6, 6);
|
|
7249
7340
|
minZoom = new Vector2(0.1, 0.1);
|
|
7250
7341
|
_screenOffset = { x: 0, y: 0 };
|
|
@@ -7331,14 +7422,14 @@ let Camera2D = class extends Node2D {
|
|
|
7331
7422
|
}
|
|
7332
7423
|
updateTransform() {
|
|
7333
7424
|
super.updateTransform();
|
|
7334
|
-
this.
|
|
7425
|
+
this.updateWorldTransform();
|
|
7335
7426
|
}
|
|
7336
|
-
|
|
7427
|
+
updateWorldTransform() {
|
|
7337
7428
|
const viewport = this.getViewport();
|
|
7338
7429
|
if (!viewport)
|
|
7339
7430
|
return;
|
|
7340
|
-
viewport.
|
|
7341
|
-
this.emit("
|
|
7431
|
+
viewport.worldTransform.identity().scale(this.zoom.x, this.zoom.y).translate(this.position.x, this.position.y);
|
|
7432
|
+
this.emit("updateWorldTransform");
|
|
7342
7433
|
}
|
|
7343
7434
|
};
|
|
7344
7435
|
__decorateClass$I([
|
|
@@ -7569,28 +7660,28 @@ void main(void) {
|
|
|
7569
7660
|
}`
|
|
7570
7661
|
}));
|
|
7571
7662
|
__decorateClass$H([
|
|
7572
|
-
property()
|
|
7663
|
+
property({ fallback: 1 })
|
|
7573
7664
|
], ColorAdjustEffect.prototype, "saturation", 2);
|
|
7574
7665
|
__decorateClass$H([
|
|
7575
|
-
property()
|
|
7666
|
+
property({ fallback: 1 })
|
|
7576
7667
|
], ColorAdjustEffect.prototype, "contrast", 2);
|
|
7577
7668
|
__decorateClass$H([
|
|
7578
|
-
property()
|
|
7669
|
+
property({ fallback: 1 })
|
|
7579
7670
|
], ColorAdjustEffect.prototype, "brightness", 2);
|
|
7580
7671
|
__decorateClass$H([
|
|
7581
|
-
property()
|
|
7672
|
+
property({ fallback: 1 })
|
|
7582
7673
|
], ColorAdjustEffect.prototype, "red", 2);
|
|
7583
7674
|
__decorateClass$H([
|
|
7584
|
-
property()
|
|
7675
|
+
property({ fallback: 1 })
|
|
7585
7676
|
], ColorAdjustEffect.prototype, "green", 2);
|
|
7586
7677
|
__decorateClass$H([
|
|
7587
|
-
property()
|
|
7678
|
+
property({ fallback: 1 })
|
|
7588
7679
|
], ColorAdjustEffect.prototype, "blue", 2);
|
|
7589
7680
|
__decorateClass$H([
|
|
7590
|
-
property()
|
|
7681
|
+
property({ fallback: 1 })
|
|
7591
7682
|
], ColorAdjustEffect.prototype, "alpha", 2);
|
|
7592
7683
|
__decorateClass$H([
|
|
7593
|
-
property()
|
|
7684
|
+
property({ fallback: 1 })
|
|
7594
7685
|
], ColorAdjustEffect.prototype, "gamma", 2);
|
|
7595
7686
|
ColorAdjustEffect = __decorateClass$H([
|
|
7596
7687
|
customNode("ColorAdjustEffect")
|
|
@@ -7776,10 +7867,10 @@ void main(void) {
|
|
|
7776
7867
|
}`
|
|
7777
7868
|
}));
|
|
7778
7869
|
__decorateClass$F([
|
|
7779
|
-
property()
|
|
7870
|
+
property({ default: () => [] })
|
|
7780
7871
|
], ColorOverlayEffect.prototype, "colors", 2);
|
|
7781
7872
|
__decorateClass$F([
|
|
7782
|
-
property()
|
|
7873
|
+
property({ fallback: 0.5 })
|
|
7783
7874
|
], ColorOverlayEffect.prototype, "alpha", 2);
|
|
7784
7875
|
ColorOverlayEffect = __decorateClass$F([
|
|
7785
7876
|
customNode("ColorOverlayEffect")
|
|
@@ -7861,10 +7952,10 @@ void main(void) {
|
|
|
7861
7952
|
}`
|
|
7862
7953
|
}));
|
|
7863
7954
|
__decorateClass$E([
|
|
7864
|
-
property()
|
|
7955
|
+
property({ default: () => [] })
|
|
7865
7956
|
], ColorRemoveEffect.prototype, "colors", 2);
|
|
7866
7957
|
__decorateClass$E([
|
|
7867
|
-
property()
|
|
7958
|
+
property({ fallback: 0.5 })
|
|
7868
7959
|
], ColorRemoveEffect.prototype, "epsilon", 2);
|
|
7869
7960
|
ColorRemoveEffect = __decorateClass$E([
|
|
7870
7961
|
customNode("ColorRemoveEffect")
|
|
@@ -7968,10 +8059,10 @@ void main(void) {
|
|
|
7968
8059
|
}`
|
|
7969
8060
|
}));
|
|
7970
8061
|
__decorateClass$D([
|
|
7971
|
-
property()
|
|
8062
|
+
property({ default: () => [] })
|
|
7972
8063
|
], ColorReplaceEffect.prototype, "colors", 2);
|
|
7973
8064
|
__decorateClass$D([
|
|
7974
|
-
property()
|
|
8065
|
+
property({ fallback: 0.05 })
|
|
7975
8066
|
], ColorReplaceEffect.prototype, "epsilon", 2);
|
|
7976
8067
|
ColorReplaceEffect = __decorateClass$D([
|
|
7977
8068
|
customNode("ColorReplaceEffect")
|
|
@@ -8092,10 +8183,10 @@ void main(void) {
|
|
|
8092
8183
|
frag: frag$2
|
|
8093
8184
|
}));
|
|
8094
8185
|
__decorateClass$C([
|
|
8095
|
-
property({
|
|
8186
|
+
property({ fallback: 4 })
|
|
8096
8187
|
], GaussianBlurEffect.prototype, "strength", 2);
|
|
8097
8188
|
__decorateClass$C([
|
|
8098
|
-
property({
|
|
8189
|
+
property({ fallback: 3 })
|
|
8099
8190
|
], GaussianBlurEffect.prototype, "quality", 2);
|
|
8100
8191
|
GaussianBlurEffect = __decorateClass$C([
|
|
8101
8192
|
customNode("GaussianBlurEffect")
|
|
@@ -8174,19 +8265,19 @@ void main(void) {
|
|
|
8174
8265
|
}`
|
|
8175
8266
|
}));
|
|
8176
8267
|
__decorateClass$B([
|
|
8177
|
-
property()
|
|
8268
|
+
property({ fallback: "#000000FF" })
|
|
8178
8269
|
], DropShadowEffect.prototype, "color", 2);
|
|
8179
8270
|
__decorateClass$B([
|
|
8180
|
-
property()
|
|
8271
|
+
property({ fallback: 4 })
|
|
8181
8272
|
], DropShadowEffect.prototype, "blur", 2);
|
|
8182
8273
|
__decorateClass$B([
|
|
8183
|
-
property()
|
|
8274
|
+
property({ fallback: 4 })
|
|
8184
8275
|
], DropShadowEffect.prototype, "offsetX", 2);
|
|
8185
8276
|
__decorateClass$B([
|
|
8186
|
-
property()
|
|
8277
|
+
property({ fallback: 4 })
|
|
8187
8278
|
], DropShadowEffect.prototype, "offsetY", 2);
|
|
8188
8279
|
__decorateClass$B([
|
|
8189
|
-
property()
|
|
8280
|
+
property({ fallback: false })
|
|
8190
8281
|
], DropShadowEffect.prototype, "shadowOnly", 2);
|
|
8191
8282
|
DropShadowEffect = __decorateClass$B([
|
|
8192
8283
|
customNode("DropShadowEffect")
|
|
@@ -8246,7 +8337,7 @@ void main(void) {
|
|
|
8246
8337
|
}`
|
|
8247
8338
|
}));
|
|
8248
8339
|
__decorateClass$A([
|
|
8249
|
-
property()
|
|
8340
|
+
property({ fallback: 5 })
|
|
8250
8341
|
], EmbossEffect.prototype, "strength", 2);
|
|
8251
8342
|
EmbossEffect = __decorateClass$A([
|
|
8252
8343
|
customNode("EmbossEffect")
|
|
@@ -8435,31 +8526,31 @@ void main(void) {
|
|
|
8435
8526
|
}`
|
|
8436
8527
|
}));
|
|
8437
8528
|
__decorateClass$z([
|
|
8438
|
-
property()
|
|
8529
|
+
property({ fallback: 10 })
|
|
8439
8530
|
], GlitchEffect.prototype, "slices", 2);
|
|
8440
8531
|
__decorateClass$z([
|
|
8441
|
-
property()
|
|
8532
|
+
property({ fallback: 512 })
|
|
8442
8533
|
], GlitchEffect.prototype, "sampleSize", 2);
|
|
8443
8534
|
__decorateClass$z([
|
|
8444
|
-
property()
|
|
8535
|
+
property({ fallback: 100 })
|
|
8445
8536
|
], GlitchEffect.prototype, "offset", 2);
|
|
8446
8537
|
__decorateClass$z([
|
|
8447
|
-
property()
|
|
8538
|
+
property({ fallback: 0 })
|
|
8448
8539
|
], GlitchEffect.prototype, "direction", 2);
|
|
8449
8540
|
__decorateClass$z([
|
|
8450
|
-
property()
|
|
8541
|
+
property({ fallback: 2 })
|
|
8451
8542
|
], GlitchEffect.prototype, "fillMode", 2);
|
|
8452
8543
|
__decorateClass$z([
|
|
8453
|
-
property()
|
|
8544
|
+
property({ fallback: 0 })
|
|
8454
8545
|
], GlitchEffect.prototype, "seed", 2);
|
|
8455
8546
|
__decorateClass$z([
|
|
8456
|
-
property()
|
|
8547
|
+
property({ default: () => [2, 2] })
|
|
8457
8548
|
], GlitchEffect.prototype, "red", 2);
|
|
8458
8549
|
__decorateClass$z([
|
|
8459
|
-
property()
|
|
8550
|
+
property({ default: () => [-10, 4] })
|
|
8460
8551
|
], GlitchEffect.prototype, "green", 2);
|
|
8461
8552
|
__decorateClass$z([
|
|
8462
|
-
property()
|
|
8553
|
+
property({ default: () => [10, -4] })
|
|
8463
8554
|
], GlitchEffect.prototype, "blue", 2);
|
|
8464
8555
|
GlitchEffect = __decorateClass$z([
|
|
8465
8556
|
customNode("GlitchEffect")
|
|
@@ -8652,25 +8743,25 @@ void main(void) {
|
|
|
8652
8743
|
}`
|
|
8653
8744
|
}));
|
|
8654
8745
|
__decorateClass$y([
|
|
8655
|
-
property()
|
|
8746
|
+
property({ fallback: 0 })
|
|
8656
8747
|
], GodrayEffect.prototype, "time", 2);
|
|
8657
8748
|
__decorateClass$y([
|
|
8658
|
-
property()
|
|
8749
|
+
property({ fallback: 30 })
|
|
8659
8750
|
], GodrayEffect.prototype, "angle", 2);
|
|
8660
8751
|
__decorateClass$y([
|
|
8661
|
-
property()
|
|
8752
|
+
property({ fallback: 0.5 })
|
|
8662
8753
|
], GodrayEffect.prototype, "gain", 2);
|
|
8663
8754
|
__decorateClass$y([
|
|
8664
|
-
property()
|
|
8755
|
+
property({ fallback: 2.5 })
|
|
8665
8756
|
], GodrayEffect.prototype, "lacunarity", 2);
|
|
8666
8757
|
__decorateClass$y([
|
|
8667
|
-
property()
|
|
8758
|
+
property({ fallback: true })
|
|
8668
8759
|
], GodrayEffect.prototype, "parallel", 2);
|
|
8669
8760
|
__decorateClass$y([
|
|
8670
|
-
property()
|
|
8761
|
+
property({ default: () => [0, 0] })
|
|
8671
8762
|
], GodrayEffect.prototype, "center", 2);
|
|
8672
8763
|
__decorateClass$y([
|
|
8673
|
-
property()
|
|
8764
|
+
property({ fallback: 1 })
|
|
8674
8765
|
], GodrayEffect.prototype, "alpha", 2);
|
|
8675
8766
|
GodrayEffect = __decorateClass$y([
|
|
8676
8767
|
customNode("GodrayEffect")
|
|
@@ -8774,13 +8865,13 @@ void main() {
|
|
|
8774
8865
|
}
|
|
8775
8866
|
};
|
|
8776
8867
|
__decorateClass$x([
|
|
8777
|
-
property()
|
|
8868
|
+
property({ fallback: 4 })
|
|
8778
8869
|
], KawaseBlurEffect.prototype, "strength", 2);
|
|
8779
8870
|
__decorateClass$x([
|
|
8780
|
-
property()
|
|
8871
|
+
property({ fallback: 3 })
|
|
8781
8872
|
], KawaseBlurEffect.prototype, "quality", 2);
|
|
8782
8873
|
__decorateClass$x([
|
|
8783
|
-
property()
|
|
8874
|
+
property({ default: () => [1, 1] })
|
|
8784
8875
|
], KawaseBlurEffect.prototype, "pixelSize", 2);
|
|
8785
8876
|
KawaseBlurEffect = __decorateClass$x([
|
|
8786
8877
|
customNode("KawaseBlurEffect")
|
|
@@ -8886,7 +8977,7 @@ __decorateClass$w([
|
|
|
8886
8977
|
property({ protected: true })
|
|
8887
8978
|
], MaskEffect.prototype, "texture", 2);
|
|
8888
8979
|
__decorateClass$w([
|
|
8889
|
-
property({
|
|
8980
|
+
property({ fallback: "" })
|
|
8890
8981
|
], MaskEffect.prototype, "src", 2);
|
|
8891
8982
|
MaskEffect = __decorateClass$w([
|
|
8892
8983
|
customNode("MaskEffect")
|
|
@@ -8988,25 +9079,25 @@ void main() {
|
|
|
8988
9079
|
__publicField$7(OutlineEffect, "MIN_SAMPLES", 1);
|
|
8989
9080
|
__publicField$7(OutlineEffect, "MAX_SAMPLES", 100);
|
|
8990
9081
|
__decorateClass$v([
|
|
8991
|
-
property()
|
|
9082
|
+
property({ fallback: "#000000ff" })
|
|
8992
9083
|
], OutlineEffect.prototype, "color", 2);
|
|
8993
9084
|
__decorateClass$v([
|
|
8994
|
-
property()
|
|
9085
|
+
property({ fallback: 1 })
|
|
8995
9086
|
], OutlineEffect.prototype, "width", 2);
|
|
8996
9087
|
__decorateClass$v([
|
|
8997
|
-
property()
|
|
9088
|
+
property({ fallback: "solid" })
|
|
8998
9089
|
], OutlineEffect.prototype, "style", 2);
|
|
8999
9090
|
__decorateClass$v([
|
|
9000
9091
|
property()
|
|
9001
9092
|
], OutlineEffect.prototype, "image", 2);
|
|
9002
9093
|
__decorateClass$v([
|
|
9003
|
-
property()
|
|
9094
|
+
property({ fallback: 1 })
|
|
9004
9095
|
], OutlineEffect.prototype, "opacity", 2);
|
|
9005
9096
|
__decorateClass$v([
|
|
9006
|
-
property()
|
|
9097
|
+
property({ fallback: 0.1 })
|
|
9007
9098
|
], OutlineEffect.prototype, "quality", 2);
|
|
9008
9099
|
__decorateClass$v([
|
|
9009
|
-
property()
|
|
9100
|
+
property({ fallback: false })
|
|
9010
9101
|
], OutlineEffect.prototype, "knockout", 2);
|
|
9011
9102
|
OutlineEffect = __decorateClass$v([
|
|
9012
9103
|
customNode("OutlineEffect")
|
|
@@ -9077,7 +9168,7 @@ void main(void) {
|
|
|
9077
9168
|
}`
|
|
9078
9169
|
}));
|
|
9079
9170
|
__decorateClass$u([
|
|
9080
|
-
property()
|
|
9171
|
+
property({ fallback: 10 })
|
|
9081
9172
|
], PixelateEffect.prototype, "strength", 2);
|
|
9082
9173
|
PixelateEffect = __decorateClass$u([
|
|
9083
9174
|
customNode("PixelateEffect")
|
|
@@ -9208,13 +9299,13 @@ __decorateClass$t([
|
|
|
9208
9299
|
property()
|
|
9209
9300
|
], ZoomBlurEffect.prototype, "center", 2);
|
|
9210
9301
|
__decorateClass$t([
|
|
9211
|
-
property()
|
|
9302
|
+
property({ fallback: 20 })
|
|
9212
9303
|
], ZoomBlurEffect.prototype, "innerRadius", 2);
|
|
9213
9304
|
__decorateClass$t([
|
|
9214
|
-
property()
|
|
9305
|
+
property({ fallback: -1 })
|
|
9215
9306
|
], ZoomBlurEffect.prototype, "radius", 2);
|
|
9216
9307
|
__decorateClass$t([
|
|
9217
|
-
property()
|
|
9308
|
+
property({ fallback: 0.1 })
|
|
9218
9309
|
], ZoomBlurEffect.prototype, "strength", 2);
|
|
9219
9310
|
ZoomBlurEffect = __decorateClass$t([
|
|
9220
9311
|
customNode("ZoomBlurEffect")
|
|
@@ -9700,7 +9791,10 @@ class BaseElement2DText extends CoreObject {
|
|
|
9700
9791
|
break;
|
|
9701
9792
|
}
|
|
9702
9793
|
}
|
|
9703
|
-
|
|
9794
|
+
setContent(content) {
|
|
9795
|
+
this.content = normalizeTextContent(content);
|
|
9796
|
+
}
|
|
9797
|
+
measure() {
|
|
9704
9798
|
this.base.style = {
|
|
9705
9799
|
justifyContent: "center",
|
|
9706
9800
|
alignItems: "center",
|
|
@@ -9708,12 +9802,6 @@ class BaseElement2DText extends CoreObject {
|
|
|
9708
9802
|
...this.parent.style.toJSON()
|
|
9709
9803
|
};
|
|
9710
9804
|
this.base.requestUpdate();
|
|
9711
|
-
}
|
|
9712
|
-
setContent(content) {
|
|
9713
|
-
this.content = normalizeTextContent(content);
|
|
9714
|
-
}
|
|
9715
|
-
measure() {
|
|
9716
|
-
this._updateText();
|
|
9717
9805
|
return this.base.measure();
|
|
9718
9806
|
}
|
|
9719
9807
|
updateMeasure() {
|
|
@@ -9956,36 +10044,63 @@ let BaseElement2D = class extends Node2D {
|
|
|
9956
10044
|
this._updateOverflow();
|
|
9957
10045
|
}
|
|
9958
10046
|
getRect() {
|
|
9959
|
-
|
|
10047
|
+
return this.getGlobalAabb();
|
|
10048
|
+
}
|
|
10049
|
+
_getPointArray() {
|
|
10050
|
+
const { width, height } = this.size;
|
|
9960
10051
|
const x1 = 0;
|
|
9961
10052
|
const y1 = 0;
|
|
9962
|
-
const x2 = x1 +
|
|
9963
|
-
const y2 = y1 +
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
a * p[0] + c * p[1] + tx,
|
|
9973
|
-
b * p[0] + d * p[1] + ty
|
|
9974
|
-
];
|
|
9975
|
-
});
|
|
9976
|
-
const xx = points.map((p) => p[0]);
|
|
9977
|
-
const yy = points.map((p) => p[1]);
|
|
9978
|
-
const minX = Math.min(...xx);
|
|
9979
|
-
const maxX = Math.max(...xx);
|
|
9980
|
-
const minY = Math.min(...yy);
|
|
9981
|
-
const maxY = Math.max(...yy);
|
|
10053
|
+
const x2 = x1 + width;
|
|
10054
|
+
const y2 = y1 + height;
|
|
10055
|
+
return [
|
|
10056
|
+
{ x: x1, y: y1 },
|
|
10057
|
+
{ x: x1, y: y2 },
|
|
10058
|
+
{ x: x2, y: y1 },
|
|
10059
|
+
{ x: x2, y: y2 }
|
|
10060
|
+
];
|
|
10061
|
+
}
|
|
10062
|
+
getAabb() {
|
|
9982
10063
|
return new Rect2(
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
10064
|
+
this._getPointArray().map((p) => {
|
|
10065
|
+
return this.transform.apply(p);
|
|
10066
|
+
})
|
|
10067
|
+
);
|
|
10068
|
+
}
|
|
10069
|
+
getGlobalAabb() {
|
|
10070
|
+
return new Rect2(
|
|
10071
|
+
this._getPointArray().map((p) => {
|
|
10072
|
+
return this.globalTransform.apply(p);
|
|
10073
|
+
})
|
|
9987
10074
|
);
|
|
9988
10075
|
}
|
|
10076
|
+
getObb() {
|
|
10077
|
+
const origin = this.getTransformOrigin();
|
|
10078
|
+
const _origin = this.transform.apply(origin).sub(origin);
|
|
10079
|
+
return {
|
|
10080
|
+
rect: new Rect2(
|
|
10081
|
+
this._getPointArray().map((p) => {
|
|
10082
|
+
p.x += _origin.x;
|
|
10083
|
+
p.y += _origin.y;
|
|
10084
|
+
return p;
|
|
10085
|
+
})
|
|
10086
|
+
),
|
|
10087
|
+
rotation: this.rotation
|
|
10088
|
+
};
|
|
10089
|
+
}
|
|
10090
|
+
getGlobalObb() {
|
|
10091
|
+
const origin = this.getTransformOrigin();
|
|
10092
|
+
const _origin = this.globalTransform.apply(origin).sub(origin);
|
|
10093
|
+
return {
|
|
10094
|
+
rect: new Rect2(
|
|
10095
|
+
this._getPointArray().map((p) => {
|
|
10096
|
+
p.x += _origin.x;
|
|
10097
|
+
p.y += _origin.y;
|
|
10098
|
+
return p;
|
|
10099
|
+
})
|
|
10100
|
+
),
|
|
10101
|
+
rotation: this.globalRotation
|
|
10102
|
+
};
|
|
10103
|
+
}
|
|
9989
10104
|
// protected _rectsOverlap(r1: any, r2: any): boolean {
|
|
9990
10105
|
// return (
|
|
9991
10106
|
// r1.x < r2.x + r2.width
|
|
@@ -9998,12 +10113,12 @@ let BaseElement2D = class extends Node2D {
|
|
|
9998
10113
|
// override isVisibleInTree(): boolean {
|
|
9999
10114
|
// if (this._tree) {
|
|
10000
10115
|
// const root = this._tree.root
|
|
10001
|
-
// const camera = root.
|
|
10116
|
+
// const camera = root.worldTransform.inverse()
|
|
10002
10117
|
// const { x, y, width, height } = root
|
|
10003
|
-
// const p1 = camera.
|
|
10004
|
-
// const p2 = camera.
|
|
10005
|
-
// const p3 = camera.
|
|
10006
|
-
// const p4 = camera.
|
|
10118
|
+
// const p1 = camera.apply(x, y)
|
|
10119
|
+
// const p2 = camera.apply(x + width, y)
|
|
10120
|
+
// const p3 = camera.apply(x + width, y + height)
|
|
10121
|
+
// const p4 = camera.apply(x, y + height)
|
|
10007
10122
|
// const pts = [p1, p2, p3, p4]
|
|
10008
10123
|
// const xs = pts.map(p => p[0])
|
|
10009
10124
|
// const ys = pts.map(p => p[1])
|
|
@@ -10093,9 +10208,9 @@ let BaseElement2D = class extends Node2D {
|
|
|
10093
10208
|
}
|
|
10094
10209
|
}
|
|
10095
10210
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
10096
|
-
|
|
10211
|
+
_positionInput(localPos, key) {
|
|
10097
10212
|
const { width, height } = this.size;
|
|
10098
|
-
return
|
|
10213
|
+
return localPos.x >= 0 && localPos.x < width && localPos.y >= 0 && localPos.y < height;
|
|
10099
10214
|
}
|
|
10100
10215
|
_input(event, key) {
|
|
10101
10216
|
switch (key) {
|
|
@@ -10103,14 +10218,15 @@ let BaseElement2D = class extends Node2D {
|
|
|
10103
10218
|
case "pointermove":
|
|
10104
10219
|
case "pointerup": {
|
|
10105
10220
|
if (this.canPointerEvents()) {
|
|
10106
|
-
|
|
10221
|
+
const { screenX, screenY } = event;
|
|
10107
10222
|
if (screenX && screenY) {
|
|
10223
|
+
const pos = new Vector2(screenX, screenY);
|
|
10108
10224
|
const viewport = this.getViewport();
|
|
10109
10225
|
if (viewport) {
|
|
10110
|
-
|
|
10226
|
+
viewport.toGlobal(pos, pos);
|
|
10111
10227
|
}
|
|
10112
|
-
|
|
10113
|
-
if (this.
|
|
10228
|
+
this.toLocal(pos, pos);
|
|
10229
|
+
if (this._positionInput(pos, key)) {
|
|
10114
10230
|
if (!event.target) {
|
|
10115
10231
|
event.target = this;
|
|
10116
10232
|
}
|