laymur 0.3.19 → 0.3.22

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.
@@ -60,59 +60,59 @@ export declare class UIGraphics extends UIElement {
60
60
  *
61
61
  * @param fillColor - Optional color to fill after clearing (CSS color string)
62
62
  */
63
- clear(fillColor?: string): void;
63
+ clear(fillColor?: string): this;
64
64
  /**
65
65
  * Draws a rectangle on the canvas.
66
66
  */
67
- rect(x: number, y: number, width: number, height: number): void;
67
+ rect(x: number, y: number, width: number, height: number): this;
68
68
  /**
69
69
  * Draws a filled rectangle on the canvas.
70
70
  */
71
- fillRect(x: number, y: number, width: number, height: number): void;
71
+ fillRect(x: number, y: number, width: number, height: number): this;
72
72
  /**
73
73
  * Draws a stroked rectangle on the canvas.
74
74
  */
75
- strokeRect(x: number, y: number, width: number, height: number): void;
75
+ strokeRect(x: number, y: number, width: number, height: number): this;
76
76
  /**
77
77
  * Draws a circle on the canvas.
78
78
  */
79
- circle(x: number, y: number, radius: number): void;
79
+ circle(x: number, y: number, radius: number): this;
80
80
  /**
81
81
  * Begins a new path.
82
82
  */
83
- beginPath(): void;
83
+ beginPath(): this;
84
84
  /**
85
85
  * Closes the current path.
86
86
  */
87
- closePath(): void;
87
+ closePath(): this;
88
88
  /**
89
89
  * Fills the current path.
90
90
  */
91
- fill(): void;
91
+ fill(): this;
92
92
  /**
93
93
  * Strokes the current path.
94
94
  */
95
- stroke(): void;
95
+ stroke(): this;
96
96
  /**
97
97
  * Moves the path to a point.
98
98
  */
99
- moveTo(x: number, y: number): void;
99
+ moveTo(x: number, y: number): this;
100
100
  /**
101
101
  * Draws a line to a point.
102
102
  */
103
- lineTo(x: number, y: number): void;
103
+ lineTo(x: number, y: number): this;
104
104
  /**
105
105
  * Sets the fill style.
106
106
  */
107
- setFillStyle(style: string | CanvasGradient | CanvasPattern): void;
107
+ setFillStyle(style: string | CanvasGradient | CanvasPattern): this;
108
108
  /**
109
109
  * Sets the stroke style.
110
110
  */
111
- setStrokeStyle(style: string | CanvasGradient | CanvasPattern): void;
111
+ setStrokeStyle(style: string | CanvasGradient | CanvasPattern): this;
112
112
  /**
113
113
  * Sets the line width.
114
114
  */
115
- setLineWidth(width: number): void;
115
+ setLineWidth(width: number): this;
116
116
  /**
117
117
  * Destroys the graphics element by cleaning up resources.
118
118
  */
package/dist/index.js CHANGED
@@ -5290,6 +5290,7 @@ class UIGraphics extends UIElement {
5290
5290
  this._private_ctx.fillRect(0, 0, this._private_canvas.width, this._private_canvas.height);
5291
5291
  }
5292
5292
  this._private_canvasTexture.needsUpdate = true;
5293
+ return this;
5293
5294
  }
