modern-canvas 0.12.0 → 0.12.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.cjs CHANGED
@@ -10205,12 +10205,12 @@ class BaseElement2DText extends CoreObject {
10205
10205
  const origin = parent.getTransformOrigin();
10206
10206
  return new Transform2D().translate(-origin.x, -origin.y).scale(scale > 0 ? 1 : -1, 1).translate(origin.x, origin.y);
10207
10207
  }
10208
- _useDrawByTexture() {
10208
+ useTextureDraw() {
10209
10209
  return !!this.effects?.length || this.content.some((p) => {
10210
10210
  return p.fragments.some((f) => !!f.highlightImage);
10211
10211
  });
10212
10212
  }
10213
- _drawByVertices(ctx) {
10213
+ _pathDraw(ctx) {
10214
10214
  this.base.pathSets.forEach((pathSet) => {
10215
10215
  pathSet.paths.forEach((path) => {
10216
10216
  const meta = path.getMeta();
@@ -10281,7 +10281,7 @@ class BaseElement2DText extends CoreObject {
10281
10281
  });
10282
10282
  });
10283
10283
  }
10284
- _drawByTexture(ctx) {
10284
+ _textureDraw(ctx) {
10285
10285
  this._texture.width = Math.round(this.base.boundingBox.width);
10286
10286
  this._texture.height = Math.round(this.base.boundingBox.height);
10287
10287
  this.base.render({ view: this._texture.source });
@@ -10291,10 +10291,10 @@ class BaseElement2DText extends CoreObject {
10291
10291
  }
10292
10292
  draw() {
10293
10293
  const ctx = this.parent.context;
10294
- if (this._useDrawByTexture()) {
10295
- this._drawByTexture(ctx);
10294
+ if (this.useTextureDraw()) {
10295
+ this._textureDraw(ctx);
10296
10296
  } else {
10297
- this._drawByVertices(ctx);
10297
+ this._pathDraw(ctx);
10298
10298
  }
10299
10299
  }
10300
10300
  }
@@ -10331,6 +10331,8 @@ var __decorateClass$e = (decorators, target, key, kind) => {
10331
10331
  result = (decorator(result)) || result;
10332
10332
  return result;
10333
10333
  };
10334
+ const layoutStyle = new Set(Object.keys(modernIdoc.getDefaultLayoutStyle()));
10335
+ const textStyles = new Set(Object.keys(modernIdoc.getDefaultTextStyle()));
10334
10336
  exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
10335
10337
  size = new Vector2().on("update", () => {
10336
10338
  this.updateGlobalTransform();
@@ -10491,6 +10493,11 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
10491
10493
  this.requestRedraw();
10492
10494
  break;
10493
10495
  }
10496
+ if (textStyles.has(key) || layoutStyle.has(key)) {
10497
+ if (this.text.isValid()) {
10498
+ this.text.update();
10499
+ }
10500
+ }
10494
10501
  }
10495
10502
  _process(delta) {
10496
10503
  this.foreground.updateFrameIndex();
@@ -10666,7 +10673,9 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
10666
10673
  }
10667
10674
  if (this._text.isValid()) {
10668
10675
  this._tree?.log(this.name, "text drawing");
10669
- this._shape.draw(true);
10676
+ if (this._text.useTextureDraw()) {
10677
+ this._shape.draw(true);
10678
+ }
10670
10679
  this._text.draw();
10671
10680
  }
10672
10681
  this._drawContent();
package/dist/index.d.cts CHANGED
@@ -2122,9 +2122,9 @@ declare class BaseElement2DText extends CoreObject {
2122
2122
  updateMeasure(): this;
2123
2123
  isValid(): boolean;
2124
2124
  protected _createVertTransform(): Transform2D | undefined;
2125
- protected _useDrawByTexture(): boolean;
2126
- protected _drawByVertices(ctx: CanvasContext): void;
2127
- protected _drawByTexture(ctx: CanvasContext): void;
2125
+ useTextureDraw(): boolean;
2126
+ protected _pathDraw(ctx: CanvasContext): void;
2127
+ protected _textureDraw(ctx: CanvasContext): void;
2128
2128
  draw(): void;
2129
2129
  }
2130
2130
 
package/dist/index.d.mts CHANGED
@@ -2122,9 +2122,9 @@ declare class BaseElement2DText extends CoreObject {
2122
2122
  updateMeasure(): this;
2123
2123
  isValid(): boolean;
2124
2124
  protected _createVertTransform(): Transform2D | undefined;
2125
- protected _useDrawByTexture(): boolean;
2126
- protected _drawByVertices(ctx: CanvasContext): void;
2127
- protected _drawByTexture(ctx: CanvasContext): void;
2125
+ useTextureDraw(): boolean;
2126
+ protected _pathDraw(ctx: CanvasContext): void;
2127
+ protected _textureDraw(ctx: CanvasContext): void;
2128
2128
  draw(): void;
2129
2129
  }
2130
2130
 
package/dist/index.d.ts CHANGED
@@ -2122,9 +2122,9 @@ declare class BaseElement2DText extends CoreObject {
2122
2122
  updateMeasure(): this;
2123
2123
  isValid(): boolean;
2124
2124
  protected _createVertTransform(): Transform2D | undefined;
2125
- protected _useDrawByTexture(): boolean;
2126
- protected _drawByVertices(ctx: CanvasContext): void;
2127
- protected _drawByTexture(ctx: CanvasContext): void;
2125
+ useTextureDraw(): boolean;
2126
+ protected _pathDraw(ctx: CanvasContext): void;
2127
+ protected _textureDraw(ctx: CanvasContext): void;
2128
2128
  draw(): void;
2129
2129
  }
2130
2130