laymur 0.3.22 → 0.3.24

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.
@@ -39,14 +39,6 @@ export declare class UIGraphics extends UIElement {
39
39
  * @param options - Configuration options for the graphics element
40
40
  */
41
41
  constructor(layer: UILayer, options?: UIGraphicsOptions);
42
- /**
43
- * Gets the canvas width.
44
- */
45
- get canvasWidth(): number;
46
- /**
47
- * Gets the canvas height.
48
- */
49
- get canvasHeight(): number;
50
42
  /**
51
43
  * Gets the current color tint applied to the graphics.
52
44
  */
@@ -58,9 +50,9 @@ export declare class UIGraphics extends UIElement {
58
50
  /**
59
51
  * Clears the canvas with optional fill color.
60
52
  *
61
- * @param fillColor - Optional color to fill after clearing (CSS color string)
53
+ * @param fillColor - Optional color to fill after clearing
62
54
  */
63
- clear(fillColor?: string): this;
55
+ clear(fillColor?: UIColor): this;
64
56
  /**
65
57
  * Draws a rectangle on the canvas.
66
58
  */
@@ -104,11 +96,11 @@ export declare class UIGraphics extends UIElement {
104
96
  /**
105
97
  * Sets the fill style.
106
98
  */
107
- setFillStyle(style: string | CanvasGradient | CanvasPattern): this;
99
+ setFillStyle(style: UIColor | CanvasGradient | CanvasPattern): this;
108
100
  /**
109
101
  * Sets the stroke style.
110
102
  */
111
- setStrokeStyle(style: string | CanvasGradient | CanvasPattern): this;
103
+ setStrokeStyle(style: UIColor | CanvasGradient | CanvasPattern): this;
112
104
  /**
113
105
  * Sets the line width.
114
106
  */
package/dist/index.js CHANGED
@@ -2133,6 +2133,16 @@ class UIColor extends i {
2133
2133
  }
2134
2134
  return this;
2135
2135
  }
2136
+ /**
2137
+ * Converts the color to a CSS rgba() string.
2138
+ * @returns CSS rgba string (e.g., "rgba(255, 0, 0, 1)")
2139
+ */
2140
+ toCSSColor() {
2141
+ const r = Math.round(this.rInternal * 255);
2142
+ const g = Math.round(this.gInternal * 255);
2143
+ const b = Math.round(this.bInternal * 255);
2144
+ return `rgba(${r}, ${g}, ${b}, ${this.aInternal})`;
2145
+ }
2136
2146
  /**
2137
2147
  * Creates a new UIColor instance with identical color values.
2138
2148
  * @returns A new UIColor instance with the same RGBA values
@@ -5254,18 +5264,6 @@ class UIGraphics extends UIElement {
5254
5264
  this._private_colorInternal = color;
5255
5265
  this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
5256
5266
  }
5257
- /**
5258
- * Gets the canvas width.
5259
- */
5260
- get canvasWidth() {
5261
- return this._private_canvas.width;
5262
- }
5263
- /**
5264
- * Gets the canvas height.
5265
- */
5266
- get canvasHeight() {
5267
- return this._private_canvas.height;
5268
- }
5269
5267
  /**
5270
5268
  * Gets the current color tint applied to the graphics.
5271
5269
  */
@@ -5281,12 +5279,12 @@ class UIGraphics extends UIElement {
5281
5279
  /**
5282
5280
  * Clears the canvas with optional fill color.
5283
5281
  *
5284
- * @param fillColor - Optional color to fill after clearing (CSS color string)
5282
+ * @param fillColor - Optional color to fill after clearing
5285
5283
  */
5286
5284
  clear(fillColor) {
5287
5285
  this._private_ctx.clearRect(0, 0, this._private_canvas.width, this._private_canvas.height);
5288
5286
  if (fillColor !== undefined) {
5289
- this._private_ctx.fillStyle = fillColor;
5287
+ this._private_ctx.fillStyle = fillColor.toCSSColor();
5290
5288
  this._private_ctx.fillRect(0, 0, this._private_canvas.width, this._private_canvas.height);
5291
5289
  }
5292
5290
  this._private_canvasTexture.needsUpdate = true;
@@ -5377,14 +5375,15 @@ class UIGraphics extends UIElement {
5377
5375
  * Sets the fill style.
5378
5376
  */
5379
5377
  setFillStyle(style) {
5380
- this._private_ctx.fillStyle = style;
5378
+ this._private_ctx.fillStyle = style instanceof UIColor ? style.toCSSColor() : style;
5381
5379
  return this;
5382
5380
  }
5383
5381
  /**
5384
5382
  * Sets the stroke style.
5385
5383
  */
5386
5384
  setStrokeStyle(style) {
5387
- this._private_ctx.strokeStyle = style;
5385
+ this._private_ctx.strokeStyle =
5386
+ style instanceof UIColor ? style.toCSSColor() : style;
5388
5387
  return this;
5389
5388
  }
5390
5389
  /**
@@ -6851,7 +6850,7 @@ class UIFullscreenLayer extends UILayer {
6851
6850
  /**
6852
6851
  * Creates a fullscreen layer and sets up window event listeners.
6853
6852
  */
6854
- constructor(resizePolicy = new UIResizePolicyNone()) {
6853
+ constructor(resizePolicy = new UIResizePolicyNone(), mode = UIMode.VISIBLE) {
6855
6854
  super(window.innerWidth, window.innerHeight);
6856
6855
  /**
6857
6856
  * Handles window resize. Updates layer dimensions according to resize policy.
@@ -6879,6 +6878,7 @@ class UIFullscreenLayer extends UILayer {
6879
6878
  };
6880
6879
  window.addEventListener("resize", this._private_onResize);
6881
6880
  window.addEventListener("pointerdown", this._private_onClick);
6881
+ this.mode = mode;
6882
6882
  this._private_resizePolicyInternal = resizePolicy;
6883
6883
  this._private_resizePolicyInternal.on(UIResizePolicyEvent.CHANGE, this._private_onResize);
6884
6884
  this._private_onResize();