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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineProperty, Observable, Reactivable, parseColor, property, RawWeakMap as RawWeakMap$1, isGradient, isColorFillObject, clearUndef, idGenerator, normalizeFill, isNone, normalizeBackground, normalizeForeground, normalizeOutline, normalizeShadow, normalizeShape, getDefaultStyle, normalizeText, normalizeTextContent } from 'modern-idoc';
1
+ import { defineProperty, Observable, Reactivable, parseColor, property, RawWeakMap as RawWeakMap$1, isGradient, isColorFillObject, clearUndef, idGenerator, normalizeFill, isNone, normalizeBackground, normalizeForeground, normalizeOutline, normalizeShadow, normalizeShape, getDefaultStyle, normalizeText, normalizeTextContent, getDefaultTextStyle, getDefaultLayoutStyle } from 'modern-idoc';
2
2
  import { fonts } from 'modern-font';
3
3
  import { extend } from 'colord';
4
4
  import namesPlugin from 'colord/plugins/names';
@@ -10199,12 +10199,12 @@ class BaseElement2DText extends CoreObject {
10199
10199
  const origin = parent.getTransformOrigin();
10200
10200
  return new Transform2D().translate(-origin.x, -origin.y).scale(scale > 0 ? 1 : -1, 1).translate(origin.x, origin.y);
10201
10201
  }
10202
- _useDrawByTexture() {
10202
+ useTextureDraw() {
10203
10203
  return !!this.effects?.length || this.content.some((p) => {
10204
10204
  return p.fragments.some((f) => !!f.highlightImage);
10205
10205
  });
10206
10206
  }
10207
- _drawByVertices(ctx) {
10207
+ _pathDraw(ctx) {
10208
10208
  this.base.pathSets.forEach((pathSet) => {
10209
10209
  pathSet.paths.forEach((path) => {
10210
10210
  const meta = path.getMeta();
@@ -10275,7 +10275,7 @@ class BaseElement2DText extends CoreObject {
10275
10275
  });
10276
10276
  });
10277
10277
  }
10278
- _drawByTexture(ctx) {
10278
+ _textureDraw(ctx) {
10279
10279
  this._texture.width = Math.round(this.base.boundingBox.width);
10280
10280
  this._texture.height = Math.round(this.base.boundingBox.height);
10281
10281
  this.base.render({ view: this._texture.source });
@@ -10285,10 +10285,10 @@ class BaseElement2DText extends CoreObject {
10285
10285
  }
10286
10286
  draw() {
10287
10287
  const ctx = this.parent.context;
10288
- if (this._useDrawByTexture()) {
10289
- this._drawByTexture(ctx);
10288
+ if (this.useTextureDraw()) {
10289
+ this._textureDraw(ctx);
10290
10290
  } else {
10291
- this._drawByVertices(ctx);
10291
+ this._pathDraw(ctx);
10292
10292
  }
10293
10293
  }
10294
10294
  }
@@ -10325,6 +10325,8 @@ var __decorateClass$e = (decorators, target, key, kind) => {
10325
10325
  result = (decorator(result)) || result;
10326
10326
  return result;
10327
10327
  };
10328
+ const layoutStyle = new Set(Object.keys(getDefaultLayoutStyle()));
10329
+ const textStyles = new Set(Object.keys(getDefaultTextStyle()));
10328
10330
  let BaseElement2D = class extends Node2D {
10329
10331
  size = new Vector2().on("update", () => {
10330
10332
  this.updateGlobalTransform();
@@ -10485,6 +10487,11 @@ let BaseElement2D = class extends Node2D {
10485
10487
  this.requestRedraw();
10486
10488
  break;
10487
10489
  }
10490
+ if (textStyles.has(key) || layoutStyle.has(key)) {
10491
+ if (this.text.isValid()) {
10492
+ this.text.update();
10493
+ }
10494
+ }
10488
10495
  }
10489
10496
  _process(delta) {
10490
10497
  this.foreground.updateFrameIndex();
@@ -10660,7 +10667,9 @@ let BaseElement2D = class extends Node2D {
10660
10667
  }
10661
10668
  if (this._text.isValid()) {
10662
10669
  this._tree?.log(this.name, "text drawing");
10663
- this._shape.draw(true);
10670
+ if (this._text.useTextureDraw()) {
10671
+ this._shape.draw(true);
10672
+ }
10664
10673
  this._text.draw();
10665
10674
  }
10666
10675
  this._drawContent();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.12.0",
4
+ "version": "0.12.2",
5
5
  "packageManager": "pnpm@10.18.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",