modern-canvas 0.7.5 → 0.7.6

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
@@ -752,10 +752,11 @@ class Input extends modernIdoc.EventEmitter {
752
752
  mapPositionToPoint(point, x, y) {
753
753
  if (!this.target)
754
754
  return;
755
- const width = Number(this.target.getAttribute("width")) || 0;
756
- const height = Number(this.target.getAttribute("height")) || 0;
755
+ const clientRect = this.target.isConnected ? this.target.getBoundingClientRect() : void 0;
757
756
  const pixelRatio = Number(this.target.getAttribute("data-pixel-ratio")) || 1;
758
- const rect = this.target.isConnected ? this.target.getBoundingClientRect() : { width, height, left: 0, top: 0 };
757
+ const width = Number(this.target.getAttribute("width")) || (clientRect ? clientRect.width * pixelRatio : 0);
758
+ const height = Number(this.target.getAttribute("height")) || (clientRect ? clientRect.height * pixelRatio : 0);
759
+ const rect = clientRect ?? { width, height, left: 0, top: 0 };
759
760
  const multiplier = 1 / pixelRatio;
760
761
  point.x = (x - rect.left) * (width / rect.width) * multiplier;
761
762
  point.y = (y - rect.top) * (height / rect.height) * multiplier;
@@ -5454,7 +5455,7 @@ class CanvasContext extends modernPath2d.Path2D {
5454
5455
  miterLimit: this.miterLimit ?? 10
5455
5456
  }
5456
5457
  });
5457
- super.reset();
5458
+ this.reset();
5458
5459
  }
5459
5460
  fillRect(x, y, width, height) {
5460
5461
  this.rect(x, y, width, height).fill();
@@ -5487,7 +5488,7 @@ class CanvasContext extends modernPath2d.Path2D {
5487
5488
  uvTransform: this.uvTransform,
5488
5489
  vertTransform: this.vertTransform
5489
5490
  });
5490
- super.reset();
5491
+ this.resetStatus();
5491
5492
  }