5294
5295
  /**
5295
5296
  * Draws a rectangle on the canvas.
@@ -5297,6 +5298,7 @@ class UIGraphics extends UIElement {
5297
5298
  rect(x, y, width, height) {
5298
5299
  this._private_ctx.rect(x, y, width, height);
5299
5300
  this._private_canvasTexture.needsUpdate = true;
5301
+ return this;
5300
5302
  }
5301
5303
  /**
5302
5304
  * Draws a filled rectangle on the canvas.
@@ -5304,6 +5306,7 @@ class UIGraphics extends UIElement {
5304
5306
  fillRect(x, y, width, height) {
5305
5307
  this._private_ctx.fillRect(x, y, width, height);
5306
5308
  this._private_canvasTexture.needsUpdate = true;
5309
+ return this;
5307
5310
  }
5308
5311
  /**
5309
5312
  * Draws a stroked rectangle on the canvas.
@@ -5311,6 +5314,7 @@ class UIGraphics extends UIElement {
5311
5314
  strokeRect(x, y, width, height) {
5312
5315
  this._private_ctx.strokeRect(x, y, width, height);
5313
5316
  this._private_canvasTexture.needsUpdate = true;
5317
+ return this;
5314
5318
  }
5315
5319
  /**
5316
5320
  * Draws a circle on the canvas.
@@ -5320,6 +5324,7 @@ class UIGraphics extends UIElement {
5320
5324
  this._private_ctx.arc(x, y, radius, 0, Math.PI * 2);
5321
5325
  this._private_ctx.closePath();
5322
5326
  this._private_canvasTexture.needsUpdate = true;
5327
+ return this;
5323
5328
  }
5324
5329
  /**
5325
5330
  * Begins a new path.
@@ -5327,6 +5332,7 @@ class UIGraphics extends UIElement {
5327
5332
  beginPath() {
5328
5333
  this._private_ctx.beginPath();
5329
5334
  this._private_canvasTexture.needsUpdate = true;
5335
+ return this;
5330
5336
  }
5331
5337
  /**
5332
5338
  * Closes the current path.
@@ -5334,6 +5340,7 @@ class UIGraphics extends UIElement {
5334
5340
  closePath() {
5335
5341
  this._private_ctx.closePath();
5336
5342
  this._private_canvasTexture.needsUpdate = true;
5343
+ return this;
5337
5344
  }
5338
5345
  /**
5339
5346
  * Fills the current path.
@@ -5341,6 +5348,7 @@ class UIGraphics extends UIElement {
5341
5348
  fill() {
5342
5349
  this._private_ctx.fill();
5343
5350
  this._private_canvasTexture.needsUpdate = true;
5351
+ return this;
5344
5352
  }
5345
5353
  /**
5346
5354
  * Strokes the current path.
@@ -5348,13 +5356,14 @@ class UIGraphics extends UIElement {
5348
5356
  stroke() {
5349
5357
  this._private_ctx.stroke();
5350
5358
  this._private_canvasTexture.needsUpdate = true;
5359
+ return this;
5351
5360
  }
5352
5361
  /**
5353
5362
  * Moves the path to a point.
5354
5363
  */
5355
5364
  moveTo(x, y) {
5356
5365
  this._private_ctx.moveTo(x, y);
5357
- this._private_canvasTexture.needsUpdate = true;
5366
+ return this;
5358
5367
  }
5359
5368
  /**
5360
5369
  * Draws a line to a point.
@@ -5362,27 +5371,28 @@ class UIGraphics extends UIElement {
5362
5371
  lineTo(x, y) {
5363
5372
  this._private_ctx.lineTo(x, y);
5364
5373
  this._private_canvasTexture.needsUpdate = true;
5374
+ return this;
5365
5375
  }
5366
5376
  /**
5367
5377
  * Sets the fill style.
5368
5378
  */
5369
5379
  setFillStyle(style) {
5370
5380
  this._private_ctx.fillStyle = style;
5371
- this._private_canvasTexture.needsUpdate = true;
5381
+ return this;
5372
5382
  }
5373
5383
  /**
5374
5384
  * Sets the stroke style.
5375
5385
  */
5376
5386
  setStrokeStyle(style) {
5377
5387
  this._private_ctx.strokeStyle = style;
5378
- this._private_canvasTexture.needsUpdate = true;
5388
+ return this;
5379
5389
  }
5380
5390
  /**
5381
5391
  * Sets the line width.
5382
5392
  */
5383
5393
  setLineWidth(width) {
5384
5394
  this._private_ctx.lineWidth = width;
5385
- this._private_canvasTexture.needsUpdate = true;
5395
+ return this;
5386
5396
  }
5387
5397
  /**
5388
5398
  * Destroys the graphics element by cleaning up resources.
@@ -6639,13 +6649,17 @@ class UIText extends UIElement {
6639
6649
  }
6640
6650
  }
6641
6651
 
6652
+ var UIResizePolicyEvent;
6653
+ (function (UIResizePolicyEvent) {
6654
+ UIResizePolicyEvent[UIResizePolicyEvent["CHANGE"] = 0] = "CHANGE";
6655
+ })(UIResizePolicyEvent || (UIResizePolicyEvent = {}));
6642
6656
  /**
6643
6657
  * Base class for UI resize policies.
6644
6658
  *
6645
6659
  * Calculates scale factors based on viewport dimensions. Different policies
6646
6660
  * implement different scaling strategies.
6647
6661
  */
