modern-canvas 0.8.3 → 0.8.5

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.scale.x > 0 && parent.scale.y > 0) {
9889
+ return void 0;
9890
+ }
9891
+ const scale = parent.scale.x * parent.scale.y;
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
  }
@@ -10058,16 +10069,22 @@ let BaseElement2D = class extends Node2D {
10058
10069
  }
10059
10070
  return this;
10060
10071
  }
10061
- _updateStyleProperty(key, value, _oldValue, _declaration) {
10072
+ _updateStyleProperty(key, value, oldValue, _declaration) {
10062
10073
  switch (key) {
10063
10074
  case "rotate":
10064
10075
  this.rotation = this.style.rotate * DEG_TO_RAD;
10065
10076
  break;
10066
10077
  case "scaleX":
10067
10078
  this.scale.x = this.style.scaleX;
10079
+ if (this.text.canDraw() && (value ^ oldValue) < 0) {
10080
+ this.requestRedraw();
10081
+ }
10068
10082
  break;
10069
10083
  case "scaleY":
10070
10084
  this.scale.y = this.style.scaleY;
10085
+ if (this.text.canDraw() && (value ^ oldValue) < 0) {
10086
+ this.requestRedraw();
10087
+ }
10071
10088
  break;
10072
10089
  case "skewX":
10073
10090
  this.skew.x = this.style.skewX;
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.5",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",