modern-canvas 0.4.0 → 0.4.2

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
@@ -8766,7 +8766,7 @@ let BaseElement2D = class extends Node2D {
8766
8766
  if (this.style.boxShadow !== "none") {
8767
8767
  const node = this.getNode(nodePath);
8768
8768
  if (node) ; else {
8769
- this.appendChild(new ShadowEffect(), "back");
8769
+ this.appendChild(new ShadowEffect({ name: nodePath }), "back");
8770
8770
  }
8771
8771
  } else {
8772
8772
  const node = this.getNode(nodePath);
@@ -8783,7 +8783,7 @@ let BaseElement2D = class extends Node2D {
8783
8783
  if (node) {
8784
8784
  node.src = maskImage;
8785
8785
  } else {
8786
- this.appendChild(new MaskEffect({ src: maskImage }), "back");
8786
+ this.appendChild(new MaskEffect({ name: nodePath, src: maskImage }), "back");
8787
8787
  }
8788
8788
  } else {
8789
8789
  const node = this.getNode(nodePath);
@@ -8822,13 +8822,34 @@ let BaseElement2D = class extends Node2D {
8822
8822
  this._updateOverflow();
8823
8823
  }
8824
8824
  getRect() {
8825
- const [a, c, tx, b, d, ty] = this.transform.toArray();
8826
- const { width, height } = this.size;
8825
+ const { width: w, height: h } = this.size;
8826
+ const x1 = 0;
8827
+ const y1 = 0;
8828
+ const x2 = x1 + w;
8829
+ const y2 = y1 + h;
8830
+ const [a, c, tx, b, d, ty] = this.globalTransform.toArray();
8831
+ const points = [
8832
+ [x1, y1],
8833
+ [x1, y2],
8834
+ [x2, y1],
8835
+ [x2, y2]
8836
+ ].map((p) => {
8837
+ return [
8838
+ a * p[0] + c * p[1] + tx,
8839
+ b * p[0] + d * p[1] + ty
8840
+ ];
8841
+ });
8842
+ const xx = points.map((p) => p[0]);
8843
+ const yy = points.map((p) => p[1]);
8844
+ const minX = Math.min(...xx);
8845
+ const maxX = Math.max(...xx);
8846
+ const minY = Math.min(...yy);
8847
+ const maxY = Math.max(...yy);
8827
8848
  return new Rect2(
8828
- tx,
8829
- ty,
8830
- a * width + c * height,
8831
- b * width + d * height
8849
+ minX,
8850
+ minY,
8851
+ maxX - minX,
8852
+ maxY - minY
8832
8853
  );
8833
8854
  }
8834
8855
  _updateOverflow() {
@@ -9634,7 +9655,7 @@ let Image2D = class extends Element2D {
9634
9655
  }
9635
9656
  }
9636
9657
  _repaint(batchables) {
9637
- return batchables.map((batchable) => {
9658
+ return super._repaint(batchables).map((batchable) => {
9638
9659
  return {
9639
9660
  ...batchable,
9640
9661
  disableWrapMode: true
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.4.2",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",