6648
- class UIResizePolicy {
6662
+ class UIResizePolicy extends i {
6649
6663
  }
6650
6664
  /**
6651
6665
  * No scaling applied, always returns 1:1 scale.
@@ -6667,15 +6681,35 @@ class UIResizePolicyFixedWidth extends UIResizePolicy {
6667
6681
  */
6668
6682
  constructor(fixedWidthLandscape, fixedWidthPortrait) {
6669
6683
  super();
6670
- this.fixedWidthLandscape = fixedWidthLandscape;
6671
- this.fixedWidthPortrait = fixedWidthPortrait;
6672
6684
  assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyFixedWidth.fixedWidthLandscape");
6673
6685
  assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyFixedWidth.fixedWidthPortrait");
6686
+ this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
6687
+ this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
6688
+ }
6689
+ get fixedWidthLandscape() {
6690
+ return this._private_fixedWidthLandscapeInternal;
6691
+ }
6692
+ get fixedWidthPortrait() {
6693
+ return this._private_fixedWidthPortraitInternal;
6694
+ }
6695
+ set fixedWidthLandscape(value) {
6696
+ assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthLandscape");
6697
+ if (value !== this._private_fixedWidthLandscapeInternal) {
6698
+ this._private_fixedWidthLandscapeInternal = value;
6699
+ this.emit(UIResizePolicyEvent.CHANGE);
6700
+ }
6701
+ }
6702
+ set fixedWidthPortrait(value) {
6703
+ assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthPortrait");
6704
+ if (value !== this._private_fixedWidthPortraitInternal) {
6705
+ this._private_fixedWidthPortraitInternal = value;
6706
+ this.emit(UIResizePolicyEvent.CHANGE);
6707
+ }
6674
6708
  }
6675
6709
  calculateScaleInternal(width, height) {
6676
6710
  return width > height
6677
- ? this.fixedWidthLandscape / width
6678
- : this.fixedWidthPortrait / width;
6711
+ ? this._private_fixedWidthLandscapeInternal / width
6712
+ : this._private_fixedWidthPortraitInternal / width;
6679
6713
  }
6680
6714
  }
6681
6715
  /**
@@ -6690,15 +6724,35 @@ class UIResizePolicyFixedHeight extends UIResizePolicy {
6690
6724
  */
6691
6725
  constructor(fixedHeightLandscape, fixedHeightPortrait) {
6692
6726
  super();
6693
- this.fixedHeightLandscape = fixedHeightLandscape;
6694
- this.fixedHeightPortrait = fixedHeightPortrait;
6695
6727
  assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyFixedHeight.fixedHeightLandscape");
6696
6728
  assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyFixedHeight.fixedHeightPortrait");
6729
+ this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
6730
+ this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
6731
+ }
6732
+ get fixedHeightLandscape() {
6733
+ return this._private_fixedHeightLandscapeInternal;
6734
+ }
6735
+ get fixedHeightPortrait() {
6736
+ return this._private_fixedHeightPortraitInternal;
6737
+ }
6738
+ set fixedHeightLandscape(value) {
6739
+ assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightLandscape");
6740
+ if (value !== this._private_fixedHeightLandscapeInternal) {
6741
+ this._private_fixedHeightLandscapeInternal = value;
6742
+ this.emit(UIResizePolicyEvent.CHANGE);
6743
+ }
6744
+ }
6745
+ set fixedHeightPortrait(value) {
6746
+ assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightPortrait");
6747
+ if (value !== this._private_fixedHeightPortraitInternal) {
6748
+ this._private_fixedHeightPortraitInternal = value;
6749
+ this.emit(UIResizePolicyEvent.CHANGE);
6750
+ }
6697
6751
  }
6698
6752
  calculateScaleInternal(width, height) {
6699
6753
  return width > height
6700
- ? this.fixedHeightLandscape / height
6701
- : this.fixedHeightPortrait / height;
6754
+ ? this._private_fixedHeightLandscapeInternal / height
6755
+ : this._private_fixedHeightPortraitInternal / height;
6702
6756
  }
