modern-canvas 0.4.37 → 0.4.39
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 +41 -25
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +41 -25
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2496,25 +2496,23 @@ class Transform2D extends Matrix3 {
|
|
|
2496
2496
|
return t2d.multiply(this, this);
|
|
2497
2497
|
}
|
|
2498
2498
|
skewX(x) {
|
|
2499
|
-
return this.skew(x,
|
|
2499
|
+
return this.skew(x, 0);
|
|
2500
2500
|
}
|
|
2501
2501
|
skewY(y) {
|
|
2502
|
-
return this.skew(
|
|
2502
|
+
return this.skew(0, y);
|
|
2503
2503
|
}
|
|
2504
2504
|
skew(x, y) {
|
|
2505
2505
|
return this.premultiply(Transform2D._t2d.makeSkew(x, y));
|
|
2506
2506
|
}
|
|
2507
2507
|
makeSkew(x, y) {
|
|
2508
|
-
const
|
|
2509
|
-
const
|
|
2510
|
-
const cy = -Math.sin(-x);
|
|
2511
|
-
const sy = Math.cos(-x);
|
|
2508
|
+
const tanX = Math.tan(x);
|
|
2509
|
+
const tanY = Math.tan(y);
|
|
2512
2510
|
this.set([
|
|
2513
|
-
|
|
2514
|
-
|
|
2511
|
+
1,
|
|
2512
|
+
tanY,
|
|
2515
2513
|
0,
|
|
2516
|
-
|
|
2517
|
-
|
|
2514
|
+
tanX,
|
|
2515
|
+
1,
|
|
2518
2516
|
0,
|
|
2519
2517
|
0,
|
|
2520
2518
|
0,
|
|
@@ -2563,7 +2561,7 @@ class Transform2D extends Matrix3 {
|
|
|
2563
2561
|
scale(x, y, z = 1) {
|
|
2564
2562
|
return this.premultiply(Transform2D._t2d.makeScale(x, y, z));
|
|
2565
2563
|
}
|
|
2566
|
-
makeScale(x, y,
|
|
2564
|
+
makeScale(x, y, _z = 1) {
|
|
2567
2565
|
this.set([
|
|
2568
2566
|
x,
|
|
2569
2567
|
0,
|
|
@@ -2573,7 +2571,7 @@ class Transform2D extends Matrix3 {
|
|
|
2573
2571
|
0,
|
|
2574
2572
|
0,
|
|
2575
2573
|
0,
|
|
2576
|
-
|
|
2574
|
+
1
|
|
2577
2575
|
]);
|
|
2578
2576
|
return this;
|
|
2579
2577
|
}
|
|
@@ -6453,15 +6451,27 @@ exports.Node = class Node extends CoreObject {
|
|
|
6453
6451
|
if (this.is(node) || node.hasParent()) {
|
|
6454
6452
|
return node;
|
|
6455
6453
|
}
|
|
6454
|
+
let index = -1;
|
|
6456
6455
|
switch (internalMode) {
|
|
6457
6456
|
case "default":
|
|
6457
|
+
index = this._children.findLastIndex((node2) => node2.internalMode === "default");
|
|
6458
|
+
if (index > -1) {
|
|
6459
|
+
index += 1;
|
|
6460
|
+
} else {
|
|
6461
|
+
index = this._children.findIndex((node2) => node2.internalMode === "back");
|
|
6462
|
+
}
|
|
6463
|
+
break;
|
|
6458
6464
|
case "front": {
|
|
6459
|
-
|
|
6460
|
-
const index = this._children.findIndex((node2) => node2.internalMode === targetMode);
|
|
6465
|
+
index = this._children.findLastIndex((node2) => node2.internalMode === "front");
|
|
6461
6466
|
if (index > -1) {
|
|
6462
|
-
|
|
6467
|
+
index += 1;
|
|
6463
6468
|
} else {
|
|
6464
|
-
this._children.
|
|
6469
|
+
index = this._children.findIndex((node2) => node2.internalMode === "default");
|
|
6470
|
+
}
|
|
6471
|
+
if (index > -1) {
|
|
6472
|
+
index += 1;
|
|
6473
|
+
} else {
|
|
6474
|
+
index = this._children.findIndex((node2) => node2.internalMode === "back");
|
|
6465
6475
|
}
|
|
6466
6476
|
break;
|
|
6467
6477
|
}
|
|
@@ -6469,6 +6479,11 @@ exports.Node = class Node extends CoreObject {
|
|
|
6469
6479
|
this._children.push(node);
|
|
6470
6480
|
break;
|
|
6471
6481
|
}
|
|
6482
|
+
if (index > -1) {
|
|
6483
|
+
this._children.splice(index, 0, node);
|
|
6484
|
+
} else {
|
|
6485
|
+
this._children.push(node);
|
|
6486
|
+
}
|
|
6472
6487
|
node.internalMode = internalMode;
|
|
6473
6488
|
node.setParent(this);
|
|
6474
6489
|
this.emit("appendChild", node);
|
|
@@ -10207,7 +10222,7 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
|
|
|
10207
10222
|
const offsetY = originY * height;
|
|
10208
10223
|
this.transform.identity().translate(-offsetX, -offsetY).scale(this.scale.x, this.scale.y).skew(this.skew.x, this.skew.y).rotate(this.rotation);
|
|
10209
10224
|
parseCSSTransform(this.style.transform, width, height, this.transform);
|
|
10210
|
-
this.transform.translate(
|
|
10225
|
+
this.transform.translate(this.position.x, this.position.y).translate(offsetX, offsetY);
|
|
10211
10226
|
}
|
|
10212
10227
|
_updateGlobalTransform() {
|
|
10213
10228
|
super._updateGlobalTransform();
|
|
@@ -11231,22 +11246,23 @@ exports.Text2D = class Text2D extends TextureRect2D {
|
|
|
11231
11246
|
this._subTextsCount = 0;
|
|
11232
11247
|
}
|
|
11233
11248
|
if (this.split) {
|
|
11234
|
-
this.
|
|
11249
|
+
this.measure().paragraphs.forEach((p) => {
|
|
11235
11250
|
p.fragments.forEach((f) => {
|
|
11236
11251
|
f.characters.forEach((c) => {
|
|
11237
|
-
this.
|
|
11252
|
+
this.append(
|
|
11238
11253
|
new exports.Text2D({
|
|
11239
|
-
|
|
11254
|
+
internalMode: "front",
|
|
11240
11255
|
style: {
|
|
11241
11256
|
...c.computedStyle,
|
|
11242
11257
|
left: c.inlineBox.x,
|
|
11243
11258
|
top: c.inlineBox.y,
|
|
11244
11259
|
width: 0,
|
|
11245
|
-
height: 0
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11260
|
+
height: 0
|
|
11261
|
+
},
|
|
11262
|
+
content: c.content,
|
|
11263
|
+
effects: this.effects,
|
|
11264
|
+
fonts: this.fonts
|
|
11265
|
+
})
|
|
11250
11266
|
);
|
|
11251
11267
|
this._subTextsCount++;
|
|
11252
11268
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -565,7 +565,7 @@ declare class Transform2D extends Matrix3 {
|
|
|
565
565
|
scaleY(y: number): this;
|
|
566
566
|
scale3d(x: number, y: number, z?: number): this;
|
|
567
567
|
scale(x: number, y: number, z?: number): this;
|
|
568
|
-
makeScale(x: number, y: number,
|
|
568
|
+
makeScale(x: number, y: number, _z?: number): this;
|
|
569
569
|
rotateX(x: number): this;
|
|
570
570
|
rotateY(y: number): this;
|
|
571
571
|
rotateZ(z: number): this;
|
package/dist/index.d.mts
CHANGED
|
@@ -565,7 +565,7 @@ declare class Transform2D extends Matrix3 {
|
|
|
565
565
|
scaleY(y: number): this;
|
|
566
566
|
scale3d(x: number, y: number, z?: number): this;
|
|
567
567
|
scale(x: number, y: number, z?: number): this;
|
|
568
|
-
makeScale(x: number, y: number,
|
|
568
|
+
makeScale(x: number, y: number, _z?: number): this;
|
|
569
569
|
rotateX(x: number): this;
|
|
570
570
|
rotateY(y: number): this;
|
|
571
571
|
rotateZ(z: number): this;
|
package/dist/index.d.ts
CHANGED
|
@@ -565,7 +565,7 @@ declare class Transform2D extends Matrix3 {
|
|
|
565
565
|
scaleY(y: number): this;
|
|
566
566
|
scale3d(x: number, y: number, z?: number): this;
|
|
567
567
|
scale(x: number, y: number, z?: number): this;
|
|
568
|
-
makeScale(x: number, y: number,
|
|
568
|
+
makeScale(x: number, y: number, _z?: number): this;
|
|
569
569
|
rotateX(x: number): this;
|
|
570
570
|
rotateY(y: number): this;
|
|
571
571
|
rotateZ(z: number): this;
|