laymur 0.3.15 → 0.3.19

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.
@@ -0,0 +1,119 @@
1
+ import type { Matrix3, Texture } from "three";
2
+ import type { UILayer } from "../layers/UILayer";
3
+ import { UIColor } from "../miscellaneous/UIColor";
4
+ import { UIElement } from "./UIElement";
5
+ export declare enum UIAnimatedImageEvent {
6
+ PLAY = 0,
7
+ PAUSE = 1,
8
+ STOP = 2
9
+ }
10
+ export type UIAnimatedImageSequence = {
11
+ texture: Texture;
12
+ transforms: Matrix3[];
13
+ } | Texture[];
14
+ /**
15
+ * Configuration options for creating a UIAnimatedImage element.
16
+ */
17
+ export interface UIAnimatedImageOptions {
18
+ /** X position of the element */
19
+ x: number;
20
+ /** Y position of the element */
21
+ y: number;
22
+ /** Width of the element */
23
+ width: number;
24
+ /** Height of the element */
25
+ height: number;
26
+ /** Color tint applied to the image */
27
+ color: UIColor;
28
+ /** Frame rate for animation */
29
+ frameRate: number;
30
+ /** Whether animation should loop */
31
+ loop: boolean;
32
+ }
33
+ /**
34
+ * UI element for displaying textured images.
35
+ *
36
+ * UIAnimatedImage is a concrete implementation of UIElement that renders a textured
37
+ * image using shader-based planes. It automatically sizes itself
38
+ * to match the texture dimensions and provides control over visual properties
39
+ * such as color tinting.
40
+ *
41
+ * @see {@link UIElement} - Base class providing UI element functionality
42
+ * @see {@link Texture} - Three.js texture for image data
43
+ */
44
+ export declare class UIAnimatedImage extends UIElement {
45
+ /** Internal storage for the current texture */
46
+ private readonly sequenceInternal;
47
+ /** Internal storage for the color tint */
48
+ private readonly colorInternal;
49
+ private frameRateInternal;
50
+ private loopInternal;
51
+ private intervalHandler?;
52
+ private currentFrameIndex;
53
+ /**
54
+ * Creates a new UIAnimatedImage instance.
55
+ *
56
+ * The image will automatically size itself to match the texture's dimensions.
57
+ * All options have default values if not specified.
58
+ *
59
+ * @param layer - The UI layer that contains this image
60
+ * @param texture - The Three.js texture to display
61
+ * @param options - Configuration options for the image
62
+ * @throws Will throw an error if the texture dimensions are not valid positive numbers
63
+ */
64
+ constructor(layer: UILayer, sequence: UIAnimatedImageSequence, options?: Partial<UIAnimatedImageOptions>);
65
+ /**
66
+ * Gets the current color tint applied to the image.
67
+ * @returns The UIColor instance
68
+ */
69
+ get color(): UIColor;
70
+ /**
71
+ * Gets the frame rate for animation.
72
+ * @returns The frame rate in frames per second
73
+ */
74
+ get frameRate(): number;
75
+ /**
76
+ * Gets whether the animation loops.
77
+ * @returns True if animation loops
78
+ */
79
+ get loop(): boolean;
80
+ /**
81
+ * Gets the total duration of the animation in seconds.
82
+ * @returns The duration in seconds
83
+ */
84
+ get duration(): number;
85
+ /**
86
+ * Sets the color tint applied to the image.
87
+ * @param value - The UIColor instance
88
+ */
89
+ set color(value: UIColor);
90
+ /**
91
+ * Sets the frame rate for animation.
92
+ * @param value - The frame rate in frames per second
93
+ */
94
+ set frameRate(value: number);
95
+ /**
96
+ * Sets whether the animation loops.
97
+ * @param value - True to enable looping
98
+ */
99
+ set loop(value: boolean);
100
+ /**
101
+ * Starts or resumes playback of the animation.
102
+ */
103
+ play(): void;
104
+ /**
105
+ * Pauses the animation at the current frame.
106
+ */
107
+ pause(): void;
108
+ /**
109
+ * Stops the animation and resets to the first frame.
110
+ */
111
+ stop(): void;
112
+ /**
113
+ * Destroys the UI image by cleaning up color event listeners and all associated resources.
114
+ */
115
+ destroy(): void;
116
+ /** Event handler for when the color changes */
117
+ private readonly onColorChange;
118
+ private updateFrame;
119
+ }
@@ -0,0 +1,122 @@
1
+ import type { UILayer } from "../layers/UILayer";
2
+ import { UIColor } from "../miscellaneous/UIColor";
3
+ import { UIElement } from "./UIElement";
4
+ /**
5
+ * Configuration options for creating a UIGraphics element.
6
+ */
7
+ export interface UIGraphicsOptions {
8
+ /** X position of the element */
9
+ x?: number;
10
+ /** Y position of the element */
11
+ y?: number;
12
+ /** Width of the canvas (default: 512) */
13
+ width?: number;
14
+ /** Height of the canvas (default: 512) */
15
+ height?: number;
16
+ /** Color tint applied to the graphics */
17
+ color?: UIColor;
18
+ }
19
+ /**
20
+ * UI element for drawing graphics using 2D canvas API.
21
+ *
22
+ * UIGraphics uses an OffscreenCanvas for rendering 2D graphics and converts it
23
+ * to a Three.js texture for display. It provides access to the canvas context
24
+ * for custom drawing operations.
25
+ */
26
+ export declare class UIGraphics extends UIElement {
27
+ /** OffscreenCanvas for rendering graphics */
28
+ private readonly canvas;
29
+ /** 2D rendering context */
30
+ private readonly ctx;
31
+ /** Three.js texture created from the canvas */
32
+ private readonly canvasTexture;
33
+ /** Internal storage for the color tint */
34
+ private readonly colorInternal;
35
+ /**
36
+ * Creates a new UIGraphics instance.
37
+ *
38
+ * @param layer - The UI layer that contains this graphics element
39
+ * @param options - Configuration options for the graphics element
40
+ */
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
+ /**
51
+ * Gets the current color tint applied to the graphics.
52
+ */
53
+ get color(): UIColor;
54
+ /**
55
+ * Sets the color tint applied to the graphics.
56
+ */
57
+ set color(value: UIColor);
58
+ /**
59
+ * Clears the canvas with optional fill color.
60
+ *
61
+ * @param fillColor - Optional color to fill after clearing (CSS color string)
62
+ */
63
+ clear(fillColor?: string): void;
64
+ /**
65
+ * Draws a rectangle on the canvas.
66
+ */
67
+ rect(x: number, y: number, width: number, height: number): void;
68
+ /**
69
+ * Draws a filled rectangle on the canvas.
70
+ */
71
+ fillRect(x: number, y: number, width: number, height: number): void;
72
+ /**
73
+ * Draws a stroked rectangle on the canvas.
74
+ */
75
+ strokeRect(x: number, y: number, width: number, height: number): void;
76
+ /**
77
+ * Draws a circle on the canvas.
78
+ */
79
+ circle(x: number, y: number, radius: number): void;
80
+ /**
81
+ * Begins a new path.
82
+ */
83
+ beginPath(): void;
84
+ /**
85
+ * Closes the current path.
86
+ */
87
+ closePath(): void;
88
+ /**
89
+ * Fills the current path.
90
+ */
91
+ fill(): void;
92
+ /**
93
+ * Strokes the current path.
94
+ */
95
+ stroke(): void;
96
+ /**
97
+ * Moves the path to a point.
98
+ */
99
+ moveTo(x: number, y: number): void;
100
+ /**
101
+ * Draws a line to a point.
102
+ */
103
+ lineTo(x: number, y: number): void;
104
+ /**
105
+ * Sets the fill style.
106
+ */
107
+ setFillStyle(style: string | CanvasGradient | CanvasPattern): void;
108
+ /**
109
+ * Sets the stroke style.
110
+ */
111
+ setStrokeStyle(style: string | CanvasGradient | CanvasPattern): void;
112
+ /**
113
+ * Sets the line width.
114
+ */
115
+ setLineWidth(width: number): void;
116
+ /**
117
+ * Destroys the graphics element by cleaning up resources.
118
+ */
119
+ destroy(): void;
120
+ /** Event handler for when the color changes */
121
+ private readonly onColorChange;
122
+ }
@@ -10,6 +10,10 @@ export interface UIImageOptions {
10
10
  x: number;
11
11
  /** Y position of the element */
12
12
  y: number;
13
+ /** Width of the element */
14
+ width: number;
15
+ /** Height of the element */
16
+ height: number;
13
17
  /** Color tint applied to the image */
14
18
  color: UIColor;
15
19
  }
