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.cjs CHANGED
@@ -9739,7 +9739,7 @@ class BaseElement2DShape extends CoreObject {
9739
9739
  }
9740
9740
  if (!viewBox) {
9741
9741
  const bbox = this._path2DSet.getBoundingBox();
9742
- viewBox = bbox ? [bbox.x, bbox.y, bbox.width, bbox.height] : [0, 0, 1, 1];
9742
+ viewBox = bbox ? [bbox.x, bbox.y, bbox.width || 1, bbox.height || 1] : [0, 0, 1, 1];
9743
9743
  }
9744
9744
  const [x, y, w, h] = viewBox;
9745
9745
  this._path2DSet.paths.forEach((path) => {
@@ -9889,6 +9889,15 @@ class BaseElement2DText extends CoreObject {
9889
9889
  this.enabled && !/^\s*$/.test(this.base.toString())
9890
9890
  );
9891
9891
  }
9892
+ _getVertTransform() {
9893
+ const parent = this.parent;
9894
+ if (parent.style.scaleX > 0 && parent.style.scaleY > 0) {
9895
+ return void 0;
9896
+ }
9897
+ const scale = parent.style.scaleX * parent.style.scaleY;
9898
+ const origin = parent.getTransformOrigin();
9899
+ return new Transform2D().translate(-origin.x, -origin.y).scale(scale > 0 ? 1 : -1, 1).translate(origin.x, origin.y);
9900
+ }
9892
9901
  draw() {
9893
9902
  const ctx = this.parent.context;
9894
9903
  this.base.update();
@@ -9906,11 +9915,13 @@ class BaseElement2DText extends CoreObject {
9906
9915
  ctx.strokeStyle = this._textures[0] ?? outline.color;
9907
9916
  ctx.lineCap = outline.lineCap;
9908
9917
  ctx.lineJoin = outline.lineJoin;
9918
+ ctx.vertTransform = this._getVertTransform();
9909
9919
  ctx.stroke({ disableWrapMode });
9910
9920
  }
9911
9921
  } else {
9912
9922
  ctx.addPath(path);
9913
9923
  ctx.style = { ...path.style };
9924
+ ctx.vertTransform = this._getVertTransform();
9914
9925
  ctx.stroke();
9915
9926
  }
9916
9927
  }
@@ -9923,13 +9934,13 @@ class BaseElement2DText extends CoreObject {
9923
9934
  ctx.style = { ...path.style };
9924
9935
  ctx.uvTransform = uvTransform;
9925
9936
  ctx.fillStyle = this._textures[1] ?? fill.color;
9926
- ctx.fill({
9927
- disableWrapMode
9928
- });
9937
+ ctx.vertTransform = this._getVertTransform();
9938
+ ctx.fill({ disableWrapMode });
9929
9939
  }
9930
9940
  } else {
9931
9941
  ctx.addPath(path);
9932
9942
  ctx.style = { ...path.style };
9943
+ ctx.vertTransform = this._getVertTransform();
9933
9944
  ctx.fill();
9934
9945
  }
9935
9946
  }
package/dist/index.d.cts CHANGED
@@ -2104,6 +2104,7 @@ declare class BaseElement2DText extends CoreObject {
2104
2104
  measure(): MeasureResult;
2105
2105
  updateMeasure(): this;
2106
2106
  canDraw(): boolean;
2107
+ protected _getVertTransform(): Transform2D | undefined;
2107
2108
  draw(): void;
2108
2109
  }
2109
2110
 
package/dist/index.d.mts CHANGED
@@ -2104,6 +2104,7 @@ declare class BaseElement2DText extends CoreObject {
2104
2104
  measure(): MeasureResult;
2105
2105
  updateMeasure(): this;
2106
2106
  canDraw(): boolean;
2107
+ protected _getVertTransform(): Transform2D | undefined;
2107
2108
  draw(): void;
2108
2109
  }
2109
2110
 
package/dist/index.d.ts CHANGED
@@ -2104,6 +2104,7 @@ declare class BaseElement2DText extends CoreObject {
2104
2104
  measure(): MeasureResult;
2105
2105
  updateMeasure(): this;
2106
2106
  canDraw(): boolean;
2107
+ protected _getVertTransform(): Transform2D | undefined;
2107
2108
  draw(): void;
2108
2109
  }
2109
2110