modern-canvas 0.4.38 → 0.4.40

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.mjs CHANGED
@@ -2490,25 +2490,23 @@ class Transform2D extends Matrix3 {
2490
2490
  return t2d.multiply(this, this);
2491
2491
  }
2492
2492
  skewX(x) {
2493
- return this.skew(x, 1);
2493
+ return this.skew(x, 0);
2494
2494
  }
2495
2495
  skewY(y) {
2496
- return this.skew(1, y);
2496
+ return this.skew(0, y);
2497
2497
  }
2498
2498
  skew(x, y) {
2499
2499
  return this.premultiply(Transform2D._t2d.makeSkew(x, y));
2500
2500
  }
2501
2501
  makeSkew(x, y) {
2502
- const cx = Math.cos(y);
2503
- const sx = Math.sin(y);
2504
- const cy = -Math.sin(-x);
2505
- const sy = Math.cos(-x);
2502
+ const tanX = Math.tan(x);
2503
+ const tanY = Math.tan(y);
2506
2504
  this.set([
2507
- cx,
2508
- cy,
2505
+ 1,
2506
+ tanY,
2509
2507
  0,
2510
- sx,
2511
- sy,
2508
+ tanX,
2509
+ 1,
2512
2510
  0,
2513
2511
  0,
2514
2512
  0,
@@ -6447,15 +6445,27 @@ let Node = class extends CoreObject {
6447
6445
  if (this.is(node) || node.hasParent()) {
6448
6446
  return node;
6449
6447
  }
6448
+ let index = -1;
6450
6449
  switch (internalMode) {
6451
6450
  case "default":
6451
+ index = this._children.findLastIndex((node2) => node2.internalMode === "default");
6452
+ if (index > -1) {
6453
+ index += 1;
6454
+ } else {
6455
+ index = this._children.findIndex((node2) => node2.internalMode === "back");
6456
+ }
6457
+ break;
6452
6458
  case "front": {
6453
- const targetMode = internalMode === "default" ? "back" : "front";
6454
- const index = this._children.findIndex((node2) => node2.internalMode === targetMode);
6459
+ index = this._children.findLastIndex((node2) => node2.internalMode === "front");
6460
+ if (index > -1) {
6461
+ index += 1;
6462
+ } else {
6463
+ index = this._children.findIndex((node2) => node2.internalMode === "default");
6464
+ }
6455
6465
  if (index > -1) {
6456
- this._children.splice(index, 0, node);
6466
+ index += 1;
6457
6467
  } else {
6458
- this._children.push(node);
6468
+ index = this._children.findIndex((node2) => node2.internalMode === "back");
6459
6469
  }
6460
6470
  break;
6461
6471
  }
@@ -6463,6 +6473,11 @@ let Node = class extends CoreObject {
6463
6473
  this._children.push(node);
6464
6474
  break;
6465
6475
  }
6476
+ if (index > -1) {
6477
+ this._children.splice(index, 0, node);
6478
+ } else {
6479
+ this._children.push(node);
6480
+ }
6466
6481
  node.internalMode = internalMode;
6467
6482
  node.setParent(this);
6468
6483
  this.emit("appendChild", node);
@@ -11112,9 +11127,6 @@ var __decorateClass$g = (decorators, target, key, kind) => {
11112
11127
  };
11113
11128
  const textStyles = new Set(Object.keys(textDefaultStyle));
11114
11129
  let Text2D = class extends TextureRect2D {
11115
- effects;
11116
- measureDom;
11117
- fonts;
11118
11130
  texture = new CanvasTexture();
11119
11131
  base = new Text();
11120
11132
  measureResult;
@@ -11225,22 +11237,23 @@ let Text2D = class extends TextureRect2D {
11225
11237
  this._subTextsCount = 0;
11226
11238
  }
11227
11239
  if (this.split) {
11228
- this.measureResult?.paragraphs.forEach((p) => {
11240
+ this.measure().paragraphs.forEach((p) => {
11229
11241
  p.fragments.forEach((f) => {
11230
11242
  f.characters.forEach((c) => {
11231
- this.appendChild(
11243
+ this.append(
11232
11244
  new Text2D({
11233
- content: c.content,
11245
+ internalMode: "front",
11234
11246
  style: {
11235
11247
  ...c.computedStyle,
11236
11248
  left: c.inlineBox.x,
11237
11249
  top: c.inlineBox.y,
11238
11250
  width: 0,
11239
- height: 0,
11240
- effects: this.effects
11241
- }
11242
- }),
11243
- "front"
11251
+ height: 0
11252
+ },
11253
+ content: c.content,
11254
+ effects: this.effects,
11255
+ fonts: this.fonts
11256
+ })
11244
11257
  );
11245
11258
  this._subTextsCount++;
11246
11259
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.4.38",
4
+ "version": "0.4.40",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",