6703
6757
  }
6704
6758
  /**
@@ -6711,15 +6765,35 @@ class UIResizePolicyCross extends UIResizePolicy {
6711
6765
  */
6712
6766
  constructor(fixedWidthLandscape, fixedHeightPortrait) {
6713
6767
  super();
6714
- this.fixedWidthLandscape = fixedWidthLandscape;
6715
- this.fixedHeightPortrait = fixedHeightPortrait;
6716
6768
  assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyCross.fixedWidthLandscape");
6717
6769
  assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyCross.fixedHeightPortrait");
6770
+ this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
6771
+ this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
6772
+ }
6773
+ get fixedWidthLandscape() {
6774
+ return this._private_fixedWidthLandscapeInternal;
6775
+ }
6776
+ get fixedHeightPortrait() {
6777
+ return this._private_fixedHeightPortraitInternal;
6778
+ }
6779
+ set fixedWidthLandscape(value) {
6780
+ assertValidPositiveNumber(value, "UIResizePolicyCross.fixedWidthLandscape");
6781
+ if (value !== this._private_fixedWidthLandscapeInternal) {
6782
+ this._private_fixedWidthLandscapeInternal = value;
6783
+ this.emit(UIResizePolicyEvent.CHANGE);
6784
+ }
6785
+ }
6786
+ set fixedHeightPortrait(value) {
6787
+ assertValidPositiveNumber(value, "UIResizePolicyCross.fixedHeightPortrait");
6788
+ if (value !== this._private_fixedHeightPortraitInternal) {
6789
+ this._private_fixedHeightPortraitInternal = value;
6790
+ this.emit(UIResizePolicyEvent.CHANGE);
6791
+ }
6718
6792
  }
6719
6793
  calculateScaleInternal(width, height) {
6720
6794
  return width > height
6721
- ? this.fixedWidthLandscape / width
6722
- : this.fixedHeightPortrait / height;
6795
+ ? this._private_fixedWidthLandscapeInternal / width
6796
+ : this._private_fixedHeightPortraitInternal / height;
6723
6797
  }
6724
6798
  }
6725
6799
  /**
@@ -6732,15 +6806,35 @@ class UIResizePolicyCrossInverted extends UIResizePolicy {
6732
6806
  */
6733
6807
  constructor(fixedHeightLandscape, fixedWidthPortrait) {
6734
6808
  super();
6735
- this.fixedHeightLandscape = fixedHeightLandscape;
6736
- this.fixedWidthPortrait = fixedWidthPortrait;
6737
6809
  assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyCrossInverted.fixedHeightLandscape");
6738
6810
  assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyCrossInverted.fixedWidthPortrait");
6811
+ this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
6812
+ this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
6813
+ }
6814
+ get fixedHeightLandscape() {
6815
+ return this._private_fixedHeightLandscapeInternal;
6816
+ }
6817
+ get fixedWidthPortrait() {
6818
+ return this._private_fixedWidthPortraitInternal;
6819
+ }
6820
+ set fixedHeightLandscape(value) {
6821
+ assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedHeightLandscape");
6822
+ if (value !== this._private_fixedHeightLandscapeInternal) {
6823
+ this._private_fixedHeightLandscapeInternal = value;
6824
+ this.emit(UIResizePolicyEvent.CHANGE);
6825
+ }
6826
+ }
6827
+ set fixedWidthPortrait(value) {
6828
+ assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedWidthPortrait");
6829
+ if (value !== this._private_fixedWidthPortraitInternal) {
6830
+ this._private_fixedWidthPortraitInternal = value;
6831
+ this.emit(UIResizePolicyEvent.CHANGE);
6832
+ }
6739
6833
  }
6740
6834
  calculateScaleInternal(width, height) {
6741
6835
  return width > height
6742
- ? this.fixedHeightLandscape / height
6743
- : this.fixedWidthPortrait / width;
6836
+ ? this._private_fixedHeightLandscapeInternal / height
6837
+ : this._private_fixedWidthPortraitInternal / width;
6744
6838
  }
6745
6839
  }
6746
6840
 
