modern-canvas 0.5.1 → 0.5.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
@@ -9312,7 +9312,6 @@ class BaseElement2DText extends CoreObject {
9312
9312
  this.parent = parent;
9313
9313
  }
9314
9314
  base = new Text();
9315
- texture = new CanvasTexture();
9316
9315
  measureResult;
9317
9316
  setProperties(properties) {
9318
9317
  return super.setProperties(
@@ -9351,29 +9350,23 @@ class BaseElement2DText extends CoreObject {
9351
9350
  }
9352
9351
  canDraw() {
9353
9352
  return Boolean(
9354
- this.enabled && !/^\s*$/.test(this.base.toString()) && this.texture?.valid
9353
+ this.enabled && !/^\s*$/.test(this.base.toString())
9355
9354
  );
9356
9355
  }
9357
9356
  draw() {
9358
- this.base.render({
9359
- pixelRatio: this.texture.pixelRatio,
9360
- view: this.texture.source
9361
- });
9362
- this.texture.requestUpload();
9363
- const textWidth = this.measureResult?.boundingBox.width ?? this.parent.size.width;
9364
- const textHeight = this.measureResult?.boundingBox.height ?? this.parent.size.height;
9365
9357
  const ctx = this.parent.context;
9366
- ctx.fillStyle = this.texture;
9367
- ctx.uvTransform = new Transform2D().scale(1 / textWidth, 1 / textHeight);
9368
- ctx.vertTransform = () => {
9369
- const parent = this.parent;
9370
- const origin = parent.getTransformOrigin();
9371
- return new Transform2D().translate(-origin.x, -origin.y).scale(
9372
- parent.globalScale.x > 0 ? 1 : -1,
9373
- parent.globalScale.y > 0 ? 1 : -1
9374
- ).translate(origin.x, origin.y);
9375
- };
9376
- ctx.fill();
9358
+ this.base.update();
9359
+ this.base.paragraphs.forEach((p) => {
9360
+ p.fragments.forEach((f) => {
9361
+ f.characters.forEach((c) => {
9362
+ ctx.fillStyle = c.computedStyle.color;
9363
+ ctx.addPath(c.path);
9364
+ ctx.style.fillRule = "evenodd";
9365
+ ctx.closePath();
9366
+ ctx.fill();
9367
+ });
9368
+ });
9369
+ });
9377
9370
  }
9378
9371
  }
9379
9372
  __decorateClass$o([
@@ -9784,7 +9777,6 @@ let BaseElement2D = class extends Node2D {
9784
9777
  }
9785
9778
  if (this._text.canDraw()) {
9786
9779
  this._tree?.log(this.name, "draw text");
9787
- this._shape.drawRect();
9788
9780
  this._text.draw();
9789
9781
  }
9790
9782
  this._drawContent();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.5.1",
4
+ "version": "0.5.2",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",
@@ -78,10 +78,10 @@
78
78
  "devDependencies": {
79
79
  "@antfu/eslint-config": "^4.16.1",
80
80
  "@types/earcut": "^3.0.0",
81
- "@types/node": "^24.0.4",
81
+ "@types/node": "^24.0.7",
82
82
  "bumpp": "^10.2.0",
83
83
  "conventional-changelog-cli": "^5.0.0",
84
- "eslint": "^9.29.0",
84
+ "eslint": "^9.30.0",
85
85
  "lint-staged": "^16.1.2",
86
86
  "lottie-web": "^5.13.0",
87
87
  "modern-gif": "^2.0.4",