modern-canvas 0.6.9 → 0.6.11

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
@@ -5599,7 +5599,6 @@ function getNodeIid(key) {
5599
5599
  return iid;
5600
5600
  }
5601
5601
  exports.Node = class Node extends CoreObject {
5602
- meta = {};
5603
5602
  _readyed = false;
5604
5603
  constructor(properties, nodes = []) {
5605
5604
  super();
@@ -6088,6 +6087,9 @@ __decorateClass$R([
6088
6087
  __decorateClass$R([
6089
6088
  modernIdoc.property({ fallback: "default" })
6090
6089
  ], exports.Node.prototype, "internalMode", 2);
6090
+ __decorateClass$R([
6091
+ modernIdoc.property({ default: () => ({}) })
6092
+ ], exports.Node.prototype, "meta", 2);
6091
6093
  __decorateClass$R([
6092
6094
  modernIdoc.property({ protected: true })
6093
6095
  ], exports.Node.prototype, "mask", 2);
@@ -7101,29 +7103,26 @@ class CanvasContext extends modernPath2d.Path2D {
7101
7103
  }
7102
7104
  }
7103
7105
  stroke(options) {
7104
- const path = new modernPath2d.Path2D(this);
7105
- let texture = this._defaultStyle;
7106
- if (this.strokeStyle) {
7107
- texture = this._toTexture(this.strokeStyle);
7108
- }
7109
- if (this.curves.length) {
7110
- this._draws.push({
7111
- ...options,
7112
- type: "stroke",
7113
- path,
7114
- texture,
7115
- uvTransform: this.uvTransform,
7116
- vertTransform: this.vertTransform,
7117
- style: {
7118
- alignment: 0.5,
7119
- cap: this.lineCap ?? "butt",
7120
- join: this.lineJoin ?? "miter",
7121
- width: this.lineWidth ?? 1,
7122
- miterLimit: this.miterLimit ?? 10
7123
- }
7124
- });
7125
- super.reset();
7106
+ if (!this.curves.length) {
7107
+ return;
7126
7108
  }
7109
+ const strokeStyle = this.strokeStyle ?? (typeof this.style.stroke === "string" ? this.style.stroke : void 0);
7110
+ this._draws.push({
7111
+ ...options,
7112
+ type: "stroke",
7113
+ path: new modernPath2d.Path2D(this),
7114
+ texture: strokeStyle ? this._toTexture(strokeStyle) : this._defaultStyle,
7115
+ uvTransform: this.uvTransform,
7116
+ vertTransform: this.vertTransform,
7117
+ style: {
7118
+ alignment: 0.5,
7119
+ cap: this.lineCap ?? "butt",
7120
+ join: this.lineJoin ?? "miter",
7121
+ width: this.lineWidth ?? 1,
7122
+ miterLimit: this.miterLimit ?? 10
7123
+ }
7124
+ });
7125
+ super.reset();
7127
7126
  }
7128
7127
  fillRect(x, y, width, height) {
7129
7128
  this.rect(x, y, width, height).fill();
@@ -7132,16 +7131,15 @@ class CanvasContext extends modernPath2d.Path2D {
7132
7131
  this.rect(x, y, width, height).stroke();
7133
7132
  }
7134
7133
  fill(options) {
7135
- const path = new modernPath2d.Path2D(this);
7136
- let texture = this._defaultStyle;
7137
- if (this.fillStyle) {
7138
- texture = this._toTexture(this.fillStyle);
7134
+ if (!this.curves.length) {
7135
+ return;
7139
7136
  }
7137
+ const fillStyle = this.fillStyle ?? (typeof this.style.fill === "string" ? this.style.fill : void 0);
7140
7138
  this._draws.push({
7141
7139
  ...options,
7142
7140
  type: "fill",
7143
- path,
7144
- texture,
7141
+ path: new modernPath2d.Path2D(this),
7142
+ texture: fillStyle ? this._toTexture(fillStyle) : this._defaultStyle,
7145
7143
  uvTransform: this.uvTransform,
7146
7144
  vertTransform: this.vertTransform
7147
7145
  });
@@ -9332,15 +9330,13 @@ class BaseElement2DText extends CoreObject {
9332
9330
  draw() {
9333
9331
  const ctx = this.parent.context;
9334
9332
  this.base.update();
9335
- this.base.paragraphs.forEach((p) => {
9336
- p.fragments.forEach((f) => {
9337
- f.characters.forEach((c) => {
9338
- ctx.fillStyle = c.computedStyle.color;
9339
- ctx.addPath(c.path);
9340
- ctx.style.fillRule = "evenodd";
9341
- ctx.closePath();
9342
- ctx.fill();
9343
- });
9333
+ this.base.pathSets.forEach((pathSet) => {
9334
+ pathSet.paths.forEach((path) => {
9335
+ ctx.addPath(path);
9336
+ ctx.style = { ...path.style };
9337
+ ctx.fillStyle = void 0;
9338
+ ctx.strokeStyle = void 0;
9339
+ ctx.fill();
9344
9340
  });
9345
9341
  });
9346
9342
  }
@@ -9389,7 +9385,7 @@ exports.Node2D = class Node2D extends exports.CanvasItem {
9389
9385
  super._updateProperty(key, value, oldValue, declaration);
9390
9386
  switch (key) {
9391
9387
  case "rotation":
9392
- this.updateGlobalTransform();
9388
+ this.requestRelayout();
9393
9389
  break;
9394
9390
  }
9395
9391
  }
@@ -13584,7 +13580,7 @@ exports.CanvasItemEditor = class CanvasItemEditor extends exports.Control {
13584
13580
  style: {
13585
13581
  width: 500,
13586
13582
  height: 500,
13587
- backgroundColor: "#FFFFFFFF",
13583
+ backgroundColor: "#00FFFFFF",
13588
13584
  // overflow: 'hidden',
13589
13585
  pointerEvents: "none"
13590
13586
  // boxShadow: '2px 2px 2px 1px rgba(0, 0, 0, 0.2)',
package/dist/index.d.cts CHANGED
@@ -1629,8 +1629,8 @@ declare class Node extends CoreObject {
1629
1629
  processSortMode: ProcessSortMode;
1630
1630
  renderMode: RenderMode;
1631
1631
  internalMode: InternalMode;
1632
+ meta: Record<string, any>;
1632
1633
  mask?: Maskable;
1633
- readonly meta: Record<string, any>;
1634
1634
  protected _readyed: boolean;
1635
1635
  constructor(properties?: Partial<NodeProperties>, nodes?: Node[]);
1636
1636
  setProperties(properties?: Record<string, any>): this;
package/dist/index.d.mts CHANGED
@@ -1629,8 +1629,8 @@ declare class Node extends CoreObject {
1629
1629
  processSortMode: ProcessSortMode;
1630
1630
  renderMode: RenderMode;
1631
1631
  internalMode: InternalMode;
1632
+ meta: Record<string, any>;
1632
1633
  mask?: Maskable;
1633
- readonly meta: Record<string, any>;
1634
1634
  protected _readyed: boolean;
1635
1635
  constructor(properties?: Partial<NodeProperties>, nodes?: Node[]);
1636
1636
  setProperties(properties?: Record<string, any>): this;
package/dist/index.d.ts CHANGED
@@ -1629,8 +1629,8 @@ declare class Node extends CoreObject {
1629
1629
  processSortMode: ProcessSortMode;
1630
1630
  renderMode: RenderMode;
1631
1631
  internalMode: InternalMode;
1632
+ meta: Record<string, any>;
1632
1633
  mask?: Maskable;
1633
- readonly meta: Record<string, any>;
1634
1634
  protected _readyed: boolean;
1635
1635
  constructor(properties?: Partial<NodeProperties>, nodes?: Node[]);
1636
1636
  setProperties(properties?: Record<string, any>): this;