@@ -6757,14 +6851,13 @@ class UIFullscreenLayer extends UILayer {
6757
6851
  /**
6758
6852
  * Creates a fullscreen layer and sets up window event listeners.
6759
6853
  */
6760
- constructor() {
6854
+ constructor(resizePolicy = new UIResizePolicyNone()) {
6761
6855
  super(window.innerWidth, window.innerHeight);
6762
- this.resizePolicy = new UIResizePolicyNone();
6763
6856
  /**
6764
6857
  * Handles window resize. Updates layer dimensions according to resize policy.
6765
6858
  */
6766
6859
  this._private_onResize = () => {
6767
- const scale = this.resizePolicy.calculateScaleInternal(window.innerWidth, window.innerHeight);
6860
+ const scale = this._private_resizePolicyInternal.calculateScaleInternal(window.innerWidth, window.innerHeight);
6768
6861
  this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);
6769
6862
  };
6770
6863
  /**
@@ -6781,19 +6874,39 @@ class UIFullscreenLayer extends UILayer {
6781
6874
  const y = rect
6782
6875
  ? rect.bottom - event.clientY
6783
6876
  : window.innerHeight - event.clientY;
6784
- const scale = this.resizePolicy.calculateScaleInternal(window.innerWidth, window.innerHeight);
6877
+ const scale = this._private_resizePolicyInternal.calculateScaleInternal(window.innerWidth, window.innerHeight);
6785
6878
  this.pointerClickInternal(x * scale, y * scale);
6786
6879
  };
6787
6880
  window.addEventListener("resize", this._private_onResize);
6788
6881
  window.addEventListener("pointerdown", this._private_onClick);
6882
+ this._private_resizePolicyInternal = resizePolicy;
6883
+ this._private_resizePolicyInternal.on(UIResizePolicyEvent.CHANGE, this._private_onResize);
6789
6884
  this._private_onResize();
6790
6885
  }
6886
+ /**
6887
+ * Gets the current resize policy.
6888
+ */
6889
+ get resizePolicy() {
6890
+ return this._private_resizePolicyInternal;
6891
+ }
6892
+ /**
6893
+ * Sets a new resize policy. Unsubscribes from old policy and subscribes to new one.
6894
+ */
6895
+ set resizePolicy(value) {
6896
+ if (this._private_resizePolicyInternal !== value) {
6897
+ this._private_resizePolicyInternal.off(UIResizePolicyEvent.CHANGE, this._private_onResize);
6898
+ this._private_resizePolicyInternal = value;
6899
+ this._private_resizePolicyInternal.on(UIResizePolicyEvent.CHANGE, this._private_onResize);
6900
+ this._private_onResize();
6901
+ }
6902
+ }
6791
6903
  /**
6792
6904
  * Removes window event listeners. The layer should not be used after this.
6793
6905
  */
6794
6906
  destroy() {
6795
6907
  window.removeEventListener("resize", this._private_onResize);
6796
6908
  window.removeEventListener("pointerdown", this._private_onClick);
6909
+ this._private_resizePolicyInternal.off(UIResizePolicyEvent.CHANGE, this._private_onResize);
6797
6910
  }
6798
6911
  /**
6799
6912
  * Renders the layer.
@@ -7222,5 +7335,5 @@ function isUITextSpan(obj) {
7222
7335
  (!("style" in obj) || isUITextStyle(obj.style)));
7223
7336
  }
7224
7337
 
7225
- export { UIAnchor, UIAnimatedImage, UIAnimatedImageEvent, UIAspectConstraint, UIColor, UIColorEvent, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGenericInstancedPlane, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UIInputEvent, UILayer, UILayerEvent, UIMicro, UIMicroAnchorMode, UIMicroEvent, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunction, UIRelation, UIResizePolicy, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePriority, resolveRelation, resolveTextPadding, resolveTextStyle };
7338
+ export { UIAnchor, UIAnimatedImage, UIAnimatedImageEvent, UIAspectConstraint, UIColor, UIColorEvent, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGenericInstancedPlane, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UIInputEvent, UILayer, UILayerEvent, UIMicro, UIMicroAnchorMode, UIMicroEvent, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunction, UIRelation, UIResizePolicy, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyEvent, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePriority, resolveRelation, resolveTextPadding, resolveTextStyle };
7226
7339
  //# sourceMappingURL=index.js.map