laymur 0.16.0 → 0.17.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 +84 -208
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +41 -0
- package/dist/{constraints → core/constraints}/UIConstraint.d.ts +2 -2
- package/dist/core/constraints/UIConstraint.js +11 -0
- package/dist/core/constraints/UICustomConstraint.js +37 -0
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +34 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.js +3 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +100 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.js +4 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +136 -0
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +40 -0
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +71 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.js +3 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +100 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.js +4 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +136 -0
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +40 -0
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +34 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.js +19 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.js +138 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.js +3 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.js +63 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.js +3 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.js +63 -0
- package/dist/{elements → core/elements}/UIAnchor/UIAnchor.Internal.d.ts +3 -0
- package/dist/core/elements/UIAnchor/UIAnchor.Internal.js +5 -0
- package/dist/{elements → core/elements}/UIAnchor/UIAnchor.d.ts +3 -3
- package/dist/core/elements/UIAnchor/UIAnchor.js +49 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.js +15 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +259 -0
- package/dist/core/elements/UIDummy/UIDummy.Internal.js +8 -0
- package/dist/{elements → core/elements}/UIDummy/UIDummy.d.ts +2 -2
- package/dist/core/elements/UIDummy/UIDummy.js +173 -0
- package/dist/core/elements/UIElement/UIElement.Internal.js +5 -0
- package/dist/{elements → core/elements}/UIElement/UIElement.d.ts +2 -2
- package/dist/core/elements/UIElement/UIElement.js +74 -0
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.js +7 -0
- package/dist/core/elements/UIGraphics/UIGraphics.js +126 -0
- package/dist/core/elements/UIImage/UIImage.js +85 -0
- package/dist/core/elements/UINineSlice/UINineSlice.Internal.js +12 -0
- package/dist/core/elements/UINineSlice/UINineSlice.js +188 -0
- package/dist/core/elements/UIProgress/UIProgress.Internal.js +3 -0
- package/dist/core/elements/UIProgress/UIProgress.js +165 -0
- package/dist/core/elements/UIScene/UIScene.Internal.js +27 -0
- package/dist/core/elements/UIScene/UIScene.js +157 -0
- package/dist/core/elements/UIText/UIText.Internal.js +12 -0
- package/dist/core/elements/UIText/UIText.Measuring.js +153 -0
- package/dist/core/elements/UIText/UIText.Rendering.js +61 -0
- package/dist/core/elements/UIText/UIText.js +265 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.js +5 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +147 -0
- package/dist/core/layers/UILayer/UILayer.Internal.js +7 -0
- package/dist/core/layers/UILayer/UILayer.js +113 -0
- package/dist/core/miscellaneous/UIExpression.js +128 -0
- package/dist/core/miscellaneous/UIMode.js +30 -0
- package/dist/core/miscellaneous/UIOrientation.js +20 -0
- package/dist/core/miscellaneous/UIPriority.js +63 -0
- package/dist/core/miscellaneous/UIRelation.js +40 -0
- package/dist/core/miscellaneous/UITransparencyMode.js +12 -0
- package/dist/core/miscellaneous/area/UIArea.js +5 -0
- package/dist/core/miscellaneous/area/UIAreaCircle.js +32 -0
- package/dist/core/miscellaneous/area/UIAreaPolygon.js +40 -0
- package/dist/core/miscellaneous/area/UIAreaRectangle.js +36 -0
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +72 -0
- package/dist/core/miscellaneous/asserts.js +163 -0
- package/dist/core/miscellaneous/canvas.js +37 -0
- package/dist/core/miscellaneous/color/UIColor.Internal.js +42 -0
- package/dist/core/miscellaneous/color/UIColor.js +636 -0
- package/dist/core/miscellaneous/computeTransform.js +82 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +168 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +349 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +357 -0
- package/dist/core/miscellaneous/generic-plane/shared.js +228 -0
- package/dist/core/miscellaneous/insets/UIInsets.Internal.js +3 -0
- package/dist/core/miscellaneous/insets/UIInsets.js +224 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +19 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +51 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +48 -0
- package/dist/{miscellaneous → core/miscellaneous}/math.d.ts +2 -0
- package/dist/core/miscellaneous/math.js +11 -0
- package/dist/core/miscellaneous/micro/UIMicro.Internal.js +15 -0
- package/dist/core/miscellaneous/micro/UIMicro.js +181 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +9 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +50 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +50 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.js +13 -0
- package/dist/core/miscellaneous/shared.js +37 -0
- package/dist/core/miscellaneous/text-span/UITextSpan.js +36 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.js +17 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.js +372 -0
- package/dist/core/miscellaneous/texture/UITextureView.Internal.js +6 -0
- package/dist/core/miscellaneous/texture/UITextureView.js +234 -0
- package/dist/core/miscellaneous/webglCapabilities.js +103 -0
- package/dist/core/shaders/UIImage.glsl.js +3 -0
- package/dist/core/shaders/UINineSlice.glsl.js +3 -0
- package/dist/core/shaders/UIProgress.glsl.js +3 -0
- package/dist/core/shaders/UIProgressMaskFunctionCircular.glsl.js +3 -0
- package/dist/core/shaders/UIProgressMaskFunctionDirectional.glsl.js +3 -0
- package/dist/{wrappers → core/wrappers}/UIInputWrapper/UIInputWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UIInputWrapper/UIInputWrapper.d.ts +2 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +108 -0
- package/dist/{wrappers → core/wrappers}/UISceneWrapper/UISceneWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UISceneWrapper/UISceneWrapper.d.ts +2 -2
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +75 -0
- package/dist/{wrappers → core/wrappers}/UISolverWrapper/UISolverWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UISolverWrapper/UISolverWrapper.d.ts +2 -2
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +505 -0
- package/dist/index.js +51 -9246
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +21 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +47 -0
- package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +14 -0
- package/dist/particles/behaviorModules/UIBehaviorModule.js +9 -0
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +39 -0
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +110 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +22 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +66 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +20 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +48 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +26 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +66 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +20 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +49 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +26 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +70 -0
- package/dist/particles/elements/UIEmitter.Internal.d.ts +15 -0
- package/dist/particles/elements/UIEmitter.Internal.js +11 -0
- package/dist/particles/elements/UIEmitter.d.ts +68 -0
- package/dist/particles/elements/UIEmitter.js +203 -0
- package/dist/particles/index.d.ts +18 -0
- package/dist/particles/index.js +18 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +13 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +211 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +17 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.js +93 -0
- package/dist/particles/miscellaneous/miscellaneous.d.ts +32 -0
- package/dist/particles/miscellaneous/miscellaneous.js +67 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +14 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.js +32 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +15 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +37 -0
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +8 -0
- package/dist/particles/renderingModules/UIRenderingModule.js +9 -0
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +14 -0
- package/dist/particles/renderingModules/UIRenderingTexture.js +26 -0
- package/dist/particles/shaders/UIRenderingColorOverLife.glsl.js +3 -0
- package/dist/particles/shaders/UIRenderingColorOverVelocity.glsl.js +3 -0
- package/dist/particles/shaders/UIRenderingTexture.glsl.js +3 -0
- package/dist/particles/spawnModules/UISpawnModule.d.ts +9 -0
- package/dist/particles/spawnModules/UISpawnModule.js +9 -0
- package/dist/particles/spawnModules/UISpawnOffset.d.ts +21 -0
- package/dist/particles/spawnModules/UISpawnOffset.js +46 -0
- package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomLifetime.js +47 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.js +45 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +26 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.js +60 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.js +45 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +26 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.js +64 -0
- package/dist/particles/spawnModules/UISpawnRectangle.d.ts +27 -0
- package/dist/particles/spawnModules/UISpawnRectangle.js +62 -0
- package/package.json +27 -36
- package/dist/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- /package/dist/{constraints → core/constraints}/UIAspectConstraint/UIAspectConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIAspectConstraint/UIAspectConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UICustomConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHeightConstraint/UIHeightConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHeightConstraint/UIHeightConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIWidthConstraint/UIWidthConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIWidthConstraint/UIWidthConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIConstraint2DBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIConstraint2DBuilder.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UICoverConstraintBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UICoverConstraintBuilder.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIFitConstraintBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIFitConstraintBuilder.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIAnimatedImage/UIAnimatedImage.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIDummy/UIDummy.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIElement/UIElement.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIGraphics/UIGraphics.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIGraphics/UIGraphics.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIImage/UIImage.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIImage/UIImage.d.ts +0 -0
- /package/dist/{elements → core/elements}/UINineSlice/UINineSlice.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UINineSlice/UINineSlice.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIProgress/UIProgress.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIProgress/UIProgress.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIScene/UIScene.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIScene/UIScene.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Interfaces.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Measuring.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Rendering.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.d.ts +0 -0
- /package/dist/{index.d.ts → core/index.d.ts} +0 -0
- /package/dist/{layers → core/layers}/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +0 -0
- /package/dist/{layers → core/layers}/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -0
- /package/dist/{layers → core/layers}/UILayer/UILayer.Internal.d.ts +0 -0
- /package/dist/{layers → core/layers}/UILayer/UILayer.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIExpression.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIMode.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIOrientation.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIPriority.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIRelation.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UITransparencyMode.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIArea.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaCircle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaPolygon.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaRectangle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaRoundedRectangle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/asserts.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/canvas.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/color/UIColor.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/color/UIColor.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/computeTransform.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/shared.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/insets/UIInsets.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/insets/UIInsets.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunction.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunctionCircular.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunctionDirectional.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/micro/UIMicro.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/micro/UIMicro.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicy.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCover.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCross.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCrossInverted.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFit.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFixedHeight.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFixedWidth.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyNone.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/shared.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-span/UITextSpan.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-span/UITextSpan.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-style/UITextStyle.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-style/UITextStyle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/texture/UITextureView.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/texture/UITextureView.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/webglCapabilities.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
+
<img src="./assets/logotype.png" width="200" alt="Laymur logo"><br/>
|
|
2
3
|
<h1 align="center">Laymur</h1>
|
|
3
4
|
<p align="center">
|
|
4
|
-
|
|
5
|
+
Constraint-based UI library for Three.js.<br/>
|
|
6
|
+
Primarily built for mobile advertisements (playable ads).
|
|
5
7
|
</p>
|
|
6
8
|
</p>
|
|
7
|
-
|
|
8
9
|
<p align="center">
|
|
9
|
-
<a href="https://www.npmjs.com/package/laymur"><img src="https://img.shields.io/npm/v/laymur.svg" alt="npm version"></a>
|
|
10
|
-
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
|
11
|
-
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-%5E5.8.0-blue" alt="TypeScript"></a>
|
|
12
|
-
<a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-0.157.0--0.180.0-green" alt="Three.js"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/laymur"><img src="https://img.shields.io/npm/v/laymur.svg" alt="npm version"></a>
|
|
11
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
|
12
|
+
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-%5E5.8.0-blue" alt="TypeScript"></a>
|
|
13
|
+
<a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-0.157.0--0.180.0-green" alt="Three.js"></a>
|
|
13
14
|
</p>
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
This library is in early development. APIs may change.
|
|
18
|
-
|
|
19
|
-
## What it does
|
|
20
|
-
|
|
21
|
-
A compact UI library designed for Three.js mobile advertisements where bundle size matters. Uses constraint-based positioning to handle responsive layouts across different screen sizes and orientations.
|
|
16
|
+
## Features
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Originally built for mobile ad development scenarios where you need to keep the bundle small while supporting various screen configurations.
|
|
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
|
|
30
23
|
|
|
31
24
|
## Installation
|
|
32
25
|
|
|
@@ -34,235 +27,118 @@ Originally built for mobile ad development scenarios where you need to keep the
|
|
|
34
27
|
npm install laymur
|
|
35
28
|
```
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## Quick Example
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import { UIFullscreenLayer, UIImage, UIText } from "laymur";
|
|
43
|
-
import { WebGLRenderer, TextureLoader, Clock } from "three";
|
|
44
|
-
|
|
45
|
-
const renderer = new WebGLRenderer();
|
|
46
|
-
const layer = new UIFullscreenLayer();
|
|
47
|
-
const clock = new Clock();
|
|
48
|
-
|
|
49
|
-
const texture = new TextureLoader().load("background.jpg");
|
|
50
|
-
const background = new UIImage(layer, texture, { x: 0, y: 0 });
|
|
51
|
-
const title = new UIText(layer, "Mobile Ad Title", {
|
|
52
|
-
x: 100,
|
|
53
|
-
y: 100,
|
|
54
|
-
maxLineWidth: 800,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
function animate() {
|
|
58
|
-
layer.render(renderer, clock.getDelta());
|
|
59
|
-
requestAnimationFrame(animate);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
animate();
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Basic Components
|
|
66
|
-
|
|
67
|
-
### Layers
|
|
68
|
-
|
|
69
|
-
- **UIFullscreenLayer** - Handles browser window scaling
|
|
30
|
+
Peer Dependencies:
|
|
70
31
|
|
|
71
|
-
|
|
32
|
+
* `three` (>=0.157.0 <0.180.0)
|
|
33
|
+
* `@lume/kiwi` (^0.4.4)
|
|
34
|
+
* `ferrsign` (^0.0.4)
|
|
72
35
|
|
|
73
|
-
|
|
74
|
-
- **UIAnimatedImage** - Animated texture sequences
|
|
75
|
-
- **UIText** - Text rendering with word wrapping and styled spans
|
|
76
|
-
- **UIGraphics** - Vector graphics and shapes
|
|
77
|
-
- **UIScene** - Embed 3D scenes
|
|
78
|
-
- **UIProgress** - Progress bars
|
|
79
|
-
- **UINineSlice** - Scalable UI panels with border preservation
|
|
80
|
-
- **UIAnchor** - Positioning points
|
|
36
|
+
## Core Concepts
|
|
81
37
|
|
|
82
|
-
###
|
|
83
|
-
|
|
84
|
-
- **UIWidthConstraint** / **UIHeightConstraint** - Fixed sizes
|
|
85
|
-
- **UIAspectConstraint** - Maintain aspect ratios
|
|
86
|
-
- **UIHorizontalDistanceConstraint** / **UIVerticalDistanceConstraint** - Spacing between elements
|
|
87
|
-
- **UIHorizontalProportionConstraint** / **UIVerticalProportionConstraint** - Proportional sizing
|
|
88
|
-
- **UIHorizontalInterpolationConstraint** / **UIVerticalInterpolationConstraint** - Position element between two anchors
|
|
89
|
-
- **UICustomConstraint** - Custom constraint expressions
|
|
90
|
-
- **UIFitConstraintBuilder** - Fit element inside container (like CSS object-fit: contain)
|
|
91
|
-
- **UICoverConstraintBuilder** - Cover container with element (like CSS object-fit: cover)
|
|
38
|
+
### 1. Layers & Elements
|
|
92
39
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
The constraint system automatically calculates positions and sizes based on relationships you define:
|
|
40
|
+
`UIFullscreenLayer` manages coordinate system, canvas scaling, and input. All UI elements attach to a layer.
|
|
96
41
|
|
|
97
42
|
```typescript
|
|
98
|
-
import { UIImage,
|
|
99
|
-
|
|
100
|
-
const sidebar = new UIImage(layer, sidebarTexture, { x: 0, y: 0 });
|
|
101
|
-
const content = new UIImage(layer, contentTexture, { x: 0, y: 0 });
|
|
43
|
+
import { UIFullscreenLayer, UIImage, UIMode, UIResizePolicyFixedHeight } from 'laymur';
|
|
102
44
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
new UIHorizontalDistanceConstraint(sidebar, content, {
|
|
108
|
-
distance: 20,
|
|
109
|
-
anchorA: 1.0, // Right edge of sidebar
|
|
110
|
-
anchorB: 0.0, // Left edge of content
|
|
45
|
+
const layer = new UIFullscreenLayer({
|
|
46
|
+
name: "MainHUD",
|
|
47
|
+
mode: UIMode.VISIBLE,
|
|
48
|
+
resizePolicy: new UIResizePolicyFixedHeight(1080, 1920)
|
|
111
49
|
});
|
|
112
50
|
```
|
|
113
51
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
Text supports styled spans with different fonts, sizes, and colors:
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
import { UIText } from "laymur";
|
|
120
|
-
|
|
121
|
-
const text = new UIText(
|
|
122
|
-
layer,
|
|
123
|
-
[
|
|
124
|
-
{ text: "Download ", style: { fontSize: 24, color: "#333333" } },
|
|
125
|
-
{ text: "Now!", style: { fontSize: 32, color: "#ff0000", fontWeight: "bold" } },
|
|
126
|
-
],
|
|
127
|
-
{
|
|
128
|
-
x: 100,
|
|
129
|
-
y: 100,
|
|
130
|
-
maxLineWidth: 600,
|
|
131
|
-
},
|
|
132
|
-
);
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Transformations
|
|
136
|
-
|
|
137
|
-
Apply visual transformations without affecting the constraint layout:
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
const element = new UIImage(layer, texture, { x: 0, y: 0 });
|
|
141
|
-
|
|
142
|
-
// Apply transformations for animations
|
|
143
|
-
element.micro.x = 10;
|
|
144
|
-
element.micro.scaleX = 1.2;
|
|
145
|
-
element.micro.rotation = 0.1;
|
|
146
|
-
element.micro.anchorX = 0.5; // Transform origin (0 = left/bottom, 0.5 = center, 1 = right/top)
|
|
147
|
-
|
|
148
|
-
// Reset all transformations
|
|
149
|
-
element.micro.reset();
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## Event Handling
|
|
52
|
+
### 2. Constraint System
|
|
153
53
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
### Element Input Events
|
|
157
|
-
|
|
158
|
-
Elements with area (width and height) can emit input events:
|
|
54
|
+
Cassowary-based constraint solver. Supports priorities, element relationships, orientation-specific rules, and inequality relations.
|
|
159
55
|
|
|
160
56
|
```typescript
|
|
161
|
-
import {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
button.signalEntered.on((data: UIInputEventData) => {
|
|
180
|
-
console.log("Pointer entered button");
|
|
57
|
+
import {
|
|
58
|
+
UIHorizontalDistanceConstraint,
|
|
59
|
+
UIVerticalProportionConstraint,
|
|
60
|
+
UIAspectConstraint,
|
|
61
|
+
UIOrientation,
|
|
62
|
+
UIPriority,
|
|
63
|
+
UIRelation
|
|
64
|
+
} from 'laymur';
|
|
65
|
+
|
|
66
|
+
// Lock aspect ratio
|
|
67
|
+
new UIAspectConstraint(element);
|
|
68
|
+
|
|
69
|
+
// Position relative to layer center
|
|
70
|
+
new UIHorizontalDistanceConstraint(layer, element, {
|
|
71
|
+
anchorA: 0.5,
|
|
72
|
+
anchorB: 0.5,
|
|
181
73
|
});
|
|
182
74
|
|
|
183
|
-
|
|
184
|
-
|
|
75
|
+
// Size as proportion of layer, landscape only
|
|
76
|
+
new UIVerticalProportionConstraint(layer, element, {
|
|
77
|
+
proportion: 0.4,
|
|
78
|
+
orientation: UIOrientation.HORIZONTAL,
|
|
79
|
+
priority: UIPriority.P1,
|
|
185
80
|
});
|
|
186
81
|
|
|
187
|
-
|
|
188
|
-
|
|
82
|
+
// Max width constraint
|
|
83
|
+
new UIHorizontalProportionConstraint(layer, element, {
|
|
84
|
+
proportion: 0.8,
|
|
85
|
+
relation: UIRelation.LESS_THAN,
|
|
189
86
|
});
|
|
190
87
|
```
|
|
191
88
|
|
|
192
|
-
###
|
|
89
|
+
### 3. Micro-transforms
|
|
193
90
|
|
|
194
|
-
|
|
91
|
+
For animations, use `.micro` — updates visual matrix without triggering the solver.
|
|
195
92
|
|
|
196
93
|
```typescript
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
layer.signalPointerPressed.on((data: UIFullscreenLayerInputEventData) => {
|
|
200
|
-
console.log("Layer pressed at", data.x, data.y);
|
|
201
|
-
console.log("Layer:", data.layer);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
layer.signalPointerMoved.on((data: UIFullscreenLayerInputEventData) => {
|
|
205
|
-
console.log("Pointer moved to", data.x, data.y);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
layer.signalPointerReleased.on((data: UIFullscreenLayerInputEventData) => {
|
|
209
|
-
console.log("Pointer released");
|
|
210
|
-
});
|
|
94
|
+
element.micro.scaleX = Math.sin(Date.now() * 0.001) + 1;
|
|
95
|
+
element.micro.rotation += 0.01;
|
|
211
96
|
```
|
|
212
97
|
|
|
213
|
-
###
|
|
98
|
+
### 4. Particle System
|
|
214
99
|
|
|
215
|
-
|
|
100
|
+
Modular pipeline: Spawn → Behavior → Rendering.
|
|
216
101
|
|
|
217
102
|
```typescript
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
animation.signalPlayed.on(() => {
|
|
221
|
-
console.log("Animation started or resumed");
|
|
222
|
-
});
|
|
103
|
+
import { UIEmitter, UISpawnRectangle, UIBehaviorDirectionalGravity, UIRenderingTexture } from 'laymur/particles';
|
|
223
104
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
105
|
+
const emitter = new UIEmitter(
|
|
106
|
+
layer,
|
|
107
|
+
[new UISpawnRectangle([-500, 0], [500, 0])],
|
|
108
|
+
[new UIBehaviorDirectionalGravity({ x: 0, y: 100 })],
|
|
109
|
+
[new UIRenderingTexture(particleTexture)],
|
|
110
|
+
{ expectedCapacity: 1024 } // Pre-allocation hint, not a hard limit
|
|
111
|
+
);
|
|
227
112
|
|
|
228
|
-
|
|
229
|
-
console.log("Animation stopped and reset");
|
|
230
|
-
});
|
|
113
|
+
emitter.play(60); // particles/sec
|
|
231
114
|
```
|
|
232
115
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
```typescript
|
|
236
|
-
const handler = (data: UIInputEventData) => {
|
|
237
|
-
console.log("Pressed!");
|
|
238
|
-
};
|
|
116
|
+
## API Overview
|
|
239
117
|
|
|
240
|
-
|
|
241
|
-
button.signalPressed.off(handler); // Unsubscribe
|
|
242
|
-
```
|
|
118
|
+
Most commonly used exports (not exhaustive):
|
|
243
119
|
|
|
244
|
-
|
|
120
|
+
### Core
|
|
245
121
|
|
|
246
|
-
|
|
122
|
+
UIFullscreenLayer, UIImage, UIAnimatedImage, UIText, UINineSlice, UIProgress
|
|
247
123
|
|
|
248
|
-
|
|
124
|
+
### Constraints
|
|
249
125
|
|
|
250
|
-
|
|
126
|
+
UIAspectConstraint, UIHorizontalDistanceConstraint, UIVerticalDistanceConstraint, UIHorizontalProportionConstraint, UIVerticalProportionConstraint, UICoverConstraintBuilder, UIFitConstraintBuilder
|
|
251
127
|
|
|
252
|
-
|
|
128
|
+
### Particles (laymur/particles)
|
|
253
129
|
|
|
254
|
-
|
|
255
|
-
- **NPM**: [https://www.npmjs.com/package/laymur-animations](https://www.npmjs.com/package/laymur-animations)
|
|
130
|
+
UIEmitter, UISpawnRectangle, UISpawnRandomLifetime, UIBehaviorDirectionalGravity, UIBehaviorVelocityDamping, UIRenderingTexture, UIRenderingColorOverLife
|
|
256
131
|
|
|
257
|
-
##
|
|
132
|
+
## Entry Points
|
|
258
133
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
134
|
+
```json
|
|
135
|
+
// package.json
|
|
136
|
+
"exports": {
|
|
137
|
+
".": "./dist/index.js",
|
|
138
|
+
"./particles": "./dist/particles/index.js"
|
|
139
|
+
}
|
|
140
|
+
```
|
|
263
141
|
|
|
264
142
|
## License
|
|
265
143
|
|
|
266
|
-
MIT ©
|
|
267
|
-
|
|
268
|
-
Uses [Kiwi.js](https://github.com/lume/kiwi) (BSD-3-Clause) for constraint solving and [Three.js](https://threejs.org/) (MIT) for 3D rendering.
|
|
144
|
+
MIT © jango
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
|
|
2
|
+
import { UIExpression } from '../../miscellaneous/UIExpression.js';
|
|
3
|
+
import { UISingleParameterConstraint } from '../UISingleParameterConstraint/UISingleParameterConstraint.js';
|
|
4
|
+
|
|
5
|
+
/** Maintains element aspect ratio (width = height * aspect) */
|
|
6
|
+
class UIAspectConstraint extends UISingleParameterConstraint {
|
|
7
|
+
/**
|
|
8
|
+
* @param element Element to constrain
|
|
9
|
+
* @param options Aspect configuration. Defaults to element's current ratio.
|
|
10
|
+
*/
|
|
11
|
+
constructor(_private_element, options = {}) {
|
|
12
|
+
if (options.aspect !== undefined) {
|
|
13
|
+
assertValidPositiveNumber(options.aspect, "UIAspectConstraint.constructor.options.aspect");
|
|
14
|
+
}
|
|
15
|
+
super(_private_element.layer, options);
|
|
16
|
+
this._private_element = _private_element;
|
|
17
|
+
this._private_aspectInternal = options.aspect ?? _private_element.width / _private_element.height;
|
|
18
|
+
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
19
|
+
}
|
|
20
|
+
/** Current aspect ratio (width/height) */
|
|
21
|
+
get aspect() {
|
|
22
|
+
return this._private_aspectInternal;
|
|
23
|
+
}
|
|
24
|
+
/** Updates aspect ratio */
|
|
25
|
+
set aspect(value) {
|
|
26
|
+
assertValidPositiveNumber(value, "UIAspectConstraint.aspect");
|
|
27
|
+
if (this._private_aspectInternal !== value) {
|
|
28
|
+
this._private_aspectInternal = value;
|
|
29
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Builds constraint expression: width - (height * aspect) = 0 */
|
|
33
|
+
_private_buildLHS() {
|
|
34
|
+
return new UIExpression(0, [
|
|
35
|
+
[this._private_element.wVariable, 1],
|
|
36
|
+
[this._private_element.hVariable, -this._private_aspectInternal],
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { UIAspectConstraint };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { UILayer } from "../layers/UILayer/UILayer";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UISolverWrapperView } from "../wrappers/UISolverWrapper/UISolverWrapper.Internal";
|
|
3
3
|
/** Base class for layout constraints */
|
|
4
4
|
export declare abstract class UIConstraint {
|
|
5
5
|
readonly layer: UILayer;
|
|
6
6
|
/** Optional constraint name */
|
|
7
7
|
name: string;
|
|
8
8
|
/** Constraint solver wrapper */
|
|
9
|
-
protected readonly solverWrapper:
|
|
9
|
+
protected readonly solverWrapper: UISolverWrapperView;
|
|
10
10
|
/** @param layer Layer containing this constraint */
|
|
11
11
|
constructor(layer: UILayer, name?: string);
|
|
12
12
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Base class for layout constraints */
|
|
2
|
+
class UIConstraint {
|
|
3
|
+
/** @param layer Layer containing this constraint */
|
|
4
|
+
constructor(layer, name) {
|
|
5
|
+
this.layer = layer;
|
|
6
|
+
this.solverWrapper = this.layer.solverWrapper;
|
|
7
|
+
this.name = name ?? "";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { UIConstraint };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { UISingleParameterConstraint } from './UISingleParameterConstraint/UISingleParameterConstraint.js';
|
|
2
|
+
|
|
3
|
+
/** Constraint with custom LHS and RHS expressions */
|
|
4
|
+
class UICustomConstraint extends UISingleParameterConstraint {
|
|
5
|
+
/**
|
|
6
|
+
* @param layer Layer containing this constraint
|
|
7
|
+
* @param lhs Left-hand side expression
|
|
8
|
+
* @param rhs Right-hand side expression
|
|
9
|
+
* @param options Constraint configuration
|
|
10
|
+
*/
|
|
11
|
+
constructor(layer, lhs, rhs, options = {}) {
|
|
12
|
+
super(layer, options);
|
|
13
|
+
this._private_lhsInternal = lhs;
|
|
14
|
+
this._private_rhsInternal = rhs;
|
|
15
|
+
this.constraint = this.solverWrapper.createConstraint(this._private_lhsInternal, this._private_rhsInternal, this.relation, this.priority, this.isConstraintEnabled());
|
|
16
|
+
}
|
|
17
|
+
/** Left-hand side expression */
|
|
18
|
+
get lhs() {
|
|
19
|
+
return this._private_lhsInternal;
|
|
20
|
+
}
|
|
21
|
+
/** Right-hand side expression */
|
|
22
|
+
get rhs() {
|
|
23
|
+
return this._private_rhsInternal;
|
|
24
|
+
}
|
|
25
|
+
/** Updates left-hand side expression */
|
|
26
|
+
setLHS(value) {
|
|
27
|
+
this._private_lhsInternal = value;
|
|
28
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_lhsInternal);
|
|
29
|
+
}
|
|
30
|
+
/** Updates right-hand side expression */
|
|
31
|
+
setRHS(value) {
|
|
32
|
+
this._private_rhsInternal = value;
|
|
33
|
+
this.solverWrapper.setConstraintRHS(this.constraint, this._private_rhsInternal);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { UICustomConstraint };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
|
|
2
|
+
import { UIExpression } from '../../miscellaneous/UIExpression.js';
|
|
3
|
+
import { UISingleParameterConstraint } from '../UISingleParameterConstraint/UISingleParameterConstraint.js';
|
|
4
|
+
|
|
5
|
+
/** Fixes element height to constant value */
|
|
6
|
+
class UIHeightConstraint extends UISingleParameterConstraint {
|
|
7
|
+
/**
|
|
8
|
+
* @param element Element to constrain
|
|
9
|
+
* @param options Height configuration. Defaults to element's current height.
|
|
10
|
+
*/
|
|
11
|
+
constructor(_private_element, options = {}) {
|
|
12
|
+
if (options.height !== undefined) {
|
|
13
|
+
assertValidPositiveNumber(options.height, "UIHeightConstraint.constructor.options.height");
|
|
14
|
+
}
|
|
15
|
+
super(_private_element.layer, options);
|
|
16
|
+
this._private_element = _private_element;
|
|
17
|
+
this._private_heightInternal = options.height ?? _private_element.height;
|
|
18
|
+
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this._private_element.hVariable, 1]]), new UIExpression(this._private_heightInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
19
|
+
}
|
|
20
|
+
/** Current height in world units */
|
|
21
|
+
get height() {
|
|
22
|
+
return this._private_heightInternal;
|
|
23
|
+
}
|
|
24
|
+
/** Updates height */
|
|
25
|
+
set height(value) {
|
|
26
|
+
assertValidPositiveNumber(value, "UIHeightConstraint.height");
|
|
27
|
+
if (this._private_heightInternal !== value) {
|
|
28
|
+
this._private_heightInternal = value;
|
|
29
|
+
this.solverWrapper.setConstraintRHS(this.constraint, new UIExpression(value));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { UIHeightConstraint };
|
package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { assertValidNumber, assertValidConstraintArguments } from '../../miscellaneous/asserts.js';
|
|
2
|
+
import { isUIPlaneElement, isUIPointElement } from '../../miscellaneous/shared.js';
|
|
3
|
+
import { UIExpression } from '../../miscellaneous/UIExpression.js';
|
|
4
|
+
import { UISingleParameterConstraint } from '../UISingleParameterConstraint/UISingleParameterConstraint.js';
|
|
5
|
+
import { DEFAULT_ANCHOR } from './UIHorizontalDistanceConstraint.Internal.js';
|
|
6
|
+
|
|
7
|
+
/** Maintains horizontal distance between elements with configurable anchors */
|
|
8
|
+
class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
9
|
+
/**
|
|
10
|
+
* @param a First element
|
|
11
|
+
* @param b Second element
|
|
12
|
+
* @param options Distance configuration
|
|
13
|
+
*/
|
|
14
|
+
constructor(_private_a, _private_b, options = {}) {
|
|
15
|
+
if (options.anchorA !== undefined) {
|
|
16
|
+
assertValidNumber(options.anchorA, "UIHorizontalDistanceConstraint.constructor.options.anchorA");
|
|
17
|
+
}
|
|
18
|
+
if (options.anchorB !== undefined) {
|
|
19
|
+
assertValidNumber(options.anchorB, "UIHorizontalDistanceConstraint.constructor.options.anchorB");
|
|
20
|
+
}
|
|
21
|
+
if (options.distance !== undefined) {
|
|
22
|
+
assertValidNumber(options.distance, "UIHorizontalDistanceConstraint.constructor.options.distance");
|
|
23
|
+
}
|
|
24
|
+
super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalDistanceConstraint.constructor"), options);
|
|
25
|
+
this._private_a = _private_a;
|
|
26
|
+
this._private_b = _private_b;
|
|
27
|
+
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;
|
|
28
|
+
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;
|
|
29
|
+
this._private_distanceInternal = options.distance ?? 0;
|
|
30
|
+
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
31
|
+
}
|
|
32
|
+
/** Current distance in world units */
|
|
33
|
+
get distance() {
|
|
34
|
+
return this._private_distanceInternal;
|
|
35
|
+
}
|
|
36
|
+
/** Anchor on element A (0 = left, 0.5 = center, 1 = right) */
|
|
37
|
+
get anchorA() {
|
|
38
|
+
return this._private_anchorAInternal;
|
|
39
|
+
}
|
|
40
|
+
/** Anchor on element B (0 = left, 0.5 = center, 1 = right) */
|
|
41
|
+
get anchorB() {
|
|
42
|
+
return this._private_anchorBInternal;
|
|
43
|
+
}
|
|
44
|
+
/** Updates distance */
|
|
45
|
+
set distance(value) {
|
|
46
|
+
assertValidNumber(value, "UIHorizontalDistanceConstraint.distance");
|
|
47
|
+
if (this._private_distanceInternal !== value) {
|
|
48
|
+
this._private_distanceInternal = value;
|
|
49
|
+
this.solverWrapper.setConstraintRHS(this.constraint, new UIExpression(this._private_distanceInternal));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Updates anchor on element A */
|
|
53
|
+
set anchorA(value) {
|
|
54
|
+
assertValidNumber(value, "UIHorizontalDistanceConstraint.anchorA");
|
|
55
|
+
if (this._private_anchorAInternal !== value) {
|
|
56
|
+
this._private_anchorAInternal = value;
|
|
57
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Updates anchor on element B */
|
|
61
|
+
set anchorB(value) {
|
|
62
|
+
assertValidNumber(value, "UIHorizontalDistanceConstraint.anchorB");
|
|
63
|
+
if (this._private_anchorBInternal !== value) {
|
|
64
|
+
this._private_anchorBInternal = value;
|
|
65
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Builds constraint expression for distance between anchored positions */
|
|
69
|
+
_private_buildLHS() {
|
|
70
|
+
let aExpression;
|
|
71
|
+
let bExpression;
|
|
72
|
+
if (isUIPlaneElement(this._private_a)) {
|
|
73
|
+
aExpression = new UIExpression(0, [
|
|
74
|
+
[this._private_a.xVariable, 1],
|
|
75
|
+
[this._private_a.wVariable, this._private_anchorAInternal],
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
else if (isUIPointElement(this._private_a)) {
|
|
79
|
+
aExpression = new UIExpression().plus(this._private_a.xVariable, 1);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
throw new Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");
|
|
83
|
+
}
|
|
84
|
+
if (isUIPlaneElement(this._private_b)) {
|
|
85
|
+
bExpression = new UIExpression(0, [
|
|
86
|
+
[this._private_b.xVariable, 1],
|
|
87
|
+
[this._private_b.wVariable, this._private_anchorBInternal],
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
else if (isUIPointElement(this._private_b)) {
|
|
91
|
+
bExpression = new UIExpression().plus(this._private_b.xVariable, 1);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw new Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");
|
|
95
|
+
}
|
|
96
|
+
return UIExpression.minus(bExpression, aExpression);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { UIHorizontalDistanceConstraint };
|