@@ -2,7 +2,7 @@ import type { WebGLRenderer } from "three";
2
2
  import { type UILayer } from "../layers/UILayer";
3
3
  import type { UITextContent } from "../miscellaneous/textInterfaces";
4
4
  import { UIColor } from "../miscellaneous/UIColor";
5
- import { type UITextPadding } from "../miscellaneous/UITextPadding";
5
+ import { type UIPadding } from "../miscellaneous/UITextPadding";
6
6
  import { type UITextStyle } from "../miscellaneous/UITextStyle";
7
7
  import { UIElement } from "./UIElement";
8
8
  /**
@@ -18,7 +18,7 @@ export interface UITextOptions {
18
18
  /** Maximum width in pixels before text wrapping occurs. */
19
19
  maxWidth: number;
20
20
  /** Padding configuration for text content. */
21
- padding: Partial<UITextPadding>;
21
+ padding: Partial<UIPadding>;
22
22
  /** Common style properties applied to all text content. */
23
23
  commonStyle: Partial<UITextStyle>;
24
24
  }
@@ -34,7 +34,7 @@ export interface UITextOptions {
34
34
  * @see {@link UIElement} - Base class providing UI element functionality
35
35
  * @see {@link UITextContent} - Text content structure
36
36
  * @see {@link UITextStyle} - Text styling options
37
- * @see {@link UITextPadding} - Padding configuration
37
+ * @see {@link UIPadding} - Padding configuration
38
38
  */
39
39
  export declare class UIText extends UIElement {
40
40
  /** The HTML canvas element used for text rendering. */
@@ -87,7 +87,7 @@ export declare class UIText extends UIElement {
87
87
  * Gets the current padding configuration.
88
88
  * @returns The padding configuration for all sides
89
89
  */
90
- get padding(): UITextPadding;
90
+ get padding(): UIPadding;
91
91
  /**
92
92
  * Gets the common style properties applied to the text.
93
93
  * @returns The partial text style configuration
@@ -112,7 +112,7 @@ export declare class UIText extends UIElement {
112
112
  * Sets new padding configuration and triggers a rebuild.
113
113
  * @param value - The new padding configuration
114
114
  */
115
- set padding(value: UITextPadding);
115
+ set padding(value: UIPadding);
116
116
  /**
117
117
  * Sets new common style properties and triggers a rebuild.
118
118
  * @param value - The new partial text style configuration
package/dist/index.d.ts CHANGED
@@ -12,8 +12,10 @@ export * from "./constraints/UIVerticalDistanceConstraint";
12
12
  export * from "./constraints/UIVerticalProportionConstraint";
13
13
  export * from "./constraints/UIWidthConstraint";
14
14
  export * from "./elements/UIAnchor";
15
+ export * from "./elements/UIAnimatedImage";
15
16
  export * from "./elements/UIDummy";
16
17
  export * from "./elements/UIElement";
18
+ export * from "./elements/UIGraphics";
17
19
  export * from "./elements/UIImage";
18
20
  export * from "./elements/UINineSline";
19
21
  export * from "./elements/UIProgress";
@@ -21,6 +23,7 @@ export * from "./elements/UIScene";
21
23
  export * from "./elements/UIText";
22
24
  export * from "./layers/UIFullscreenLayer";
23
25
  export * from "./layers/UILayer";
26
+ export * from "./miscellaneous/resizePolicies";
24
27
  export * from "./miscellaneous/UIColor";
25
28
  export * from "./miscellaneous/UIExpression";
26
29
  export * from "./miscellaneous/UIGenericInstancedPlane";