5492
5493
  copy(source) {
5493
5494
  super.copy(source);
@@ -5502,7 +5503,7 @@ class CanvasContext extends modernPath2d.Path2D {
5502
5503
  this._draws = source._draws.slice();
5503
5504
  return this;
5504
5505
  }
5505
- reset() {
5506
+ resetStatus() {
5506
5507
  super.reset();
5507
5508
  this.strokeStyle = void 0;
5508
5509
  this.fillStyle = void 0;
@@ -5512,6 +5513,9 @@ class CanvasContext extends modernPath2d.Path2D {
5512
5513
  this.lineJoin = void 0;
5513
5514
  this.lineWidth = void 0;
5514
5515
  this.miterLimit = void 0;
5516
+ }
5517
+ reset() {
5518
+ this.resetStatus();
5515
5519
  this._draws.length = 0;
5516
5520
  return this;
5517
5521
  }
@@ -9572,7 +9576,6 @@ class BaseElement2DText extends CoreObject {
9572
9576
  case "fonts":
9573
9577
  case "fill":
9574
9578
  case "outline":
9575
- case "split":
9576
9579
  this.parent.requestRedraw();
9577
9580
  break;
9578
9581
  }
@@ -9586,6 +9589,9 @@ class BaseElement2DText extends CoreObject {
9586
9589
  };
9587
9590
  this.base.requestUpdate();
9588
9591
  }
9592
+ setContent(content) {
9593
+ this.content = modernIdoc.normalizeTextContent(content);
9594
+ }
9589
9595
  measure() {
9590
9596
  this._updateText();
9591
9597
  return this.base.measure();
@@ -9606,8 +9612,6 @@ class BaseElement2DText extends CoreObject {
9606
9612
  pathSet.paths.forEach((path) => {
9607
9613
  ctx.addPath(path);
9608
9614
  ctx.style = { ...path.style };
9609
- ctx.fillStyle = void 0;
9610
- ctx.strokeStyle = void 0;
9611
9615
  ctx.fill();
9612
9616
  });
9613
9617
  });
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Font } from 'modern-font';
2
- import { EventListenerOptions as EventListenerOptions$1, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, Style, ImageFillCropRect } from 'modern-idoc';
2
+ import { EventListenerOptions as EventListenerOptions$1, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, TextContent, Style, ImageFillCropRect } from 'modern-idoc';
3
3
  export { Color as ColorValue } from 'modern-idoc';
4
4
  import { AnimationItem } from 'lottie-web';
5
5
  import { Colord, RgbaColor, HslaColor, HsvaColor } from 'colord';
@@ -1438,6 +1438,7 @@ declare class CanvasContext extends Path2D {
1438
1438
  strokeRect(x: number, y: number, width: number, height: number): void;
1439
1439
  fill(options?: Partial<FillDraw>): void;
1440
1440
  copy(source: CanvasContext): this;
1441
+ resetStatus(): void;
1441
1442
  reset(): this;
1442
1443
  buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture2D, uvTransform?: UVTransform): void;
1443
1444
  toBatchables(): CanvasBatchable[];
@@ -2024,6 +2025,7 @@ declare class BaseElement2DText extends CoreObject {
2024
2025
  setProperties(properties?: Text$1): this;
2025
2026
  protected _updateProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2026
2027
  protected _updateText(): void;
2028
+ setContent(content: TextContent): void;
2027
2029
  measure(): MeasureResult;
2028
2030
  updateMeasure(): this;
2029
2031
  canDraw(): boolean;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Font } from 'modern-font';
2
- import { EventListenerOptions as EventListenerOptions$1, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, Style, ImageFillCropRect } from 'modern-idoc';
2
+ import { EventListenerOptions as EventListenerOptions$1, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, TextContent, Style, ImageFillCropRect } from 'modern-idoc';
3
3
  export { Color as ColorValue } from 'modern-idoc';
4
4
  import { AnimationItem } from 'lottie-web';
5
5
  import { Colord, RgbaColor, HslaColor, HsvaColor } from 'colord';
@@ -1438,6 +1438,7 @@ declare class CanvasContext extends Path2D {
1438
1438
  strokeRect(x: number, y: number, width: number, height: number): void;
1439
1439
  fill(options?: Partial<FillDraw>): void;
1440
1440
  copy(source: CanvasContext): this;
1441
+ resetStatus(): void;
1441
1442
  reset(): this;
1442
1443
  buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture2D, uvTransform?: UVTransform): void;
1443
1444
  toBatchables(): CanvasBatchable[];
@@ -2024,6 +2025,7 @@ declare class BaseElement2DText extends CoreObject {
2024
2025
  setProperties(properties?: Text$1): this;
2025
2026
  protected _updateProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2026
2027
  protected _updateText(): void;
2028
+ setContent(content: TextContent): void;
2027
2029
  measure(): MeasureResult;
2028
2030
  updateMeasure(): this;
2029
2031
  canDraw(): boolean;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Font } from 'modern-font';
2
- import { EventListenerOptions as EventListenerOptions$1, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, Style, ImageFillCropRect } from 'modern-idoc';
2
+ import { EventListenerOptions as EventListenerOptions$1, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, TextContent, Style, ImageFillCropRect } from 'modern-idoc';
3
3
  export { Color as ColorValue } from 'modern-idoc';
4
4
  import { AnimationItem } from 'lottie-web';
5
5
  import { Colord, RgbaColor, HslaColor, HsvaColor } from 'colord';
@@ -1438,6 +1438,7 @@ declare class CanvasContext extends Path2D {
1438
1438
  strokeRect(x: number, y: number, width: number, height: number): void;
1439
1439
  fill(options?: Partial<FillDraw>): void;
1440
1440
  copy(source: CanvasContext): this;
1441
+ resetStatus(): void;
1441
1442
  reset(): this;
1442
1443
  buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture2D, uvTransform?: UVTransform): void;
1443
1444
  toBatchables(): CanvasBatchable[];
@@ -2024,6 +2025,7 @@ declare class BaseElement2DText extends CoreObject {
2024
2025
  setProperties(properties?: Text$1): this;
2025
2026
  protected _updateProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2026
2027
  protected _updateText(): void;
2028
+ setContent(content: TextContent): void;
2027
2029
  measure(): MeasureResult;
2028
2030
  updateMeasure(): this;
2029
2031
  canDraw(): boolean;