laymur 0.18.1 → 0.19.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.
- package/README.md +44 -17
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +1 -1
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +6 -6
- package/dist/core/constraints/UIConstraint.d.ts +1 -0
- package/dist/core/constraints/UIConstraint.js +4 -0
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +1 -1
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +5 -5
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +2 -2
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +14 -14
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +3 -3
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +20 -20
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +2 -2
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +5 -5
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +1 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +2 -2
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +14 -14
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +3 -3
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +20 -20
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +2 -2
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +5 -5
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +1 -1
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +5 -5
- package/dist/core/layers/UILayer/UILayer.d.ts +18 -0
- package/dist/core/layers/UILayer/UILayer.js +48 -0
- package/dist/core/miscellaneous/color/UIColor.js +4 -4
- package/dist/core/miscellaneous/shared.d.ts +8 -0
- package/dist/debug/UIAspectDebug.d.ts +26 -0
- package/dist/debug/UIAspectDebug.js +118 -0
- package/dist/debug/UIConstraintDebug.d.ts +7 -0
- package/dist/debug/UIHeightDebug.d.ts +26 -0
- package/dist/debug/UIHeightDebug.js +111 -0
- package/dist/debug/UIHorizontalDistanceDebug.d.ts +29 -0
- package/dist/debug/UIHorizontalDistanceDebug.js +158 -0
- package/dist/debug/UIHorizontalInterpolationDebug.d.ts +29 -0
- package/dist/debug/UIHorizontalInterpolationDebug.js +145 -0
- package/dist/debug/UILayerDebug.d.ts +34 -0
- package/dist/debug/UILayerDebug.js +124 -0
- package/dist/debug/UIVerticalDistanceDebug.d.ts +29 -0
- package/dist/debug/UIVerticalDistanceDebug.js +158 -0
- package/dist/debug/UIVerticalInterpolationDebug.d.ts +29 -0
- package/dist/debug/UIVerticalInterpolationDebug.js +145 -0
- package/dist/debug/UIWidthDebug.d.ts +26 -0
- package/dist/debug/UIWidthDebug.js +111 -0
- package/dist/debug/index.d.ts +8 -0
- package/dist/debug/index.js +8 -0
- package/dist/debug/miscellaneous.d.ts +8 -0
- package/dist/debug/miscellaneous.js +11 -0
- package/dist/node_modules/three/examples/jsm/lines/Line2.js +56 -0
- package/dist/node_modules/three/examples/jsm/lines/LineGeometry.js +157 -0
- package/dist/node_modules/three/examples/jsm/lines/LineMaterial.js +691 -0
- package/dist/node_modules/three/examples/jsm/lines/LineSegments2.js +415 -0
- package/dist/node_modules/three/examples/jsm/lines/LineSegmentsGeometry.js +289 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +1 -1
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +1 -1
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +1 -1
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +1 -1
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +1 -1
- package/dist/particles/elements/UIEmitter.d.ts +1 -1
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +1 -2
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +1 -1
- package/dist/particles/miscellaneous/miscellaneous.d.ts +2 -1
- package/dist/particles/spawnModules/UISpawnOffset.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnRectangle.d.ts +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -15,11 +15,12 @@
|
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
|
-
* **Cassowary solver**
|
|
19
|
-
* **Orientation-aware**
|
|
20
|
-
* **Micro-transforms**
|
|
21
|
-
* **Resize policies**
|
|
22
|
-
* **Modular particles**
|
|
18
|
+
* **Cassowary solver** - constraint-based layouts via `@lume/kiwi`
|
|
19
|
+
* **Orientation-aware** - define portrait and landscape rules in one layout, solver toggles automatically
|
|
20
|
+
* **Micro-transforms** - visual-only transforms (scale, rotation, offset) that bypass the solver
|
|
21
|
+
* **Resize policies** - Cover, Fit, FixedHeight, FixedWidth, Cross strategies
|
|
22
|
+
* **Modular particles** - separate `laymur/particles` entry point, import only if needed
|
|
23
|
+
* **Debug overlay** - separate `laymur/debug` entry point, constraint visualization
|
|
23
24
|
|
|
24
25
|
## Installation
|
|
25
26
|
|
|
@@ -33,10 +34,14 @@ Peer Dependencies:
|
|
|
33
34
|
* `@lume/kiwi` (^0.4.4)
|
|
34
35
|
* `ferrsign` (^0.0.4)
|
|
35
36
|
|
|
36
|
-
## Live Examples
|
|
37
|
+
## Visual Editor & Live Examples
|
|
38
|
+
|
|
39
|
+
Check out visual editor and interactive examples at:
|
|
40
|
+
|
|
41
|
+
**[EDITOR](https://jango-git.github.io/laymur-docs/editor/index.html)**
|
|
42
|
+
|
|
43
|
+
**[EXAMPLES](https://jango-git.github.io/laymur/examples/index.html)**
|
|
37
44
|
|
|
38
|
-
Check out interactive examples and demos at:
|
|
39
|
-
**[https://jango-git.github.io/laymur/](https://jango-git.github.io/laymur/)**
|
|
40
45
|
|
|
41
46
|
## Core Concepts
|
|
42
47
|
|
|
@@ -93,7 +98,7 @@ new UIHorizontalProportionConstraint(layer, element, {
|
|
|
93
98
|
|
|
94
99
|
### 3. Micro-transforms
|
|
95
100
|
|
|
96
|
-
For animations, use `.micro`
|
|
101
|
+
For animations, use `.micro` - updates visual matrix without triggering the solver.
|
|
97
102
|
|
|
98
103
|
```typescript
|
|
99
104
|
element.micro.scaleX = Math.sin(Date.now() * 0.001) + 1;
|
|
@@ -118,6 +123,34 @@ const emitter = new UIEmitter(
|
|
|
118
123
|
emitter.play(60); // particles/sec
|
|
119
124
|
```
|
|
120
125
|
|
|
126
|
+
### 5. Debug Overlay
|
|
127
|
+
|
|
128
|
+
`laymur/debug` renders visual overlays for constraints - useful during development to inspect layout relationships.
|
|
129
|
+
|
|
130
|
+
`UILayerDebug` automatically tracks all constraints on a layer and creates the corresponding overlays. Individual constraint types can be toggled on/off.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { UILayerDebug } from 'laymur/debug';
|
|
134
|
+
|
|
135
|
+
const debug = new UILayerDebug(layer, {
|
|
136
|
+
showAspect: true,
|
|
137
|
+
showWidth: true,
|
|
138
|
+
showHeight: true,
|
|
139
|
+
showHorizontalDistance: true,
|
|
140
|
+
showVerticalDistance: true,
|
|
141
|
+
showHorizontalInterpolation: false,
|
|
142
|
+
showVerticalInterpolation: false,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Toggle a category at runtime
|
|
146
|
+
debug.showAspect = false;
|
|
147
|
+
|
|
148
|
+
// Clean up
|
|
149
|
+
debug.destroy();
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Overlays respect orientation - they hide automatically when their constraint's orientation is inactive.
|
|
153
|
+
|
|
121
154
|
## API Overview
|
|
122
155
|
|
|
123
156
|
Most commonly used exports (not exhaustive):
|
|
@@ -134,15 +167,9 @@ UIAspectConstraint, UIHorizontalDistanceConstraint, UIVerticalDistanceConstraint
|
|
|
134
167
|
|
|
135
168
|
UIEmitter, UISpawnRectangle, UISpawnRandomLifetime, UIBehaviorDirectionalGravity, UIBehaviorVelocityDamping, UIRenderingTexture, UIRenderingColorOverLife
|
|
136
169
|
|
|
137
|
-
|
|
170
|
+
### Debug (laymur/debug)
|
|
138
171
|
|
|
139
|
-
|
|
140
|
-
// package.json
|
|
141
|
-
"exports": {
|
|
142
|
-
".": "./dist/index.js",
|
|
143
|
-
"./particles": "./dist/particles/index.js"
|
|
144
|
-
}
|
|
145
|
-
```
|
|
172
|
+
UILayerDebug, UIAspectDebug, UIHeightDebug, UIWidthDebug, UIHorizontalDistanceDebug, UIVerticalDistanceDebug, UIHorizontalInterpolationDebug, UIVerticalInterpolationDebug
|
|
146
173
|
|
|
147
174
|
## License
|
|
148
175
|
|
|
@@ -3,7 +3,7 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
|
|
|
3
3
|
import type { UIAspectConstraintOptions } from "./UIAspectConstraint.Internal";
|
|
4
4
|
/** Maintains element aspect ratio (width = height * aspect) */
|
|
5
5
|
export declare class UIAspectConstraint extends UISingleParameterConstraint {
|
|
6
|
-
|
|
6
|
+
readonly element: UIPlaneElement & UILayerElement;
|
|
7
7
|
/** Solver constraint descriptor */
|
|
8
8
|
protected readonly constraint: number;
|
|
9
9
|
/** Current aspect ratio */
|
|
@@ -8,13 +8,13 @@ class UIAspectConstraint extends UISingleParameterConstraint {
|
|
|
8
8
|
* @param element Element to constrain
|
|
9
9
|
* @param options Aspect configuration. Defaults to element's current ratio.
|
|
10
10
|
*/
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(element, options = {}) {
|
|
12
12
|
if (options.aspect !== undefined) {
|
|
13
13
|
assertValidPositiveNumber(options.aspect, "UIAspectConstraint.constructor.options.aspect");
|
|
14
14
|
}
|
|
15
|
-
super(
|
|
16
|
-
this.
|
|
17
|
-
this._private_aspectInternal = options.aspect ??
|
|
15
|
+
super(element.layer, options);
|
|
16
|
+
this.element = element;
|
|
17
|
+
this._private_aspectInternal = options.aspect ?? element.width / element.height;
|
|
18
18
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
19
19
|
}
|
|
20
20
|
/** Current aspect ratio (width/height) */
|
|
@@ -32,8 +32,8 @@ class UIAspectConstraint extends UISingleParameterConstraint {
|
|
|
32
32
|
/** Builds constraint expression: width - (height * aspect) = 0 */
|
|
33
33
|
_private_buildLHS() {
|
|
34
34
|
return new UIExpression(0, [
|
|
35
|
-
[this.
|
|
36
|
-
[this.
|
|
35
|
+
[this.element.wVariable, 1],
|
|
36
|
+
[this.element.hVariable, -this._private_aspectInternal],
|
|
37
37
|
]);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -3,7 +3,7 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
|
|
|
3
3
|
import type { UIHeightConstraintOptions } from "./UIHeightConstraint.Internal";
|
|
4
4
|
/** Fixes element height to constant value */
|
|
5
5
|
export declare class UIHeightConstraint extends UISingleParameterConstraint {
|
|
6
|
-
|
|
6
|
+
readonly element: UIPlaneElement & UILayerElement;
|
|
7
7
|
/** Solver constraint descriptor */
|
|
8
8
|
protected readonly constraint: number;
|
|
9
9
|
/** Current height value */
|
|
@@ -8,14 +8,14 @@ class UIHeightConstraint extends UISingleParameterConstraint {
|
|
|
8
8
|
* @param element Element to constrain
|
|
9
9
|
* @param options Height configuration. Defaults to element's current height.
|
|
10
10
|
*/
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(element, options = {}) {
|
|
12
12
|
if (options.height !== undefined) {
|
|
13
13
|
assertValidPositiveNumber(options.height, "UIHeightConstraint.constructor.options.height");
|
|
14
14
|
}
|
|
15
|
-
super(
|
|
16
|
-
this.
|
|
17
|
-
this._private_heightInternal = options.height ??
|
|
18
|
-
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this.
|
|
15
|
+
super(element.layer, options);
|
|
16
|
+
this.element = element;
|
|
17
|
+
this._private_heightInternal = options.height ?? element.height;
|
|
18
|
+
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this.element.hVariable, 1]]), new UIExpression(this._private_heightInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
19
19
|
}
|
|
20
20
|
/** Current height in world units */
|
|
21
21
|
get height() {
|
package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
|
|
|
3
3
|
import type { UIHorizontalDistanceConstraintOptions } from "./UIHorizontalDistanceConstraint.Internal";
|
|
4
4
|
/** Maintains horizontal distance between elements with configurable anchors */
|
|
5
5
|
export declare class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
readonly a: UIPointElement | UIPlaneElement;
|
|
7
|
+
readonly b: UIPointElement | UIPlaneElement;
|
|
8
8
|
/** Solver constraint descriptor */
|
|
9
9
|
protected readonly constraint: number;
|
|
10
10
|
/** Anchor on element A */
|
package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js
CHANGED
|
@@ -11,7 +11,7 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
11
11
|
* @param b Second element
|
|
12
12
|
* @param options Distance configuration
|
|
13
13
|
*/
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(a, b, options = {}) {
|
|
15
15
|
if (options.anchorA !== undefined) {
|
|
16
16
|
assertValidNumber(options.anchorA, "UIHorizontalDistanceConstraint.constructor.options.anchorA");
|
|
17
17
|
}
|
|
@@ -21,9 +21,9 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
21
21
|
if (options.distance !== undefined) {
|
|
22
22
|
assertValidNumber(options.distance, "UIHorizontalDistanceConstraint.constructor.options.distance");
|
|
23
23
|
}
|
|
24
|
-
super(assertValidConstraintArguments(
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
24
|
+
super(assertValidConstraintArguments(a, b, "UIHorizontalDistanceConstraint.constructor"), options);
|
|
25
|
+
this.a = a;
|
|
26
|
+
this.b = b;
|
|
27
27
|
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;
|
|
28
28
|
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;
|
|
29
29
|
this._private_distanceInternal = options.distance ?? 0;
|
|
@@ -69,26 +69,26 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
69
69
|
_private_buildLHS() {
|
|
70
70
|
let aExpression;
|
|
71
71
|
let bExpression;
|
|
72
|
-
if (isUIPlaneElement(this.
|
|
72
|
+
if (isUIPlaneElement(this.a)) {
|
|
73
73
|
aExpression = new UIExpression(0, [
|
|
74
|
-
[this.
|
|
75
|
-
[this.
|
|
74
|
+
[this.a.xVariable, 1],
|
|
75
|
+
[this.a.wVariable, this._private_anchorAInternal],
|
|
76
76
|
]);
|
|
77
77
|
}
|
|
78
|
-
else if (isUIPointElement(this.
|
|
79
|
-
aExpression = new UIExpression().plus(this.
|
|
78
|
+
else if (isUIPointElement(this.a)) {
|
|
79
|
+
aExpression = new UIExpression().plus(this.a.xVariable, 1);
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
82
|
throw new Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");
|
|
83
83
|
}
|
|
84
|
-
if (isUIPlaneElement(this.
|
|
84
|
+
if (isUIPlaneElement(this.b)) {
|
|
85
85
|
bExpression = new UIExpression(0, [
|
|
86
|
-
[this.
|
|
87
|
-
[this.
|
|
86
|
+
[this.b.xVariable, 1],
|
|
87
|
+
[this.b.wVariable, this._private_anchorBInternal],
|
|
88
88
|
]);
|
|
89
89
|
}
|
|
90
|
-
else if (isUIPointElement(this.
|
|
91
|
-
bExpression = new UIExpression().plus(this.
|
|
90
|
+
else if (isUIPointElement(this.b)) {
|
|
91
|
+
bExpression = new UIExpression().plus(this.b.xVariable, 1);
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
throw new Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");
|
|
@@ -3,9 +3,9 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
|
|
|
3
3
|
import type { UIHorizontalInterpolationConstraintOptions } from "./UIHorizontalInterpolationConstraint.Internal";
|
|
4
4
|
/** Positions element C horizontally between A and B based on interpolation factor */
|
|
5
5
|
export declare class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
readonly a: UIPointElement | UIPlaneElement;
|
|
7
|
+
readonly b: UIPointElement | UIPlaneElement;
|
|
8
|
+
readonly c: UIPointElement | UIPlaneElement;
|
|
9
9
|
/** Solver constraint descriptor */
|
|
10
10
|
protected readonly constraint: number;
|
|
11
11
|
/** Anchor on element A */
|
|
@@ -12,7 +12,7 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
12
12
|
* @param c Element to position between A and B
|
|
13
13
|
* @param options Interpolation configuration
|
|
14
14
|
*/
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(a, b, c, options = {}) {
|
|
16
16
|
if (options.anchorA !== undefined) {
|
|
17
17
|
assertValidNumber(options.anchorA, "UIHorizontalInterpolationConstraint.constructor.options.anchorA");
|
|
18
18
|
}
|
|
@@ -27,10 +27,10 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
27
27
|
}
|
|
28
28
|
const anchorA = options.anchorA ?? DEFAULT_ANCHOR;
|
|
29
29
|
const anchorB = options.anchorB ?? DEFAULT_ANCHOR;
|
|
30
|
-
super(assertValidInterpolationConstraintArguments("UIHorizontalInterpolationConstraint.constructor",
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
30
|
+
super(assertValidInterpolationConstraintArguments("UIHorizontalInterpolationConstraint.constructor", a, b, c, anchorA, anchorB), options);
|
|
31
|
+
this.a = a;
|
|
32
|
+
this.b = b;
|
|
33
|
+
this.c = c;
|
|
34
34
|
this._private_anchorAInternal = anchorA;
|
|
35
35
|
this._private_anchorBInternal = anchorA;
|
|
36
36
|
this._private_anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR;
|
|
@@ -90,38 +90,38 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
90
90
|
let aExpression;
|
|
91
91
|
let bExpression;
|
|
92
92
|
let cExpression;
|
|
93
|
-
if (isUIPlaneElement(this.
|
|
93
|
+
if (isUIPlaneElement(this.a)) {
|
|
94
94
|
aExpression = new UIExpression(0, [
|
|
95
|
-
[this.
|
|
96
|
-
[this.
|
|
95
|
+
[this.a.xVariable, 1],
|
|
96
|
+
[this.a.wVariable, this._private_anchorAInternal],
|
|
97
97
|
]);
|
|
98
98
|
}
|
|
99
|
-
else if (isUIPointElement(this.
|
|
100
|
-
aExpression = new UIExpression().plus(this.
|
|
99
|
+
else if (isUIPointElement(this.a)) {
|
|
100
|
+
aExpression = new UIExpression().plus(this.a.xVariable, 1);
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
103
|
throw new Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");
|
|
104
104
|
}
|
|
105
|
-
if (isUIPlaneElement(this.
|
|
105
|
+
if (isUIPlaneElement(this.b)) {
|
|
106
106
|
bExpression = new UIExpression(0, [
|
|
107
|
-
[this.
|
|
108
|
-
[this.
|
|
107
|
+
[this.b.xVariable, 1],
|
|
108
|
+
[this.b.wVariable, this._private_anchorBInternal],
|
|
109
109
|
]);
|
|
110
110
|
}
|
|
111
|
-
else if (isUIPointElement(this.
|
|
112
|
-
bExpression = new UIExpression().plus(this.
|
|
111
|
+
else if (isUIPointElement(this.b)) {
|
|
112
|
+
bExpression = new UIExpression().plus(this.b.xVariable, 1);
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
115
|
throw new Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");
|
|
116
116
|
}
|
|
117
|
-
if (isUIPlaneElement(this.
|
|
117
|
+
if (isUIPlaneElement(this.c)) {
|
|
118
118
|
cExpression = new UIExpression(0, [
|
|
119
|
-
[this.
|
|
120
|
-
[this.
|
|
119
|
+
[this.c.xVariable, 1],
|
|
120
|
+
[this.c.wVariable, this._private_anchorCInternal],
|
|
121
121
|
]);
|
|
122
122
|
}
|
|
123
|
-
else if (isUIPointElement(this.
|
|
124
|
-
cExpression = new UIExpression().plus(this.
|
|
123
|
+
else if (isUIPointElement(this.c)) {
|
|
124
|
+
cExpression = new UIExpression().plus(this.c.xVariable, 1);
|
|
125
125
|
}
|
|
126
126
|
else {
|
|
127
127
|
throw new Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");
|
package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
|
|
|
3
3
|
import type { UIHorizontalProportionConstraintOptions } from "./UIHorizontalProportionConstraint.Internal";
|
|
4
4
|
/** Maintains proportional width relationship (A.width * proportion = B.width) */
|
|
5
5
|
export declare class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
readonly a: UIPlaneElement;
|
|
7
|
+
readonly b: UIPlaneElement;
|
|
8
8
|
protected readonly constraint: number;
|
|
9
9
|
private proportionInternal;
|
|
10
10
|
/**
|
package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js
CHANGED
|
@@ -9,13 +9,13 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
9
9
|
* @param b Second element
|
|
10
10
|
* @param options Proportion configuration
|
|
11
11
|
*/
|
|
12
|
-
constructor(
|
|
12
|
+
constructor(a, b, options = {}) {
|
|
13
13
|
if (options.proportion !== undefined) {
|
|
14
14
|
assertValidPositiveNumber(options.proportion, "UIHorizontalProportionConstraint.constructor.options.proportion");
|
|
15
15
|
}
|
|
16
|
-
super(assertValidConstraintArguments(
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
16
|
+
super(assertValidConstraintArguments(a, b, "UIHorizontalProportionConstraint.constructor"), options);
|
|
17
|
+
this.a = a;
|
|
18
|
+
this.b = b;
|
|
19
19
|
this._private_proportionInternal = options.proportion ?? 1;
|
|
20
20
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
|
|
21
21
|
}
|
|
@@ -33,7 +33,7 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
33
33
|
}
|
|
34
34
|
/** Builds constraint expression for proportional relationship */
|
|
35
35
|
_private_buildRHS() {
|
|
36
|
-
return UIExpression.minus(new UIExpression(0, [[this.
|
|
36
|
+
return UIExpression.minus(new UIExpression(0, [[this.a.wVariable, this._private_proportionInternal]]), new UIExpression(0, [[this.b.wVariable, 1]]));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -57,6 +57,7 @@ class UISingleParameterConstraint extends UIConstraint {
|
|
|
57
57
|
destroy() {
|
|
58
58
|
this.layer.signalOrientationChanged.off(this._private_onOrientationChange);
|
|
59
59
|
this.solverWrapper.removeConstraint(this.constraint);
|
|
60
|
+
super.destroy();
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
63
|
* Checks if constraint should be active for current orientation.
|
package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
|
|
|
3
3
|
import type { UIVerticalDistanceConstraintOptions } from "./UIVerticalDistanceConstraint.Internal";
|
|
4
4
|
/** Maintains vertical distance between elements with configurable anchors */
|
|
5
5
|
export declare class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
readonly a: UIPointElement | UIPlaneElement;
|
|
7
|
+
readonly b: UIPointElement | UIPlaneElement;
|
|
8
8
|
protected readonly constraint: number;
|
|
9
9
|
private anchorAInternal;
|
|
10
10
|
private anchorBInternal;
|
|
@@ -11,7 +11,7 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
11
11
|
* @param b Second element
|
|
12
12
|
* @param options Distance configuration
|
|
13
13
|
*/
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(a, b, options = {}) {
|
|
15
15
|
if (options.anchorA !== undefined) {
|
|
16
16
|
assertValidNumber(options.anchorA, "UIVerticalDistanceConstraint.constructor.options.anchorA");
|
|
17
17
|
}
|
|
@@ -21,9 +21,9 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
21
21
|
if (options.distance !== undefined) {
|
|
22
22
|
assertValidNumber(options.distance, "UIVerticalDistanceConstraint.constructor.options.distance");
|
|
23
23
|
}
|
|
24
|
-
super(assertValidConstraintArguments(
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
24
|
+
super(assertValidConstraintArguments(a, b, "UIVerticalDistanceConstraint.constructor"), options);
|
|
25
|
+
this.a = a;
|
|
26
|
+
this.b = b;
|
|
27
27
|
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;
|
|
28
28
|
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;
|
|
29
29
|
this._private_distanceInternal = options.distance ?? 0;
|
|
@@ -69,26 +69,26 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
69
69
|
_private_buildLHS() {
|
|
70
70
|
let aExpression;
|
|
71
71
|
let bExpression;
|
|
72
|
-
if (isUIPlaneElement(this.
|
|
72
|
+
if (isUIPlaneElement(this.a)) {
|
|
73
73
|
aExpression = new UIExpression(0, [
|
|
74
|
-
[this.
|
|
75
|
-
[this.
|
|
74
|
+
[this.a.yVariable, 1],
|
|
75
|
+
[this.a.hVariable, this._private_anchorAInternal],
|
|
76
76
|
]);
|
|
77
77
|
}
|
|
78
|
-
else if (isUIPointElement(this.
|
|
79
|
-
aExpression = new UIExpression().plus(this.
|
|
78
|
+
else if (isUIPointElement(this.a)) {
|
|
79
|
+
aExpression = new UIExpression().plus(this.a.yVariable, 1);
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
82
|
throw new Error("UIVerticalDistanceConstraint.buildLHS.a: invalid element type");
|
|
83
83
|
}
|
|
84
|
-
if (isUIPlaneElement(this.
|
|
84
|
+
if (isUIPlaneElement(this.b)) {
|
|
85
85
|
bExpression = new UIExpression(0, [
|
|
86
|
-
[this.
|
|
87
|
-
[this.
|
|
86
|
+
[this.b.yVariable, 1],
|
|
87
|
+
[this.b.hVariable, this._private_anchorBInternal],
|
|
88
88
|
]);
|
|
89
89
|
}
|
|
90
|
-
else if (isUIPointElement(this.
|
|
91
|
-
bExpression = new UIExpression().plus(this.
|
|
90
|
+
else if (isUIPointElement(this.b)) {
|
|
91
|
+
bExpression = new UIExpression().plus(this.b.yVariable, 1);
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
throw new Error("UIVerticalDistanceConstraint.buildLHS.b: invalid element type");
|
|
@@ -3,9 +3,9 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
|
|
|
3
3
|
import type { UIVerticalInterpolationConstraintOptions } from "./UIVerticalInterpolationConstraint.Internal";
|
|
4
4
|
/** Positions element C vertically between A and B based on interpolation factor */
|
|
5
5
|
export declare class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
readonly a: UIPointElement | UIPlaneElement;
|
|
7
|
+
readonly b: UIPointElement | UIPlaneElement;
|
|
8
|
+
readonly c: UIPointElement | UIPlaneElement;
|
|
9
9
|
/** Solver constraint descriptor */
|
|
10
10
|
protected readonly constraint: number;
|
|
11
11
|
/** Anchor on element A */
|
package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js
CHANGED
|
@@ -12,7 +12,7 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
12
12
|
* @param c Element to position between A and B
|
|
13
13
|
* @param options Interpolation configuration
|
|
14
14
|
*/
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(a, b, c, options = {}) {
|
|
16
16
|
if (options.anchorA !== undefined) {
|
|
17
17
|
assertValidNumber(options.anchorA, "UIVerticalInterpolationConstraint.constructor.options.anchorA");
|
|
18
18
|
}
|
|
@@ -27,10 +27,10 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
27
27
|
}
|
|
28
28
|
const anchorA = options.anchorA ?? DEFAULT_ANCHOR;
|
|
29
29
|
const anchorB = options.anchorB ?? DEFAULT_ANCHOR;
|
|
30
|
-
super(assertValidInterpolationConstraintArguments("UIVerticalInterpolationConstraint.constructor",
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
30
|
+
super(assertValidInterpolationConstraintArguments("UIVerticalInterpolationConstraint.constructor", a, b, c, anchorA, anchorB), options);
|
|
31
|
+
this.a = a;
|
|
32
|
+
this.b = b;
|
|
33
|
+
this.c = c;
|
|
34
34
|
this._private_anchorAInternal = anchorA;
|
|
35
35
|
this._private_anchorBInternal = anchorA;
|
|
36
36
|
this._private_anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR;
|
|
@@ -90,38 +90,38 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
90
90
|
let aExpression;
|
|
91
91
|
let bExpression;
|
|
92
92
|
let cExpression;
|
|
93
|
-
if (isUIPlaneElement(this.
|
|
93
|
+
if (isUIPlaneElement(this.a)) {
|
|
94
94
|
aExpression = new UIExpression(0, [
|
|
95
|
-
[this.
|
|
96
|
-
[this.
|
|
95
|
+
[this.a.yVariable, 1],
|
|
96
|
+
[this.a.hVariable, this._private_anchorAInternal],
|
|
97
97
|
]);
|
|
98
98
|
}
|
|
99
|
-
else if (isUIPointElement(this.
|
|
100
|
-
aExpression = new UIExpression().plus(this.
|
|
99
|
+
else if (isUIPointElement(this.a)) {
|
|
100
|
+
aExpression = new UIExpression().plus(this.a.yVariable, 1);
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
103
|
throw new Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");
|
|
104
104
|
}
|
|
105
|
-
if (isUIPlaneElement(this.
|
|
105
|
+
if (isUIPlaneElement(this.b)) {
|
|
106
106
|
bExpression = new UIExpression(0, [
|
|
107
|
-
[this.
|
|
108
|
-
[this.
|
|
107
|
+
[this.b.yVariable, 1],
|
|
108
|
+
[this.b.hVariable, this._private_anchorBInternal],
|
|
109
109
|
]);
|
|
110
110
|
}
|
|
111
|
-
else if (isUIPointElement(this.
|
|
112
|
-
bExpression = new UIExpression().plus(this.
|
|
111
|
+
else if (isUIPointElement(this.b)) {
|
|
112
|
+
bExpression = new UIExpression().plus(this.b.yVariable, 1);
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
115
|
throw new Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");
|
|
116
116
|
}
|
|
117
|
-
if (isUIPlaneElement(this.
|
|
117
|
+
if (isUIPlaneElement(this.c)) {
|
|
118
118
|
cExpression = new UIExpression(0, [
|
|
119
|
-
[this.
|
|
120
|
-
[this.
|
|
119
|
+
[this.c.yVariable, 1],
|
|
120
|
+
[this.c.hVariable, this._private_anchorCInternal],
|
|
121
121
|
]);
|
|
122
122
|
}
|
|
123
|
-
else if (isUIPointElement(this.
|
|
124
|
-
cExpression = new UIExpression().plus(this.
|
|
123
|
+
else if (isUIPointElement(this.c)) {
|
|
124
|
+
cExpression = new UIExpression().plus(this.c.yVariable, 1);
|
|
125
125
|
}
|
|
126
126
|
else {
|
|
127
127
|
throw new Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");
|
package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
|
|
|
3
3
|
import type { UIVerticalProportionConstraintOptions } from "./UIVerticalProportionConstraint.Internal";
|
|
4
4
|
/** Maintains proportional height relationship (A.height * proportion = B.height) */
|
|
5
5
|
export declare class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
readonly a: UIPlaneElement;
|
|
7
|
+
readonly b: UIPlaneElement;
|
|
8
8
|
protected readonly constraint: number;
|
|
9
9
|
private proportionInternal;
|
|
10
10
|
/**
|
package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js
CHANGED
|
@@ -9,13 +9,13 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
|
9
9
|
* @param b Second element
|
|
10
10
|
* @param options Proportion configuration
|
|
11
11
|
*/
|
|
12
|
-
constructor(
|
|
12
|
+
constructor(a, b, options = {}) {
|
|
13
13
|
if (options.proportion !== undefined) {
|
|
14
14
|
assertValidPositiveNumber(options.proportion, "UIVerticalProportionConstraint.constructor.options.proportion");
|
|
15
15
|
}
|
|
16
|
-
super(assertValidConstraintArguments(
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
16
|
+
super(assertValidConstraintArguments(a, b, "UIVerticalProportionConstraint.constructor"), options);
|
|
17
|
+
this.a = a;
|
|
18
|
+
this.b = b;
|
|
19
19
|
this._private_proportionInternal = options.proportion ?? 1;
|
|
20
20
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
|
|
21
21
|
}
|
|
@@ -33,7 +33,7 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
|
33
33
|
}
|
|
34
34
|
/** Builds constraint expression for proportional relationship */
|
|
35
35
|
_private_buildRHS() {
|
|
36
|
-
return UIExpression.minus(new UIExpression(0, [[this.
|
|
36
|
+
return UIExpression.minus(new UIExpression(0, [[this.a.hVariable, this._private_proportionInternal]]), new UIExpression(0, [[this.b.hVariable, 1]]));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -3,7 +3,7 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
|
|
|
3
3
|
import type { UIWidthConstraintOptions } from "./UIWidthConstraint.Internal";
|
|
4
4
|
/** Fixes element width to constant value */
|
|
5
5
|
export declare class UIWidthConstraint extends UISingleParameterConstraint {
|
|
6
|
-
|
|
6
|
+
readonly element: UIPlaneElement & UILayerElement;
|
|
7
7
|
/** Solver constraint descriptor */
|
|
8
8
|
protected readonly constraint: number;
|
|
9
9
|
/** Current width value */
|
|
@@ -8,14 +8,14 @@ class UIWidthConstraint extends UISingleParameterConstraint {
|
|
|
8
8
|
* @param element Element to constrain
|
|
9
9
|
* @param options Width configuration. Defaults to element's current width.
|
|
10
10
|
*/
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(element, options = {}) {
|
|
12
12
|
if (options.width !== undefined) {
|
|
13
13
|
assertValidPositiveNumber(options.width, "UIWidthConstraint.constructor.options.width");
|
|
14
14
|
}
|
|
15
|
-
super(
|
|
16
|
-
this.
|
|
17
|
-
this._private_widthInternal = options.width ??
|
|
18
|
-
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this.
|
|
15
|
+
super(element.layer, options);
|
|
16
|
+
this.element = element;
|
|
17
|
+
this._private_widthInternal = options.width ?? element.width;
|
|
18
|
+
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this.element.wVariable, 1]]), new UIExpression(this._private_widthInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
19
19
|
}
|
|
20
20
|
/** Current width in world units */
|
|
21
21
|
get width() {
|