modern-canvas 0.8.3 → 0.8.4

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
@@ -9733,7 +9733,7 @@ class BaseElement2DShape extends CoreObject {
9733
9733
  }
9734
9734
  if (!viewBox) {
9735
9735
  const bbox = this._path2DSet.getBoundingBox();
9736
- viewBox = bbox ? [bbox.x, bbox.y, bbox.width, bbox.height] : [0, 0, 1, 1];
9736
+ viewBox = bbox ? [bbox.x, bbox.y, bbox.width || 1, bbox.height || 1] : [0, 0, 1, 1];
9737
9737
  }
9738
9738
  const [x, y, w, h] = viewBox;
9739
9739
  this._path2DSet.paths.forEach((path) => {
@@ -9883,6 +9883,15 @@ class BaseElement2DText extends CoreObject {
9883
9883
  this.enabled && !/^\s*$/.test(this.base.toString())
9884
9884
  );
9885
9885
  }
9886
+ _getVertTransform() {
9887
+ const parent = this.parent;
9888
+ if (parent.style.scaleX > 0 && parent.style.scaleY > 0) {
9889
+ return void 0;
9890
+ }
9891
+ const scale = parent.style.scaleX * parent.style.scaleY;
9892
+ const origin = parent.getTransformOrigin();
9893
+ return new Transform2D().translate(-origin.x, -origin.y).scale(scale > 0 ? 1 : -1, 1).translate(origin.x, origin.y);
9894
+ }
9886
9895
  draw() {
9887
9896
  const ctx = this.parent.context;
9888
9897
  this.base.update();
@@ -9900,11 +9909,13 @@ class BaseElement2DText extends CoreObject {
9900
9909
  ctx.strokeStyle = this._textures[0] ?? outline.color;
9901
9910
  ctx.lineCap = outline.lineCap;
9902
9911
  ctx.lineJoin = outline.lineJoin;
9912
+ ctx.vertTransform = this._getVertTransform();
9903
9913
  ctx.stroke({ disableWrapMode });
9904
9914
  }
9905
9915
  } else {
9906
9916
  ctx.addPath(path);
9907
9917
  ctx.style = { ...path.style };
9918
+ ctx.vertTransform = this._getVertTransform();
9908
9919
  ctx.stroke();
9909
9920
  }
9910
9921
  }
@@ -9917,13 +9928,13 @@ class BaseElement2DText extends CoreObject {
9917
9928
  ctx.style = { ...path.style };
9918
9929
  ctx.uvTransform = uvTransform;
9919
9930
  ctx.fillStyle = this._textures[1] ?? fill.color;
9920
- ctx.fill({
9921
- disableWrapMode
9922
- });
9931
+ ctx.vertTransform = this._getVertTransform();
9932
+ ctx.fill({ disableWrapMode });
9923
9933
  }
9924
9934
  } else {
9925
9935
  ctx.addPath(path);
9926
9936
  ctx.style = { ...path.style };
9937
+ ctx.vertTransform = this._getVertTransform();
9927
9938
  ctx.fill();
9928
9939
  }
9929
9940
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.8.3",
4
+ "version": "0.8.4",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",