modern-canvas 0.6.8 → 0.6.10

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
@@ -5770,9 +5770,6 @@ let Node = class extends CoreObject {
5770
5770
  return false;
5771
5771
  }
5772
5772
  }
5773
- _update(changed) {
5774
- super._update(changed);
5775
- }
5776
5773
  _updateProperty(key, value, oldValue, declaration) {
5777
5774
  super._updateProperty(key, value, oldValue, declaration);
5778
5775
  }
@@ -7098,29 +7095,26 @@ class CanvasContext extends Path2D {
7098
7095
  }
7099
7096
  }
7100
7097
  stroke(options) {
7101
- const path = new Path2D(this);
7102
- let texture = this._defaultStyle;
7103
- if (this.strokeStyle) {
7104
- texture = this._toTexture(this.strokeStyle);
7105
- }
7106
- if (this.curves.length) {
7107
- this._draws.push({
7108
- ...options,
7109
- type: "stroke",
7110
- path,
7111
- texture,
7112
- uvTransform: this.uvTransform,
7113
- vertTransform: this.vertTransform,
7114
- style: {
7115
- alignment: 0.5,
7116
- cap: this.lineCap ?? "butt",
7117
- join: this.lineJoin ?? "miter",
7118
- width: this.lineWidth ?? 1,
7119
- miterLimit: this.miterLimit ?? 10
7120
- }
7121
- });
7122
- super.reset();
7098
+ if (!this.curves.length) {
7099
+ return;
7123
7100
  }
7101
+ const strokeStyle = this.strokeStyle ?? (typeof this.style.stroke === "string" ? this.style.stroke : void 0);
7102
+ this._draws.push({
7103
+ ...options,
7104
+ type: "stroke",
7105
+ path: new Path2D(this),
7106
+ texture: strokeStyle ? this._toTexture(strokeStyle) : this._defaultStyle,
7107
+ uvTransform: this.uvTransform,
7108
+ vertTransform: this.vertTransform,
7109
+ style: {
7110
+ alignment: 0.5,
7111
+ cap: this.lineCap ?? "butt",
7112
+ join: this.lineJoin ?? "miter",
7113
+ width: this.lineWidth ?? 1,
7114
+ miterLimit: this.miterLimit ?? 10
7115
+ }
7116
+ });
7117
+ super.reset();
7124
7118
  }
7125
7119
  fillRect(x, y, width, height) {
7126
7120
  this.rect(x, y, width, height).fill();
@@ -7129,16 +7123,15 @@ class CanvasContext extends Path2D {
7129
7123
  this.rect(x, y, width, height).stroke();
7130
7124
  }
7131
7125
  fill(options) {
7132
- const path = new Path2D(this);
7133
- let texture = this._defaultStyle;
7134
- if (this.fillStyle) {
7135
- texture = this._toTexture(this.fillStyle);
7126
+ if (!this.curves.length) {
7127
+ return;
7136
7128
  }
7129
+ const fillStyle = this.fillStyle ?? (typeof this.style.fill === "string" ? this.style.fill : void 0);
7137
7130
  this._draws.push({
7138
7131
  ...options,
7139
7132
  type: "fill",
7140
- path,
7141
- texture,
7133
+ path: new Path2D(this),
7134
+ texture: fillStyle ? this._toTexture(fillStyle) : this._defaultStyle,
7142
7135
  uvTransform: this.uvTransform,
7143
7136
  vertTransform: this.vertTransform
7144
7137
  });
@@ -7297,15 +7290,12 @@ let CanvasItem = class extends TimelineNode {
7297
7290
  }
7298
7291
  requestRedraw() {
7299
7292
  this._redrawing = true;
7300
- this.requestUpdate();
7301
7293
  }
7302
7294
  requestRelayout() {
7303
7295
  this._relayouting = true;
7304
- this.requestUpdate();
7305
7296
  }
7306
7297
  requestRepaint() {
7307
7298
  this._repainting = true;
7308
- this.requestUpdate();
7309
7299
  }
7310
7300
  _updateGlobalVisible() {
7311
7301
  this._parentGlobalVisible = this.getParent()?.globalVisible;
@@ -7344,22 +7334,14 @@ let CanvasItem = class extends TimelineNode {
7344
7334
  _process(delta) {
7345
7335
  super._process(delta);
7346
7336
  const parent = this.getParent();
7347
- if (this._parentGlobalVisible !== parent?.globalVisible) {
7348
- this.requestUpdate();
7349
- }
7350
- if (this._parentGlobalOpacity !== parent?.globalOpacity) {
7351
- this.requestUpdate();
7352
- }
7353
- }
7354
- _update(changed) {
7355
- super._update(changed);
7356
- const parent = this.getParent();
7357
7337
  if (this._parentGlobalVisible !== parent?.globalVisible) {
7358
7338
  this._updateGlobalVisible();
7359
7339
  }
7360
7340
  if (this._parentGlobalOpacity !== parent?.globalOpacity) {
7361
7341
  this._updateGlobalOpacity();
7362
7342
  }
7343
+ }
7344
+ _updateBatchables() {
7363
7345
  const redrawing = this._redrawing;
7364
7346
  let relayouting = this._relayouting;
7365
7347
  let repainting = this._repainting;
@@ -7388,6 +7370,7 @@ let CanvasItem = class extends TimelineNode {
7388
7370
  }
7389
7371
  }
7390
7372
  _render(renderer) {
7373
+ this._updateBatchables();
7391
7374
  this._batchables.forEach((batchable) => {
7392
7375
  batchable.texture?.upload(renderer);
7393
7376
  renderer.batch2D.render({
@@ -9339,15 +9322,13 @@ class BaseElement2DText extends CoreObject {
9339
9322
  draw() {
9340
9323
  const ctx = this.parent.context;
9341
9324
  this.base.update();
9342
- this.base.paragraphs.forEach((p) => {
9343
- p.fragments.forEach((f) => {
9344
- f.characters.forEach((c) => {
9345
- ctx.fillStyle = c.computedStyle.color;
9346
- ctx.addPath(c.path);
9347
- ctx.style.fillRule = "evenodd";
9348
- ctx.closePath();
9349
- ctx.fill();
9350
- });
9325
+ this.base.pathSets.forEach((pathSet) => {
9326
+ pathSet.paths.forEach((path) => {
9327
+ ctx.addPath(path);
9328
+ ctx.style = { ...path.style };
9329
+ ctx.fillStyle = void 0;
9330
+ ctx.strokeStyle = void 0;
9331
+ ctx.fill();
9351
9332
  });
9352
9333
  });
9353
9334
  }
@@ -9396,7 +9377,7 @@ let Node2D = class extends CanvasItem {
9396
9377
  super._updateProperty(key, value, oldValue, declaration);
9397
9378
  switch (key) {
9398
9379
  case "rotation":
9399
- this.updateGlobalTransform();
9380
+ this.requestRelayout();
9400
9381
  break;
9401
9382
  }
9402
9383
  }
@@ -13591,7 +13572,7 @@ let CanvasItemEditor = class extends Control {
13591
13572
  style: {
13592
13573
  width: 500,
13593
13574
  height: 500,
13594
- backgroundColor: "#FFFFFFFF",
13575
+ backgroundColor: "#00FFFFFF",
13595
13576
  // overflow: 'hidden',
13596
13577
  pointerEvents: "none"
13597
13578
  // boxShadow: '2px 2px 2px 1px rgba(0, 0, 0, 0.2)',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.6.8",
4
+ "version": "0.6.10",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",
@@ -70,15 +70,15 @@
70
70
  "colord": "^2.9.3",
71
71
  "earcut": "^3.0.1",
72
72
  "modern-font": "^0.4.1",
73
- "modern-idoc": "^0.8.2",
74
- "modern-path2d": "^1.4.1",
75
- "modern-text": "^1.6.1",
73
+ "modern-idoc": "^0.8.4",
74
+ "modern-path2d": "^1.4.3",
75
+ "modern-text": "^1.6.4",
76
76
  "yoga-layout": "^3.2.1"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@antfu/eslint-config": "^4.16.2",
80
80
  "@types/earcut": "^3.0.0",
81
- "@types/node": "^24.0.10",
81
+ "@types/node": "^24.0.12",
82
82
  "bumpp": "^10.2.0",
83
83
  "conventional-changelog-cli": "^5.0.0",
84
84
  "eslint": "^9.30.1",
@@ -88,7 +88,7 @@
88
88
  "simple-git-hooks": "^2.13.0",
89
89
  "typescript": "^5.8.3",
90
90
  "unbuild": "^3.5.0",
91
- "vite": "^7.0.2",
91
+ "vite": "^7.0.3",
92
92
  "vitest": "^3.2.4"
93
93
  },
94
94
  "simple-git-hooks": {