laymur 0.1.73 → 0.2.1

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.
Files changed (90) hide show
  1. package/README.md +367 -0
  2. package/dist/builders/UIConstraint2DBuilder.d.ts +130 -0
  3. package/dist/composer/UIComposer.d.ts +0 -0
  4. package/dist/composer/UIFullscreenQuad.d.ts +0 -0
  5. package/dist/composer/UIPass.d.ts +0 -0
  6. package/dist/constraints/UIAspectConstraint.d.ts +60 -0
  7. package/dist/constraints/UIConstraint.d.ts +29 -0
  8. package/dist/constraints/UICoverConstraint.d.ts +0 -0
  9. package/dist/constraints/UICustomConstraint.d.ts +60 -0
  10. package/dist/constraints/UIFitConstraint.d.ts +0 -0
  11. package/dist/constraints/UIHeightConstraint.d.ts +49 -0
  12. package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +94 -0
  13. package/dist/constraints/UIHorizontalProportionConstraint.d.ts +67 -0
  14. package/dist/constraints/UISingleParameterConstraint.d.ts +108 -0
  15. package/dist/constraints/UIVerticalDistanceConstraint.d.ts +94 -0
  16. package/dist/constraints/UIVerticalProportionConstraint.d.ts +67 -0
  17. package/dist/constraints/UIWidthConstraint.d.ts +49 -0
  18. package/dist/elements/UIAnchor.d.ts +78 -0
  19. package/dist/elements/UIDummy.d.ts +72 -0
  20. package/dist/elements/UIElement.d.ts +121 -0
  21. package/dist/elements/UIImage.d.ts +88 -0
  22. package/dist/elements/UINineSline.d.ts +0 -0
  23. package/dist/elements/UIProgress.d.ts +39 -0
  24. package/dist/elements/UIScene.d.ts +199 -0
  25. package/dist/elements/UIText.d.ts +157 -0
  26. package/dist/index.d.ts +29 -31
  27. package/dist/index.js +3320 -3251
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.min.js +1 -1
  30. package/dist/index.min.js.map +1 -1
  31. package/dist/layers/UIFullscreenLayer.d.ts +112 -0
  32. package/dist/layers/UILayer.d.ts +144 -0
  33. package/dist/materials/UIInstancedMaterial.d.ts +0 -0
  34. package/dist/materials/UIMaterial.d.ts +13 -0
  35. package/dist/materials/UINineSliceMaterial.d.ts +0 -0
  36. package/dist/{Materials → materials}/UIProgressMaterial.d.ts +0 -4
  37. package/dist/miscellaneous/UIExpression.d.ts +117 -0
  38. package/dist/miscellaneous/UIMicro.d.ts +130 -0
  39. package/dist/{Miscellaneous → miscellaneous}/UIOrientation.d.ts +2 -9
  40. package/dist/miscellaneous/UIPriority.d.ts +56 -0
  41. package/dist/miscellaneous/UIRelation.d.ts +43 -0
  42. package/dist/miscellaneous/UITextPadding.d.ts +7 -0
  43. package/dist/miscellaneous/UITextSpan.d.ts +6 -0
  44. package/dist/miscellaneous/UITextStyle.d.ts +18 -0
  45. package/dist/miscellaneous/asserts.d.ts +112 -0
  46. package/dist/miscellaneous/textInterfaces.d.ts +19 -0
  47. package/dist/miscellaneous/textTools.d.ts +12 -0
  48. package/dist/scalable/UIScalableMesh.d.ts +16 -0
  49. package/dist/scalable/UIScalablePlaneMesh.d.ts +14 -0
  50. package/dist/wrappers/UISceneWrapper.d.ts +18 -0
  51. package/dist/wrappers/UISolverWrapper.d.ts +29 -0
  52. package/package.json +3 -3
  53. package/dist/Builders/UIConstraint2DBuilder.d.ts +0 -42
  54. package/dist/Builders/UIConstraintContainerBuilder.d.ts +0 -20
  55. package/dist/Builders/UIConstraintStackBuilder.d.ts +0 -24
  56. package/dist/Constraints/UIAspectConstraint.d.ts +0 -56
  57. package/dist/Constraints/UIConstraint.d.ts +0 -32
  58. package/dist/Constraints/UIConstraintPower.d.ts +0 -57
  59. package/dist/Constraints/UIConstraintRule.d.ts +0 -46
  60. package/dist/Constraints/UICoverConstraint.d.ts +0 -72
  61. package/dist/Constraints/UIFitConstraint.d.ts +0 -72
  62. package/dist/Constraints/UIHeightConstraint.d.ts +0 -55
  63. package/dist/Constraints/UIHorizontalDistanceConstraint.d.ts +0 -63
  64. package/dist/Constraints/UIHorizontalProportionConstraint.d.ts +0 -58
  65. package/dist/Constraints/UIVerticalDistanceConstraint.d.ts +0 -63
  66. package/dist/Constraints/UIVerticalProportionConstraint.d.ts +0 -58
  67. package/dist/Constraints/UIWidthConstraint.d.ts +0 -55
  68. package/dist/Elements/UIAnchor.d.ts +0 -66
  69. package/dist/Elements/UIDummy.d.ts +0 -21
  70. package/dist/Elements/UIElement.d.ts +0 -134
  71. package/dist/Elements/UIImage.d.ts +0 -57
  72. package/dist/Elements/UIProgress.d.ts +0 -127
  73. package/dist/Elements/UIScene.d.ts +0 -141
  74. package/dist/Elements/UIText.d.ts +0 -76
  75. package/dist/Layers/UIFullScreenLayer.d.ts +0 -13
  76. package/dist/Layers/UILayer.d.ts +0 -68
  77. package/dist/Materials/UIMaterial.d.ts +0 -13
  78. package/dist/Miscellaneous/UIBlending.d.ts +0 -7
  79. package/dist/Miscellaneous/UIMicro.d.ts +0 -176
  80. package/dist/Miscellaneous/UITextInterfaces.d.ts +0 -49
  81. package/dist/Miscellaneous/asserts.d.ts +0 -5
  82. package/dist/Miscellaneous/math.d.ts +0 -1
  83. package/dist/Miscellaneous/microTransformationTools.d.ts +0 -3
  84. package/dist/Miscellaneous/symbols.d.ts +0 -1
  85. package/dist/Miscellaneous/textTools.d.ts +0 -9
  86. package/dist/Passes/UIComposer.d.ts +0 -114
  87. package/dist/Passes/UIFullScreenQuad.d.ts +0 -51
  88. package/dist/Passes/UIPass.d.ts +0 -43
  89. /package/dist/{Miscellaneous → miscellaneous}/UIMode.d.ts +0 -0
  90. /package/dist/{Miscellaneous → miscellaneous}/threeInstances.d.ts +0 -0
