laymur 0.2.0 → 0.2.2
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/README.md +353 -2
- package/dist/builders/UIConstraint2DBuilder.d.ts +102 -14
- package/dist/composer/UIComposer.d.ts +0 -0
- package/dist/composer/UIFullscreenQuad.d.ts +0 -0
- package/dist/composer/UIPass.d.ts +0 -0
- package/dist/constraints/UIAspectConstraint.d.ts +40 -36
- package/dist/constraints/UIConstraint.d.ts +17 -20
- package/dist/constraints/UICoverConstraint.d.ts +0 -72
- package/dist/constraints/UICustomConstraint.d.ts +60 -0
- package/dist/constraints/UIFitConstraint.d.ts +0 -72
- package/dist/constraints/UIHeightConstraint.d.ts +32 -38
- package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +77 -46
- package/dist/constraints/UIHorizontalProportionConstraint.d.ts +49 -40
- package/dist/constraints/UISingleParameterConstraint.d.ts +108 -0
- package/dist/constraints/UIVerticalDistanceConstraint.d.ts +77 -46
- package/dist/constraints/UIVerticalProportionConstraint.d.ts +49 -40
- package/dist/constraints/UIWidthConstraint.d.ts +32 -38
- package/dist/elements/UIAnchor.d.ts +58 -45
- package/dist/elements/UIDummy.d.ts +63 -12
- package/dist/elements/UIElement.d.ts +81 -93
- package/dist/elements/UIImage.d.ts +64 -33
- package/dist/elements/UINineSline.d.ts +0 -0
- package/dist/elements/UIProgress.d.ts +7 -95
- package/dist/elements/UIScene.d.ts +142 -84
- package/dist/elements/UIText.d.ts +124 -43
- package/dist/index.d.ts +10 -11
- package/dist/index.js +2887 -2716
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/layers/UIFullscreenLayer.d.ts +112 -0
- package/dist/layers/UILayer.d.ts +134 -57
- package/dist/materials/UIInstancedMaterial.d.ts +0 -0
- package/dist/materials/UIMaterial.d.ts +6 -6
- package/dist/materials/UINineSliceMaterial.d.ts +0 -0
- package/dist/materials/UIProgressMaterial.d.ts +0 -4
- package/dist/miscellaneous/UIExpression.d.ts +117 -0
- package/dist/miscellaneous/UIMicro.d.ts +73 -119
- package/dist/miscellaneous/UIOrientation.d.ts +2 -9
- package/dist/miscellaneous/UIPriority.d.ts +56 -0
- package/dist/miscellaneous/UIRelation.d.ts +43 -0
- package/dist/miscellaneous/UITextPadding.d.ts +7 -0
- package/dist/miscellaneous/UITextSpan.d.ts +6 -0
- package/dist/miscellaneous/UITextStyle.d.ts +18 -0
- package/dist/miscellaneous/asserts.d.ts +111 -4
- package/dist/miscellaneous/textInterfaces.d.ts +19 -0
- package/dist/miscellaneous/textTools.d.ts +8 -5
- package/dist/scalable/UIScalableMesh.d.ts +16 -0
- package/dist/scalable/UIScalablePlaneMesh.d.ts +14 -0
- package/dist/wrappers/UISceneWrapper.d.ts +18 -0
- package/dist/wrappers/UISolverWrapper.d.ts +29 -0
- package/package.json +1 -1
- package/dist/Passes/UIComposer.d.ts +0 -114
- package/dist/Passes/UIFullScreenQuad.d.ts +0 -51
- package/dist/Passes/UIPass.d.ts +0 -43
- package/dist/builders/UIConstraintContainerBuilder.d.ts +0 -20
- package/dist/builders/UIConstraintStackBuilder.d.ts +0 -24
- package/dist/constraints/UIConstraintPower.d.ts +0 -57
- package/dist/constraints/UIConstraintRule.d.ts +0 -46
- package/dist/layers/UIFullScreenLayer.d.ts +0 -13
- package/dist/miscellaneous/UIBlending.d.ts +0 -7
- package/dist/miscellaneous/UITextInterfaces.d.ts +0 -49
- package/dist/miscellaneous/math.d.ts +0 -1
- package/dist/miscellaneous/microTransformationTools.d.ts +0 -3
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { WebGLRenderer } from "three";
|
|
2
|
+
import { UILayer } from "./UILayer";
|
|
3
|
+
/**
|
|
4
|
+
* UI layer that manages fullscreen interfaces with optional fixed dimensions and automatic scaling.
|
|
5
|
+
*
|
|
6
|
+
* UIFullscreenLayer extends UILayer to provide automatic browser window integration,
|
|
7
|
+
* handling window resize events and pointer interactions. It supports optional fixed
|
|
8
|
+
* width or height constraints that enable responsive scaling while maintaining
|
|
9
|
+
* design proportions across different screen sizes.
|
|
10
|
+
*
|
|
11
|
+
* The layer automatically calculates scaling factors based on the orientation and
|
|
12
|
+
* fixed dimension constraints, ensuring consistent layout appearance regardless
|
|
13
|
+
* of the actual browser window size.
|
|
14
|
+
*
|
|
15
|
+
* @see {@link UILayer} - Base layer functionality
|
|
16
|
+
* @see {@link UIOrientation} - Orientation-based scaling behavior
|
|
17
|
+
*/
|
|
18
|
+
export declare class UIFullscreenLayer extends UILayer {
|
|
19
|
+
/** Internal storage for the optional fixed width constraint. */
|
|
20
|
+
private fixedWidthInternal?;
|
|
21
|
+
/** Internal storage for the optional fixed height constraint. */
|
|
22
|
+
private fixedHeightInternal?;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new UIFullscreenLayer instance with optional fixed dimensions.
|
|
25
|
+
*
|
|
26
|
+
* The layer will automatically resize to match the browser window and set up
|
|
27
|
+
* event listeners for window resize and pointer events. Fixed dimensions
|
|
28
|
+
* enable proportional scaling while maintaining design aspect ratios.
|
|
29
|
+
*
|
|
30
|
+
* @param fixedWidth - Optional fixed width for proportional scaling
|
|
31
|
+
* @param fixedHeight - Optional fixed height for proportional scaling
|
|
32
|
+
* @throws Will throw an error if fixed dimensions are not valid positive numbers
|
|
33
|
+
* @see {@link assertValidPositiveNumber}
|
|
34
|
+
*/
|
|
35
|
+
constructor(fixedWidth: number | undefined, fixedHeight: number | undefined);
|
|
36
|
+
/**
|
|
37
|
+
* Gets the current fixed width constraint.
|
|
38
|
+
* @returns The fixed width in pixels, or undefined if not set
|
|
39
|
+
*/
|
|
40
|
+
get fixedWidth(): number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Gets the current fixed height constraint.
|
|
43
|
+
* @returns The fixed height in pixels, or undefined if not set
|
|
44
|
+
*/
|
|
45
|
+
get fixedHeight(): number | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Sets a new fixed width constraint and triggers resize recalculation.
|
|
48
|
+
* @param value - The new fixed width in pixels, or undefined to remove constraint
|
|
49
|
+
* @throws Will throw an error if value is not a valid positive number
|
|
50
|
+
* @see {@link assertValidPositiveNumber}
|
|
51
|
+
*/
|
|
52
|
+
set fixedWidth(value: number | undefined);
|
|
53
|
+
/**
|
|
54
|
+
* Sets a new fixed height constraint and triggers resize recalculation.
|
|
55
|
+
* @param value - The new fixed height in pixels, or undefined to remove constraint
|
|
56
|
+
* @throws Will throw an error if value is not a valid positive number
|
|
57
|
+
* @see {@link assertValidPositiveNumber}
|
|
58
|
+
*/
|
|
59
|
+
set fixedHeight(value: number | undefined);
|
|
60
|
+
/**
|
|
61
|
+
* Destroys the fullscreen layer by removing all event listeners.
|
|
62
|
+
*
|
|
63
|
+
* This method cleans up window event listeners for resize and pointer events.
|
|
64
|
+
* After calling this method, the layer will no longer respond to window
|
|
65
|
+
* changes and should not be used anymore.
|
|
66
|
+
*/
|
|
67
|
+
destroy(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Renders the fullscreen layer and all its contained elements.
|
|
70
|
+
*
|
|
71
|
+
* Clears the depth and stencil buffers and delegates rendering to the
|
|
72
|
+
* parent layer's render method. This ensures proper rendering order
|
|
73
|
+
* and buffer management for fullscreen interfaces.
|
|
74
|
+
*
|
|
75
|
+
* @param renderer - The WebGL renderer instance
|
|
76
|
+
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
77
|
+
* @throws Will throw an error if deltaTime is not a valid number
|
|
78
|
+
* @see {@link assertValidNumber}
|
|
79
|
+
*/
|
|
80
|
+
render(renderer: WebGLRenderer, deltaTime: number): void;
|
|
81
|
+
/**
|
|
82
|
+
* Calculates the scaling factor based on orientation and fixed dimensions.
|
|
83
|
+
*
|
|
84
|
+
* The scaling factor is determined by the current orientation and which
|
|
85
|
+
* fixed dimension constraint is active. In horizontal orientation, fixed
|
|
86
|
+
* width takes precedence; in vertical orientation, fixed height takes precedence.
|
|
87
|
+
*
|
|
88
|
+
* @returns The scaling factor to apply to window dimensions
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
private calculateScale;
|
|
92
|
+
/**
|
|
93
|
+
* Event handler for window resize events.
|
|
94
|
+
*
|
|
95
|
+
* Recalculates the scaling factor and updates the layer dimensions
|
|
96
|
+
* based on the new window size and fixed dimension constraints.
|
|
97
|
+
*
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
private readonly onResize;
|
|
101
|
+
/**
|
|
102
|
+
* Event handler for pointer down events.
|
|
103
|
+
*
|
|
104
|
+
* Converts browser pointer coordinates to layer coordinates by accounting
|
|
105
|
+
* for element positioning and applying the appropriate scaling factor.
|
|
106
|
+
* The y-coordinate is flipped to match the UI coordinate system.
|
|
107
|
+
*
|
|
108
|
+
* @param event - The pointer event from the browser
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
private readonly onClick;
|
|
112
|
+
}
|
package/dist/layers/UILayer.d.ts
CHANGED
|
@@ -1,67 +1,144 @@
|
|
|
1
|
-
import { Constraint, Solver, Variable } from "@lume/kiwi";
|
|
2
1
|
import { Eventail } from "eventail";
|
|
3
|
-
import type {
|
|
4
|
-
import { OrthographicCamera, Scene } from "three";
|
|
5
|
-
import type { UIConstraint } from "../constraints/UIConstraint";
|
|
6
|
-
import { UIAnchor } from "../elements/UIAnchor";
|
|
7
|
-
import { UIElement } from "../elements/UIElement";
|
|
2
|
+
import type { WebGLRenderer } from "three";
|
|
8
3
|
import { UIMode } from "../miscellaneous/UIMode";
|
|
9
4
|
import { UIOrientation } from "../miscellaneous/UIOrientation";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
object?: Object3D;
|
|
16
|
-
variables: Map<Variable, VariableDescription>;
|
|
17
|
-
constraints: Set<UIConstraint>;
|
|
18
|
-
}
|
|
19
|
-
interface UIConstraintDescription {
|
|
20
|
-
elements: Set<UIElement | UIAnchor>;
|
|
21
|
-
variables: Map<Variable, VariableDescription>;
|
|
22
|
-
constraints: Set<Constraint>;
|
|
23
|
-
}
|
|
5
|
+
import { UISceneWrapper } from "../wrappers/UISceneWrapper";
|
|
6
|
+
import { UISolverWrapper } from "../wrappers/UISolverWrapper";
|
|
7
|
+
/**
|
|
8
|
+
* Events that can be emitted by UI layers.
|
|
9
|
+
*/
|
|
24
10
|
export declare enum UILayerEvent {
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
/** Emitted when the layer's orientation changes between horizontal and vertical. */
|
|
12
|
+
ORIENTATION_CHANGE = "orientation_change",
|
|
13
|
+
/** Emitted when the layer's visibility/interaction mode changes. */
|
|
14
|
+
MODE_CHANGE = "mode_change"
|
|
27
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Abstract base class for UI layout containers with constraint solving and rendering.
|
|
18
|
+
*
|
|
19
|
+
* UILayer serves as the fundamental container for UI elements, providing constraint-based
|
|
20
|
+
* layout solving, 3D scene management, and event handling. It manages the layer's
|
|
21
|
+
* dimensions through solver variables, handles orientation changes, and coordinates
|
|
22
|
+
* rendering and interaction for all contained elements.
|
|
23
|
+
*
|
|
24
|
+
* Each layer maintains its own constraint solver and scene graph, allowing for
|
|
25
|
+
* independent layout calculation and rendering optimization.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link UIElement} - Elements contained within layers
|
|
28
|
+
* @see {@link UISolverWrapper} - Constraint solving system
|
|
29
|
+
* @see {@link UISceneWrapper} - 3D scene management
|
|
30
|
+
* @see {@link UIOrientation} - Layer orientation states
|
|
31
|
+
*/
|
|
28
32
|
export declare abstract class UILayer extends Eventail {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
/** Optional name identifier for the layer. */
|
|
34
|
+
name: string;
|
|
35
|
+
/**
|
|
36
|
+
* Solver variable descriptor for the x-coordinate position.
|
|
37
|
+
* This variable is managed by the constraint solver system.
|
|
38
|
+
*/
|
|
39
|
+
readonly xVariable: number;
|
|
40
|
+
/**
|
|
41
|
+
* Solver variable descriptor for the y-coordinate position.
|
|
42
|
+
* This variable is managed by the constraint solver system.
|
|
43
|
+
*/
|
|
44
|
+
readonly yVariable: number;
|
|
45
|
+
/**
|
|
46
|
+
* Solver variable descriptor for the width dimension.
|
|
47
|
+
* This variable is managed by the constraint solver system.
|
|
48
|
+
*/
|
|
49
|
+
readonly wVariable: number;
|
|
50
|
+
/**
|
|
51
|
+
* Solver variable descriptor for the height dimension.
|
|
52
|
+
* This variable is managed by the constraint solver system.
|
|
53
|
+
*/
|
|
54
|
+
readonly hVariable: number;
|
|
55
|
+
/**
|
|
56
|
+
* Constraint solver wrapper for managing layout calculations.
|
|
57
|
+
* @see {@link UISolverWrapper}
|
|
58
|
+
*/
|
|
59
|
+
protected readonly solverWrapper: UISolverWrapper;
|
|
60
|
+
/**
|
|
61
|
+
* 3D scene wrapper for managing rendering and element hierarchy.
|
|
62
|
+
* @see {@link UISceneWrapper}
|
|
63
|
+
*/
|
|
64
|
+
protected readonly sceneWrapper: UISceneWrapper;
|
|
65
|
+
/** Internal storage for the current visibility/interaction mode. */
|
|
66
|
+
protected modeInternal: UIMode;
|
|
67
|
+
/** Internal storage for the current orientation state. */
|
|
68
|
+
protected orientationInternal: UIOrientation;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new UILayer instance with specified dimensions.
|
|
71
|
+
*
|
|
72
|
+
* Initializes the constraint solver with position and dimension variables,
|
|
73
|
+
* sets up the 3D scene wrapper, and determines the initial orientation
|
|
74
|
+
* based on the width-to-height ratio.
|
|
75
|
+
*
|
|
76
|
+
* @param w - Initial width of the layer
|
|
77
|
+
* @param h - Initial height of the layer
|
|
78
|
+
*/
|
|
79
|
+
constructor(w: number, h: number);
|
|
80
|
+
/**
|
|
81
|
+
* Gets the current width value from the constraint solver.
|
|
82
|
+
* @returns The current layer width in pixels
|
|
83
|
+
*/
|
|
46
84
|
get width(): number;
|
|
85
|
+
/**
|
|
86
|
+
* Gets the current height value from the constraint solver.
|
|
87
|
+
* @returns The current layer height in pixels
|
|
88
|
+
*/
|
|
47
89
|
get height(): number;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Gets the current visibility and interaction mode.
|
|
92
|
+
* @returns The current UIMode setting
|
|
93
|
+
* @see {@link UIMode}
|
|
94
|
+
*/
|
|
95
|
+
get mode(): UIMode;
|
|
96
|
+
/**
|
|
97
|
+
* Gets the current orientation state.
|
|
98
|
+
* @returns The current orientation (horizontal or vertical)
|
|
99
|
+
* @see {@link UIOrientation}
|
|
100
|
+
*/
|
|
101
|
+
get orientation(): UIOrientation;
|
|
102
|
+
/**
|
|
103
|
+
* Sets the visibility and interaction mode and emits change event.
|
|
104
|
+
* @param value - The new UIMode setting
|
|
105
|
+
* @see {@link UIMode}
|
|
106
|
+
*/
|
|
107
|
+
set mode(value: UIMode);
|
|
108
|
+
/**
|
|
109
|
+
* Internal method for resizing the layer and updating orientation.
|
|
110
|
+
*
|
|
111
|
+
* Updates the solver variables for width and height, resizes the scene wrapper,
|
|
112
|
+
* and determines if the orientation has changed based on the new dimensions.
|
|
113
|
+
* Emits an orientation change event if the orientation has changed.
|
|
114
|
+
*
|
|
115
|
+
* @param width - The new layer width
|
|
116
|
+
* @param height - The new layer height
|
|
117
|
+
* @protected
|
|
118
|
+
*/
|
|
61
119
|
protected resizeInternal(width: number, height: number): void;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Internal method for rendering the layer and its elements.
|
|
122
|
+
*
|
|
123
|
+
* Delegates rendering to the scene wrapper if the layer is not hidden.
|
|
124
|
+
* This method is called during the rendering loop to update and draw
|
|
125
|
+
* all elements contained within the layer.
|
|
126
|
+
*
|
|
127
|
+
* @param renderer - The WebGL renderer instance
|
|
128
|
+
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
129
|
+
* @protected
|
|
130
|
+
*/
|
|
131
|
+
protected renderInternal(renderer: WebGLRenderer, deltaTime: number): void;
|
|
132
|
+
/**
|
|
133
|
+
* Internal method for handling click events on the layer.
|
|
134
|
+
*
|
|
135
|
+
* Processes click events by testing elements in reverse z-order (top to bottom)
|
|
136
|
+
* until one handles the click. Only processes clicks when the layer is in
|
|
137
|
+
* interactive mode.
|
|
138
|
+
*
|
|
139
|
+
* @param x - The x-coordinate of the click
|
|
140
|
+
* @param y - The y-coordinate of the click
|
|
141
|
+
* @protected
|
|
142
|
+
*/
|
|
143
|
+
protected clickInternal(x: number, y: number): void;
|
|
66
144
|
}
|
|
67
|
-
export {};
|
|
File without changes
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Texture } from "three";
|
|
2
2
|
import { ShaderMaterial } from "three";
|
|
3
|
-
import { UIBlending } from "../miscellaneous/UIBlending";
|
|
4
3
|
export declare class UIMaterial extends ShaderMaterial {
|
|
5
4
|
constructor(map?: Texture);
|
|
6
|
-
getTexture(): Texture
|
|
5
|
+
getTexture(): Texture;
|
|
7
6
|
getColor(): number;
|
|
8
7
|
getOpacity(): number;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
getTransparency(): boolean;
|
|
9
|
+
setTexture(value: Texture): this;
|
|
10
|
+
setColor(value: number): this;
|
|
11
|
+
setOpacity(value: number): this;
|
|
12
|
+
setTransparency(value: boolean): this;
|
|
13
13
|
}
|
|
File without changes
|
|
@@ -7,10 +7,8 @@ export declare class UIProgressMaterial extends ShaderMaterial {
|
|
|
7
7
|
getForegroundTexture(): Texture;
|
|
8
8
|
getBackgroundColor(): number;
|
|
9
9
|
getForegroundColor(): number;
|
|
10
|
-
getColor(): number;
|
|
11
10
|
getBackgroundOpacity(): number;
|
|
12
11
|
getForegroundOpacity(): number;
|
|
13
|
-
getOpacity(): number;
|
|
14
12
|
getAngle(): number;
|
|
15
13
|
getIsForwardDirection(): boolean;
|
|
16
14
|
setProgress(value: number): void;
|
|
@@ -18,10 +16,8 @@ export declare class UIProgressMaterial extends ShaderMaterial {
|
|
|
18
16
|
setForegroundTexture(value: Texture): void;
|
|
19
17
|
setBackgroundColor(value: number): void;
|
|
20
18
|
setForegroundColor(value: number): void;
|
|
21
|
-
setColor(value: number): void;
|
|
22
19
|
setBackgroundOpacity(value: number): void;
|
|
23
20
|
setForegroundOpacity(value: number): void;
|
|
24
|
-
setOpacity(value: number): void;
|
|
25
21
|
setAngle(value: number): void;
|
|
26
22
|
setIsForwardDirection(value: boolean): void;
|
|
27
23
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mathematical expression builder for constraint equations in the UI layout system.
|
|
3
|
+
*
|
|
4
|
+
* UIExpression represents linear mathematical expressions of the form:
|
|
5
|
+
* constant + coefficient₁ × variable₁ + coefficient₂ × variable₂ + ... + coefficientₙ × variableₙ
|
|
6
|
+
*
|
|
7
|
+
* These expressions are used to build constraint equations for the Kiwi solver,
|
|
8
|
+
* enabling complex mathematical relationships between UI element properties.
|
|
9
|
+
* Variables are referenced by their numeric descriptors from the solver system.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link UIConstraint} - Constraints that use expressions
|
|
12
|
+
* @see {@link UISolverWrapper} - Solver integration that creates variables
|
|
13
|
+
*/
|
|
14
|
+
export declare class UIExpression {
|
|
15
|
+
/** The constant term of the expression. */
|
|
16
|
+
constant: number;
|
|
17
|
+
/** Map of variable descriptors to their coefficients in the expression. */
|
|
18
|
+
private readonly terms;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new UIExpression instance.
|
|
21
|
+
*
|
|
22
|
+
* @param constant - The constant term of the expression (defaults to 0)
|
|
23
|
+
* @param terms - Optional array of [variableDescriptor, coefficient] pairs
|
|
24
|
+
*/
|
|
25
|
+
constructor(constant?: number, terms?: [number, number][]);
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new expression that represents the sum of two expressions.
|
|
28
|
+
*
|
|
29
|
+
* Performs mathematical addition: (a.constant + a.terms) + (b.constant + b.terms)
|
|
30
|
+
* Coefficients for the same variables are combined.
|
|
31
|
+
*
|
|
32
|
+
* @param a - The first expression
|
|
33
|
+
* @param b - The second expression
|
|
34
|
+
* @returns A new expression representing a + b
|
|
35
|
+
*/
|
|
36
|
+
static plus(a: UIExpression, b: UIExpression): UIExpression;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new expression that represents the difference of two expressions.
|
|
39
|
+
*
|
|
40
|
+
* Performs mathematical subtraction: (a.constant + a.terms) - (b.constant + b.terms)
|
|
41
|
+
* Coefficients for the same variables are combined with subtraction.
|
|
42
|
+
*
|
|
43
|
+
* @param a - The first expression (minuend)
|
|
44
|
+
* @param b - The second expression (subtrahend)
|
|
45
|
+
* @returns A new expression representing a - b
|
|
46
|
+
*/
|
|
47
|
+
static minus(a: UIExpression, b: UIExpression): UIExpression;
|
|
48
|
+
/**
|
|
49
|
+
* Adds a variable term to this expression (mutating operation).
|
|
50
|
+
*
|
|
51
|
+
* If the variable already exists in the expression, its coefficient is
|
|
52
|
+
* increased by the specified amount. Otherwise, a new term is added.
|
|
53
|
+
*
|
|
54
|
+
* @param variableIndex - The variable descriptor from the solver
|
|
55
|
+
* @param coefficient - The coefficient to add for this variable
|
|
56
|
+
* @returns This expression instance for method chaining
|
|
57
|
+
*/
|
|
58
|
+
plus(variableIndex: number, coefficient: number): this;
|
|
59
|
+
/**
|
|
60
|
+
* Subtracts a variable term from this expression (mutating operation).
|
|
61
|
+
*
|
|
62
|
+
* If the variable already exists in the expression, its coefficient is
|
|
63
|
+
* decreased by the specified amount. Otherwise, a new term with negative
|
|
64
|
+
* coefficient is added.
|
|
65
|
+
*
|
|
66
|
+
* @param variableIndex - The variable descriptor from the solver
|
|
67
|
+
* @param coefficient - The coefficient to subtract for this variable
|
|
68
|
+
* @returns This expression instance for method chaining
|
|
69
|
+
*/
|
|
70
|
+
minus(variableIndex: number, coefficient: number): this;
|
|
71
|
+
/**
|
|
72
|
+
* Multiplies all terms in this expression by a scalar value (mutating operation).
|
|
73
|
+
*
|
|
74
|
+
* Both the constant term and all variable coefficients are multiplied
|
|
75
|
+
* by the specified value.
|
|
76
|
+
*
|
|
77
|
+
* @param value - The scalar value to multiply by
|
|
78
|
+
* @returns This expression instance for method chaining
|
|
79
|
+
*/
|
|
80
|
+
multiply(value: number): this;
|
|
81
|
+
/**
|
|
82
|
+
* Divides all terms in this expression by a scalar value (mutating operation).
|
|
83
|
+
*
|
|
84
|
+
* Both the constant term and all variable coefficients are divided
|
|
85
|
+
* by the specified value.
|
|
86
|
+
*
|
|
87
|
+
* @param value - The scalar value to divide by (must not be zero)
|
|
88
|
+
* @returns This expression instance for method chaining
|
|
89
|
+
*/
|
|
90
|
+
divide(value: number): this;
|
|
91
|
+
/**
|
|
92
|
+
* Checks if the expression contains a term for the specified variable.
|
|
93
|
+
*
|
|
94
|
+
* @param variableIndex - The variable descriptor to check for
|
|
95
|
+
* @returns True if the expression has a term for this variable, false otherwise
|
|
96
|
+
*/
|
|
97
|
+
hasTerm(variableIndex: number): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Copies the content of another expression into this expression (mutating operation).
|
|
100
|
+
*
|
|
101
|
+
* Replaces all terms and the constant of this expression with those
|
|
102
|
+
* from the source expression.
|
|
103
|
+
*
|
|
104
|
+
* @param expression - The source expression to copy from
|
|
105
|
+
* @returns This expression instance for method chaining
|
|
106
|
+
*/
|
|
107
|
+
copy(expression: UIExpression): this;
|
|
108
|
+
/**
|
|
109
|
+
* Creates a deep copy of this expression.
|
|
110
|
+
*
|
|
111
|
+
* The returned expression is completely independent and can be modified
|
|
112
|
+
* without affecting the original.
|
|
113
|
+
*
|
|
114
|
+
* @returns A new UIExpression instance with the same content
|
|
115
|
+
*/
|
|
116
|
+
clone(): UIExpression;
|
|
117
|
+
}
|