@@ -0,0 +1,49 @@
1
+ import type { UIElement } from "../elements/UIElement";
2
+ import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
3
+ import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
4
+ /**
5
+ * Configuration options for UIHeightConstraint creation.
6
+ */
7
+ export interface UIHeightConstraintOptions extends UISingleParameterConstraintOptions {
8
+ /** The desired height value for the element. */
9
+ height: number;
10
+ }
11
+ /**
12
+ * Constraint that enforces a specific height value for UI elements.
13
+ *
14
+ * UIHeightConstraint creates a mathematical relationship that fixes an element's
15
+ * height to a constant value. The constraint equation is: element.height = height.
16
+ * This is useful for ensuring elements maintain a specific height regardless of
17
+ * other layout changes or for setting fixed dimensions in responsive layouts.
18
+ *
19
+ * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
20
+ * @see {@link UIElement} - Elements that can have height constraints applied
21
+ * @see {@link UIExpression} - Mathematical expressions for constraint equations
22
+ */
23
+ export declare class UIHeightConstraint extends UISingleParameterConstraint {
24
+ private readonly element;
25
+ /** The constraint descriptor managed by the solver system. */
26
+ protected readonly constraint: number;
27
+ /** Internal storage for the current height value. */
28
+ private heightInternal;
29
+ /**
30
+ * Creates a new UIHeightConstraint instance.
31
+ *
32
+ * If no height is specified in options, the constraint will use the
33
+ * element's current height as the target height value.
34
+ *
35
+ * @param element - The UI element to apply the height constraint to
36
+ * @param options - Configuration options for the constraint
37
+ */
38
+ constructor(element: UIElement, options?: Partial<UIHeightConstraintOptions>);
39
+ /**
40
+ * Gets the current height value being enforced.
41
+ * @returns The height value in pixels
42
+ */
43
+ get height(): number;
44
+ /**
45
+ * Sets a new height value and updates the constraint equation.
46
+ * @param value - The new height value in pixels
47
+ */
48
+ set height(value: number);
49
+ }
@@ -0,0 +1,94 @@
1
+ import type { UIPlaneElement, UIPointElement } from "../miscellaneous/asserts";
2
+ import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
3
+ import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
4
+ /**
5
+ * Configuration options for UIHorizontalDistanceConstraint creation.
6
+ */
7
+ export interface UIHorizontalDistanceConstraintOptions extends UISingleParameterConstraintOptions {
8
+ /** Anchor point for element A (0.0 = left edge, 0.5 = center, 1.0 = right edge). */
9
+ anchorA: number;
10
+ /** Anchor point for element B (0.0 = left edge, 0.5 = center, 1.0 = right edge). */
11
+ anchorB: number;
12
+ /** The desired horizontal distance between the elements. */
13
+ distance: number;
14
+ }
15
+ /**
16
+ * Constraint that enforces horizontal distance between two UI elements.
17
+ *
18
+ * UIHorizontalDistanceConstraint creates a mathematical relationship that maintains
19
+ * a specific horizontal distance between two elements using configurable anchor points.
20
+ * For plane elements, anchors determine the reference point (0.0 = left, 0.5 = center, 1.0 = right).
21
+ * For point elements, the anchor is always the element's position. The constraint equation is:
22
+ * (elementB.x + elementB.width * anchorB) - (elementA.x + elementA.width * anchorA) = distance
23
+ *
24
+ * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
25
+ * @see {@link UIPointElement} - Point elements that can be constrained
26
+ * @see {@link UIPlaneElement} - Plane elements that can be constrained
27
+ * @see {@link UIExpression} - Mathematical expressions for constraint equations
28
+ */
29
+ export declare class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
30
+ private readonly a;
31
+ private readonly b;
32
+ /** The constraint descriptor managed by the solver system. */
33
+ protected readonly constraint: number;
34
+ /** Internal storage for element A's anchor point. */
35
+ private anchorAInternal;
36
+ /** Internal storage for element B's anchor point. */
37
+ private anchorBInternal;
38
+ /** Internal storage for the horizontal distance value. */
39
+ private distanceInternal;
40
+ /**
41
+ * Creates a new UIHorizontalDistanceConstraint instance.
42
+ *
43
+ * The constraint will use default anchor points (0.5 = center) and zero distance
44
+ * if not specified in options. Both elements must be from the same layer.
45
+ *
46
+ * @param a - The first UI element (point or plane element)
47
+ * @param b - The second UI element (point or plane element)
48
+ * @param options - Configuration options for the constraint
49
+ * @throws Will throw an error if elements are not from the same layer
50
+ * @see {@link assertValidConstraintSubjects}
51
+ */
52
+ constructor(a: UIPointElement | UIPlaneElement, b: UIPointElement | UIPlaneElement, options?: Partial<UIHorizontalDistanceConstraintOptions>);
53
+ /**
54
+ * Gets the current horizontal distance being enforced.
55
+ * @returns The horizontal distance in pixels
56
+ */
57
+ get distance(): number;
58
+ /**
59
+ * Gets the anchor point for element A.
60
+ * @returns The anchor value (0.0 = left, 0.5 = center, 1.0 = right)
61
+ */
62
+ get anchorA(): number;
63
+ /**
64
+ * Gets the anchor point for element B.
65
+ * @returns The anchor value (0.0 = left, 0.5 = center, 1.0 = right)
66
+ */
67
+ get anchorB(): number;
68
+ /**
69
+ * Sets a new horizontal distance and updates the constraint equation.
70
+ * @param value - The new horizontal distance in pixels
71
+ */
72
+ set distance(value: number);
73
+ /**
74
+ * Sets a new anchor point for element A and updates the constraint equation.
75
+ * @param value - The new anchor value (0.0 = left, 0.5 = center, 1.0 = right)
76
+ */
77
+ set anchorA(value: number);
78
+ /**
79
+ * Sets a new anchor point for element B and updates the constraint equation.
80
+ * @param value - The new anchor value (0.0 = left, 0.5 = center, 1.0 = right)
81
+ */
82
+ set anchorB(value: number);
83
+ /**
84
+ * Builds the left-hand side expression for the constraint equation.
85
+ *
86
+ * Creates the expression: (elementB.x + elementB.width * anchorB) - (elementA.x + elementA.width * anchorA)
87
+ * For point elements, only the x position is used since they have no width.
88
+ * For plane elements, the anchor determines the reference point within the element's width.
89
+ *
90
+ * @returns The UIExpression representing the horizontal distance calculation
91
+ * @private
92
+ */
93
+ private buildLHS;
94
+ }
@@ -0,0 +1,67 @@
1
+ import type { UIPlaneElement } from "../miscellaneous/asserts";
2
+ import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
3
+ import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
4
+ /**
5
+ * Configuration options for UIHorizontalProportionConstraint creation.
6
+ */
7
+ export interface UIHorizontalProportionConstraintOptions extends UISingleParameterConstraintOptions {
8
+ /** The proportional relationship between element widths (elementA.width = elementB.width * proportion). */
9
+ proportion: number;
10
+ }
11
+ /**
12
+ * Constraint that enforces proportional width relationships between two UI elements.
13
+ *
14
+ * UIHorizontalProportionConstraint creates a mathematical relationship that maintains
15
+ * a proportional ratio between the widths of two plane elements. The constraint equation is:
16
+ * elementA.width * proportion = elementB.width, which can be rearranged as:
17
+ * elementA.width * proportion - elementB.width = 0
18
+ *
19
+ * This is useful for creating responsive layouts where elements need to maintain
20
+ * specific width ratios, such as sidebar-to-content ratios or grid column proportions.
21
+ *
22
+ * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
23
+ * @see {@link UIPlaneElement} - Plane elements that can have proportional constraints applied
24
+ * @see {@link UIExpression} - Mathematical expressions for constraint equations
25
+ */
26
+ export declare class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
27
+ private readonly a;
28
+ private readonly b;
29
+ /** The constraint descriptor managed by the solver system. */
30
+ protected readonly constraint: number;
31
+ /** Internal storage for the current proportion value. */
32
+ private proportionInternal;
33
+ /**
34
+ * Creates a new UIHorizontalProportionConstraint instance.
35
+ *
36
+ * The constraint will enforce the relationship: elementA.width * proportion = elementB.width.
37
+ * If no proportion is specified, it defaults to 1.0 (equal widths).
38
+ * Both elements must be from the same layer.
39
+ *
40
+ * @param a - The first UI plane element (whose width will be multiplied by proportion)
41
+ * @param b - The second UI plane element (target width for the proportion)
42
+ * @param options - Configuration options for the constraint
43
+ * @throws Will throw an error if elements are not from the same layer
44
+ * @see {@link assertValidConstraintSubjects}
45
+ */
46
+ constructor(a: UIPlaneElement, b: UIPlaneElement, options?: Partial<UIHorizontalProportionConstraintOptions>);
47
+ /**
48
+ * Gets the current proportion value being enforced.
49
+ * @returns The proportion ratio (elementA.width = elementB.width * proportion)
50
+ */
51
+ get proportion(): number;
52
+ /**
53
+ * Sets a new proportion value and updates the constraint equation.
54
+ * @param value - The new proportion ratio
55
+ */
56
+ set proportion(value: number);
57
+ /**
58
+ * Builds the left-hand side expression for the constraint equation.
59
+ *
60
+ * Creates the expression: (elementA.width * proportion) - elementB.width = 0
61
+ * This enforces the relationship: elementA.width * proportion = elementB.width
62
+ *
63
+ * @returns The UIExpression representing the proportional width relationship
64
+ * @private
65
+ */
66
+ private buildLHS;
67
+ }
@@ -0,0 +1,108 @@
1
+ import type { UILayer } from "../layers/UILayer";
2
+ import { UIOrientation } from "../miscellaneous/UIOrientation";
3
+ import { type UIPriority } from "../miscellaneous/UIPriority";
4
+ import { type UIRelation } from "../miscellaneous/UIRelation";
5
+ import { UIConstraint } from "./UIConstraint";
6
+ /**
7
+ * Configuration options for UISingleParameterConstraint creation.
8
+ */
9
+ export interface UISingleParameterConstraintOptions {
10
+ /** Priority level for the constraint in the solver hierarchy. */
11
+ priority: UIPriority;
12
+ /** Mathematical relation type for the constraint equation. */
13
+ relation: UIRelation;
14
+ /** Orientation context for when the constraint should be active. */
15
+ orientation: UIOrientation;
16
+ }
17
+ /**
18
+ * Abstract base class for constraints that operate with configurable parameters.
19
+ *
20
+ * UISingleParameterConstraint extends UIConstraint with common functionality
21
+ * for constraints that need priority, relation, and orientation configuration.
22
+ * It provides automatic orientation-based enabling/disabling of constraints
23
+ * and manages the lifecycle of solver constraint descriptors.
24
+ *
25
+ * @see {@link UIConstraint} - Base constraint class
26
+ * @see {@link UIPriority} - Priority level configuration
27
+ * @see {@link UIRelation} - Mathematical relation types
28
+ * @see {@link UIOrientation} - Orientation-based activation
29
+ */
30
+ export declare abstract class UISingleParameterConstraint extends UIConstraint {
31
+ /** Internal storage for the constraint priority level. */
32
+ protected priorityInternal: UIPriority;
33
+ /** Internal storage for the constraint relation type. */
34
+ protected relationInternal: UIRelation;
35
+ /** Internal storage for the constraint orientation setting. */
36
+ protected orientationInternal: UIOrientation;
37
+ /** The constraint descriptor managed by the solver system. */
38
+ protected abstract readonly constraint: number;
39
+ /**
40
+ * Creates a new UISingleParameterConstraint instance.
41
+ *
42
+ * Initializes the constraint with resolved default values and sets up
43
+ * orientation change event handling for dynamic constraint activation.
44
+ *
45
+ * @param layer - The UI layer that contains this constraint
46
+ * @param priority - Optional priority level (defaults to P0)
47
+ * @param relation - Optional relation type (defaults to EQUAL)
48
+ * @param orientation - Optional orientation setting (defaults to ALWAYS)
49
+ */
50
+ constructor(layer: UILayer, priority?: UIPriority, relation?: UIRelation, orientation?: UIOrientation);
51
+ /**
52
+ * Gets the current priority level of the constraint.
53
+ * @returns The constraint priority level
54
+ */
55
+ get priority(): UIPriority;
56
+ /**
57
+ * Gets the current mathematical relation type of the constraint.
58
+ * @returns The constraint relation type
59
+ */
60
+ get relation(): UIRelation;
61
+ /**
62
+ * Gets the current orientation setting of the constraint.
63
+ * @returns The constraint orientation setting
64
+ */
65
+ get orientation(): UIOrientation;
66
+ /**
67
+ * Sets a new priority level for the constraint.
68
+ * @param value - The new priority level
69
+ */
70
+ set priority(value: UIPriority);
71
+ /**
72
+ * Sets a new mathematical relation type for the constraint.
73
+ * @param value - The new relation type
74
+ */
75
+ set relation(value: UIRelation);
76
+ /**
77
+ * Sets a new orientation setting for the constraint.
78
+ * @param value - The new orientation setting
79
+ */
80
+ set orientation(value: UIOrientation);
81
+ /**
82
+ * Destroys the constraint by cleaning up event listeners and solver resources.
83
+ *
84
+ * This method removes the orientation change event listener and removes
85
+ * the constraint from the solver system. After calling this method,
86
+ * the constraint should not be used anymore.
87
+ */
88
+ destroy(): void;
89
+ /**
90
+ * Determines if the constraint should be enabled based on orientation.
91
+ *
92
+ * The constraint is enabled if its orientation is set to ALWAYS or if
93
+ * it matches the current layer orientation.
94
+ *
95
+ * @returns True if the constraint should be enabled, false otherwise
96
+ * @protected
97
+ */
98
+ protected isConstraintEnabled(): boolean;
99
+ /**
100
+ * Event handler for layer orientation changes.
101
+ *
102
+ * Updates the constraint's enabled state in the solver based on the
103
+ * current orientation and the constraint's orientation setting.
104
+ *
105
+ * @private
106
+ */
107
+ private readonly onOrientationChange;
108
+ }
@@ -0,0 +1,94 @@
1
+ import type { UIPlaneElement, UIPointElement } from "../miscellaneous/asserts";
2
+ import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
3
+ import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
4
+ /**
5
+ * Configuration options for UIVerticalDistanceConstraint creation.
6
+ */
7
+ export interface UIVerticalDistanceConstraintOptions extends UISingleParameterConstraintOptions {
8
+ /** Anchor point for element A (0.0 = top edge, 0.5 = center, 1.0 = bottom edge). */
9
+ anchorA: number;
10
+ /** Anchor point for element B (0.0 = top edge, 0.5 = center, 1.0 = bottom edge). */
11
+ anchorB: number;
12
+ /** The desired vertical distance between the elements. */
13
+ distance: number;
14
+ }
15
+ /**
16
+ * Constraint that enforces vertical distance between two UI elements.
17
+ *
18
+ * UIVerticalDistanceConstraint creates a mathematical relationship that maintains
19
+ * a specific vertical distance between two elements using configurable anchor points.
20
+ * For plane elements, anchors determine the reference point (0.0 = top, 0.5 = center, 1.0 = bottom).
21
+ * For point elements, the anchor is always the element's position. The constraint equation is:
22
+ * (elementB.y + elementB.height * anchorB) - (elementA.y + elementA.height * anchorA) = distance
23
+ *
24
+ * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
25
+ * @see {@link UIPointElement} - Point elements that can be constrained
26
+ * @see {@link UIPlaneElement} - Plane elements that can be constrained
27
+ * @see {@link UIExpression} - Mathematical expressions for constraint equations
28
+ */
29
+ export declare class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
30
+ private readonly a;
31
+ private readonly b;
32
+ /** The constraint descriptor managed by the solver system. */
33
+ protected readonly constraint: number;
34
+ /** Internal storage for element A's anchor point. */
35
+ private anchorAInternal;
36
+ /** Internal storage for element B's anchor point. */
37
+ private anchorBInternal;
38
+ /** Internal storage for the vertical distance value. */
39
+ private distanceInternal;
40
+ /**
41
+ * Creates a new UIVerticalDistanceConstraint instance.
42
+ *
43
+ * The constraint will use default anchor points (0.5 = center) and zero distance
44
+ * if not specified in options. Both elements must be from the same layer.
45
+ *
46
+ * @param a - The first UI element (point or plane element)
47
+ * @param b - The second UI element (point or plane element)
48
+ * @param options - Configuration options for the constraint
49
+ * @throws Will throw an error if elements are not from the same layer
50
+ * @see {@link assertValidConstraintSubjects}
51
+ */
52
+ constructor(a: UIPointElement | UIPlaneElement, b: UIPointElement | UIPlaneElement, options?: Partial<UIVerticalDistanceConstraintOptions>);
53
+ /**
54
+ * Gets the current vertical distance being enforced.
55
+ * @returns The vertical distance in pixels
56
+ */
57
+ get distance(): number;
58
+ /**
59
+ * Gets the anchor point for element A.
60
+ * @returns The anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)
61
+ */
62
+ get anchorA(): number;
63
+ /**
64
+ * Gets the anchor point for element B.
65
+ * @returns The anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)
66
+ */
67
+ get anchorB(): number;
68
+ /**
69
+ * Sets a new vertical distance and updates the constraint equation.
70
+ * @param value - The new vertical distance in pixels
71
+ */
72
+ set distance(value: number);
73
+ /**
74
+ * Sets a new anchor point for element A and updates the constraint equation.
75
+ * @param value - The new anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)
76
+ */
77
+ set anchorA(value: number);
78
+ /**
79
+ * Sets a new anchor point for element B and updates the constraint equation.
80
+ * @param value - The new anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)
81
+ */
82
+ set anchorB(value: number);
83
+ /**
84
+ * Builds the left-hand side expression for the constraint equation.
85
+ *
86
+ * Creates the expression: (elementB.y + elementB.height * anchorB) - (elementA.y + elementA.height * anchorA)
87
+ * For point elements, only the y position is used since they have no height.
88
+ * For plane elements, the anchor determines the reference point within the element's height.
89
+ *
90
+ * @returns The UIExpression representing the vertical distance calculation
91
+ * @private
92
+ */
93
+ private buildLHS;
94
+ }
@@ -0,0 +1,67 @@
1
+ import type { UIPlaneElement } from "../miscellaneous/asserts";
2
+ import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
3
+ import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
4
+ /**
5
+ * Configuration options for UIVerticalProportionConstraint creation.
6
+ */
7
+ export interface UIVerticalProportionConstraintOptions extends UISingleParameterConstraintOptions {
8
+ /** The proportional relationship between element heights (elementA.height = elementB.height * proportion). */
9
+ proportion: number;
10
+ }
11
+ /**
12
+ * Constraint that enforces proportional height relationships between two UI elements.
13
+ *
14
+ * UIVerticalProportionConstraint creates a mathematical relationship that maintains
15
+ * a proportional ratio between the heights of two plane elements. The constraint equation is:
16
+ * elementA.height * proportion = elementB.height, which can be rearranged as:
17
+ * elementA.height * proportion - elementB.height = 0
18
+ *
19
+ * This is useful for creating responsive layouts where elements need to maintain
20
+ * specific height ratios, such as header-to-content ratios or row height proportions.
21
+ *
22
+ * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
23
+ * @see {@link UIPlaneElement} - Plane elements that can have proportional constraints applied
24
+ * @see {@link UIExpression} - Mathematical expressions for constraint equations
25
+ */
26
+ export declare class UIVerticalProportionConstraint extends UISingleParameterConstraint {
27
+ private readonly a;
28
+ private readonly b;
29
+ /** The constraint descriptor managed by the solver system. */
30
+ protected readonly constraint: number;
31
+ /** Internal storage for the current proportion value. */
32
+ private proportionInternal;
33
+ /**
34
+ * Creates a new UIVerticalProportionConstraint instance.
35
+ *
36
+ * The constraint will enforce the relationship: elementA.height * proportion = elementB.height.
37
+ * If no proportion is specified, it defaults to 1.0 (equal heights).
38
+ * Both elements must be from the same layer.
39
+ *
40
+ * @param a - The first UI plane element (whose height will be multiplied by proportion)
41
+ * @param b - The second UI plane element (target height for the proportion)
42
+ * @param options - Configuration options for the constraint
43
+ * @throws Will throw an error if elements are not from the same layer
44
+ * @see {@link assertValidConstraintSubjects}
45
+ */
46
+ constructor(a: UIPlaneElement, b: UIPlaneElement, options?: Partial<UIVerticalProportionConstraintOptions>);
47
+ /**
48
+ * Gets the current proportion value being enforced.
49
+ * @returns The proportion ratio (elementA.height = elementB.height * proportion)
50
+ */
51
+ get proportion(): number;
52
+ /**
53
+ * Sets a new proportion value and updates the constraint equation.
54
+ * @param value - The new proportion ratio
55
+ */
56
+ set proportion(value: number);
57
+ /**
58
+ * Builds the left-hand side expression for the constraint equation.
59
+ *
60
+ * Creates the expression: (elementA.height * proportion) - elementB.height = 0
61
+ * This enforces the relationship: elementA.height * proportion = elementB.height
62
+ *
63
+ * @returns The UIExpression representing the proportional height relationship
64
+ * @private
65
+ */
66
+ private buildLHS;
67
+ }
@@ -0,0 +1,49 @@
1
+ import type { UIElement } from "../elements/UIElement";
2
+ import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
3
+ import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
4
+ /**
5
+ * Configuration options for UIWidthConstraint creation.
6
+ */
7
+ export interface UIWidthConstraintOptions extends UISingleParameterConstraintOptions {
8
+ /** The desired width value for the element. */
9
+ width: number;
10
+ }
11
+ /**
12
+ * Constraint that enforces a specific width value for UI elements.
13
+ *
14
+ * UIWidthConstraint creates a mathematical relationship that fixes an element's
15
+ * width to a constant value. The constraint equation is: element.width = width.
16
+ * This is useful for ensuring elements maintain a specific width regardless of
17
+ * other layout changes or for setting fixed dimensions in responsive layouts.
18
+ *
19
+ * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
20
+ * @see {@link UIElement} - Elements that can have width constraints applied
21
+ * @see {@link UIExpression} - Mathematical expressions for constraint equations
22
+ */
23
+ export declare class UIWidthConstraint extends UISingleParameterConstraint {
24
+ private readonly element;
25
+ /** The constraint descriptor managed by the solver system. */
26
+ protected readonly constraint: number;
27
+ /** Internal storage for the current width value. */
28
+ private widthInternal;
29
+ /**
30
+ * Creates a new UIWidthConstraint instance.
31
+ *
32
+ * If no width is specified in options, the constraint will use the
33
+ * element's current width as the target width value.
34
+ *
35
+ * @param element - The UI element to apply the width constraint to
36
+ * @param options - Configuration options for the constraint
37
+ */
38
+ constructor(element: UIElement, options?: Partial<UIWidthConstraintOptions>);
39
+ /**
40
+ * Gets the current width value being enforced.
41
+ * @returns The width value in pixels
42
+ */
43
+ get width(): number;
44
+ /**
45
+ * Sets a new width value and updates the constraint equation.
46
+ * @param value - The new width value in pixels
47
+ */
48
+ set width(value: number);
49
+ }
@@ -0,0 +1,78 @@
1
+ import { Eventail } from "eventail";
2
+ import type { UILayer } from "../layers/UILayer";
3
+ import type { UIPointElement } from "../miscellaneous/asserts";
4
+ import type { UISolverWrapper } from "../wrappers/UISolverWrapper";
5
+ /**
6
+ * Abstract base class representing a minimal UI element as a point in 2D space.
7
+ *
8
+ * A UIAnchor serves as the fundamental building block for UI layout systems,
9
+ * representing a single point with x and y coordinates. It provides constraint-based
10
+ * positioning through solver variables and serves as an anchor point for more
11
+ * complex UI elements.
12
+ *
13
+ * @see {@link UIPointElement} - Interface defining point element behavior
14
+ * @see {@link UILayer} - Container layer for UI elements
15
+ * @see {@link UISolverWrapper} - Constraint solver integration
16
+ */
17
+ export declare abstract class UIAnchor extends Eventail implements UIPointElement {
18
+ readonly layer: UILayer;
19
+ /** Optional name identifier for the anchor. */
20
+ name: string;
21
+ /**
22
+ * Solver variable descriptor for the x-coordinate.
23
+ * This variable is managed by the constraint solver system.
24
+ */
25
+ readonly xVariable: number;
26
+ /**
27
+ * Solver variable descriptor for the y-coordinate.
28
+ * This variable is managed by the constraint solver system.
29
+ */
30
+ readonly yVariable: number;
31
+ /**
32
+ * Reference to the constraint solver wrapper for variable management.
33
+ * @see {@link UISolverWrapper}
34
+ */
35
+ protected readonly solverWrapper: UISolverWrapper;
36
+ /**
37
+ * Creates a new UIAnchor instance.
38
+ *
39
+ * @param layer - The UI layer that contains this anchor
40
+ * @param x - Initial x-coordinate position
41
+ * @param y - Initial y-coordinate position
42
+ * @throws Will throw an error if x or y are not valid numbers
43
+ * @see {@link assertValidNumber}
44
+ */
45
+ constructor(layer: UILayer, x: number, y: number);
46
+ /**
47
+ * Gets the current x-coordinate value from the solver.
48
+ * @returns The current x-coordinate position
49
+ */
50
+ get x(): number;
51
+ /**
52
+ * Gets the current y-coordinate value from the solver.
53
+ * @returns The current y-coordinate position
54
+ */
55
+ get y(): number;
56
+ /**
57
+ * Sets the x-coordinate value through the solver system.
58
+ * @param value - The new x-coordinate value
59
+ * @throws Will throw an error if value is not a valid number
60
+ * @see {@link assertValidNumber}
61
+ */
62
+ set x(value: number);
63
+ /**
64
+ * Sets the y-coordinate value through the solver system.
65
+ * @param value - The new y-coordinate value
66
+ * @throws Will throw an error if value is not a valid number
67
+ * @see {@link assertValidNumber}
68
+ */
69
+ set y(value: number);
70
+ /**
71
+ * Destroys the anchor by removing its solver variables.
72
+ *
73
+ * This method cleans up the solver variables associated with this anchor,
74
+ * effectively removing it from the constraint solving system. After calling
75
+ * this method, the anchor should not be used anymore.
76
+ */
77
+ destroy(): void;
78
+ }