laymur 0.15.1 → 0.17.0
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/.claude/settings.local.json +9 -0
- package/.editorconfig +14 -0
- package/CLAUDE.md +181 -0
- package/README.md +84 -208
- package/assets/logotype.png +0 -0
- package/eslint.config.js +111 -0
- package/package.json +20 -36
- package/rollup.config.js +52 -0
- package/{dist/constraints/UIAspectConstraint/UIAspectConstraint.Internal.d.ts → src/core/constraints/UIAspectConstraint/UIAspectConstraint.Internal.ts} +3 -2
- package/src/core/constraints/UIAspectConstraint/UIAspectConstraint.ts +60 -0
- package/src/core/constraints/UIConstraint.ts +20 -0
- package/src/core/constraints/UICustomConstraint.ts +62 -0
- package/{dist/constraints/UIHeightConstraint/UIHeightConstraint.Internal.d.ts → src/core/constraints/UIHeightConstraint/UIHeightConstraint.Internal.ts} +3 -2
- package/src/core/constraints/UIHeightConstraint/UIHeightConstraint.ts +52 -0
- package/src/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.ts +13 -0
- package/src/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.ts +139 -0
- package/src/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.ts +16 -0
- package/src/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.ts +189 -0
- package/{dist/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts → src/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.ts} +3 -2
- package/src/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.ts +68 -0
- package/{dist/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts → src/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.ts} +9 -8
- package/src/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.ts +94 -0
- package/src/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.ts +13 -0
- package/src/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.ts +135 -0
- package/src/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.ts +16 -0
- package/src/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.ts +189 -0
- package/{dist/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts → src/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.ts} +3 -2
- package/src/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.ts +68 -0
- package/{dist/constraints/UIWidthConstraint/UIWidthConstraint.Internal.d.ts → src/core/constraints/UIWidthConstraint/UIWidthConstraint.Internal.ts} +3 -2
- package/src/core/constraints/UIWidthConstraint/UIWidthConstraint.ts +52 -0
- package/src/core/constraints/builders/UIConstraint2DBuilder.Internal.ts +84 -0
- package/src/core/constraints/builders/UIConstraint2DBuilder.ts +168 -0
- package/src/core/constraints/builders/UICoverConstraintBuilder.Internal.ts +15 -0
- package/src/core/constraints/builders/UICoverConstraintBuilder.ts +84 -0
- package/src/core/constraints/builders/UIFitConstraintBuilder.Internal.ts +15 -0
- package/src/core/constraints/builders/UIFitConstraintBuilder.ts +84 -0
- package/src/core/elements/UIAnchor/UIAnchor.Internal.ts +13 -0
- package/src/core/elements/UIAnchor/UIAnchor.ts +70 -0
- package/src/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.ts +30 -0
- package/src/core/elements/UIAnimatedImage/UIAnimatedImage.ts +355 -0
- package/src/core/elements/UIDummy/UIDummy.Internal.ts +33 -0
- package/src/core/elements/UIDummy/UIDummy.ts +244 -0
- package/src/core/elements/UIElement/UIElement.Internal.ts +13 -0
- package/src/core/elements/UIElement/UIElement.ts +127 -0
- package/{dist/elements/UIGraphics/UIGraphics.Internal.d.ts → src/core/elements/UIGraphics/UIGraphics.Internal.ts} +7 -5
- package/src/core/elements/UIGraphics/UIGraphics.ts +168 -0
- package/{dist/elements/UIImage/UIImage.Internal.d.ts → src/core/elements/UIImage/UIImage.Internal.ts} +3 -2
- package/src/core/elements/UIImage/UIImage.ts +138 -0
- package/src/core/elements/UINineSlice/UINineSlice.Internal.ts +26 -0
- package/src/core/elements/UINineSlice/UINineSlice.ts +296 -0
- package/src/core/elements/UIProgress/UIProgress.Internal.ts +24 -0
- package/src/core/elements/UIProgress/UIProgress.ts +259 -0
- package/src/core/elements/UIScene/UIScene.Internal.ts +46 -0
- package/src/core/elements/UIScene/UIScene.ts +259 -0
- package/{dist/elements/UIText/UIText.Interfaces.d.ts → src/core/elements/UIText/UIText.Interfaces.ts} +21 -16
- package/src/core/elements/UIText/UIText.Internal.ts +29 -0
- package/src/core/elements/UIText/UIText.Measuring.ts +183 -0
- package/src/core/elements/UIText/UIText.Rendering.ts +83 -0
- package/src/core/elements/UIText/UIText.ts +376 -0
- package/{dist/index.d.ts → src/core/index.ts} +2 -1
- package/{dist/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts → src/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.ts} +14 -11
- package/src/core/layers/UIFullscreenLayer/UIFullscreenLayer.ts +233 -0
- package/{dist/layers/UILayer/UILayer.Internal.d.ts → src/core/layers/UILayer/UILayer.Internal.ts} +15 -11
- package/src/core/layers/UILayer/UILayer.ts +156 -0
- package/src/core/miscellaneous/UIExpression.ts +142 -0
- package/src/core/miscellaneous/UIMode.ts +29 -0
- package/src/core/miscellaneous/UIOrientation.ts +18 -0
- package/src/core/miscellaneous/UIPriority.ts +63 -0
- package/src/core/miscellaneous/UIRelation.ts +39 -0
- package/src/core/miscellaneous/UITransparencyMode.ts +9 -0
- package/src/core/miscellaneous/area/UIArea.ts +5 -0
- package/src/core/miscellaneous/area/UIAreaCircle.ts +32 -0
- package/src/core/miscellaneous/area/UIAreaPolygon.ts +50 -0
- package/src/core/miscellaneous/area/UIAreaRectangle.ts +38 -0
- package/src/core/miscellaneous/area/UIAreaRoundedRectangle.ts +78 -0
- package/src/core/miscellaneous/asserts.ts +187 -0
- package/src/core/miscellaneous/canvas.ts +73 -0
- package/src/core/miscellaneous/color/UIColor.Internal.ts +89 -0
- package/src/core/miscellaneous/color/UIColor.ts +844 -0
- package/src/core/miscellaneous/computeTransform.ts +127 -0
- package/src/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.ts +235 -0
- package/src/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.ts +524 -0
- package/{dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts → src/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.ts} +10 -8
- package/src/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.ts +448 -0
- package/src/core/miscellaneous/generic-plane/shared.ts +323 -0
- package/src/core/miscellaneous/insets/UIInsets.Internal.ts +9 -0
- package/src/core/miscellaneous/insets/UIInsets.ts +248 -0
- package/src/core/miscellaneous/mask-function/UIProgressMaskFunction.ts +24 -0
- package/src/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.ts +58 -0
- package/src/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.ts +52 -0
- package/src/core/miscellaneous/math.ts +16 -0
- package/src/core/miscellaneous/micro/UIMicro.Internal.ts +33 -0
- package/src/core/miscellaneous/micro/UIMicro.ts +222 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicy.ts +8 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyCover.ts +57 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyCross.ts +65 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.ts +65 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyFit.ts +57 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.ts +65 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.ts +65 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyNone.ts +11 -0
- package/src/core/miscellaneous/shared.ts +73 -0
- package/{dist/miscellaneous/text-span/UITextSpan.Internal.d.ts → src/core/miscellaneous/text-span/UITextSpan.Internal.ts} +5 -4
- package/src/core/miscellaneous/text-span/UITextSpan.ts +43 -0
- package/src/core/miscellaneous/text-style/UITextStyle.Internal.ts +52 -0
- package/src/core/miscellaneous/text-style/UITextStyle.ts +479 -0
- package/src/core/miscellaneous/texture/UITextureView.Internal.ts +55 -0
- package/src/core/miscellaneous/texture/UITextureView.ts +308 -0
- package/src/core/miscellaneous/webglCapabilities.ts +129 -0
- package/src/core/shaders/UIImage.glsl +10 -0
- package/src/core/shaders/UINineSlice.glsl +53 -0
- package/src/core/shaders/UIProgress.glsl +15 -0
- package/src/core/shaders/UIProgressMaskFunctionCircular.glsl +13 -0
- package/src/core/shaders/UIProgressMaskFunctionDirectional.glsl +12 -0
- package/src/core/shaders/glsl.d.ts +27 -0
- package/src/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.ts +23 -0
- package/src/core/wrappers/UIInputWrapper/UIInputWrapper.ts +124 -0
- package/src/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.ts +22 -0
- package/src/core/wrappers/UISceneWrapper/UISceneWrapper.ts +101 -0
- package/src/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.ts +58 -0
- package/src/core/wrappers/UISolverWrapper/UISolverWrapper.ts +605 -0
- package/src/particles/behaviorModules/UIBehaviorDirectionalGravity.ts +70 -0
- package/src/particles/behaviorModules/UIBehaviorModule.ts +20 -0
- package/src/particles/behaviorModules/UIBehaviorPointGravity.ts +173 -0
- package/src/particles/behaviorModules/UIBehaviorScaleOverLife.ts +104 -0
- package/src/particles/behaviorModules/UIBehaviorTorqueDamping.ts +75 -0
- package/src/particles/behaviorModules/UIBehaviorTorqueNoise.ts +115 -0
- package/src/particles/behaviorModules/UIBehaviorVelocityDamping.ts +77 -0
- package/src/particles/behaviorModules/UIBehaviorVelocityNoise.ts +118 -0
- package/src/particles/elements/UIEmitter.Internal.ts +22 -0
- package/src/particles/elements/UIEmitter.ts +313 -0
- package/src/particles/index.ts +18 -0
- package/src/particles/instancedParticle/UIInstancedParticle.Internal.ts +263 -0
- package/src/particles/instancedParticle/UIInstancedParticle.ts +138 -0
- package/src/particles/miscellaneous/miscellaneous.ts +115 -0
- package/src/particles/renderingModules/UIRenderingColorOverLife.ts +39 -0
- package/src/particles/renderingModules/UIRenderingColorOverVelocity.ts +49 -0
- package/src/particles/renderingModules/UIRenderingModule.ts +17 -0
- package/src/particles/renderingModules/UIRenderingTexture.ts +30 -0
- package/src/particles/shaders/UIRenderingColorOverLife.glsl +4 -0
- package/src/particles/shaders/UIRenderingColorOverVelocity.glsl +6 -0
- package/src/particles/shaders/UIRenderingTexture.glsl +4 -0
- package/src/particles/spawnModules/UISpawnModule.ts +22 -0
- package/src/particles/spawnModules/UISpawnOffset.ts +62 -0
- package/src/particles/spawnModules/UISpawnRandomLifetime.ts +68 -0
- package/src/particles/spawnModules/UISpawnRandomRotation.ts +60 -0
- package/src/particles/spawnModules/UISpawnRandomScale.ts +81 -0
- package/src/particles/spawnModules/UISpawnRandomTorque.ts +62 -0
- package/src/particles/spawnModules/UISpawnRandomVelocity.ts +92 -0
- package/src/particles/spawnModules/UISpawnRectangle.ts +81 -0
- package/tsconfig.json +29 -0
- package/dist/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +0 -22
- package/dist/constraints/UIConstraint.d.ts +0 -12
- package/dist/constraints/UICustomConstraint.d.ts +0 -28
- package/dist/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +0 -20
- package/dist/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +0 -11
- package/dist/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +0 -36
- package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +0 -14
- package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +0 -44
- package/dist/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +0 -22
- package/dist/constraints/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +0 -43
- package/dist/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +0 -11
- package/dist/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +0 -32
- package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +0 -14
- package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +0 -44
- package/dist/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +0 -22
- package/dist/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +0 -20
- package/dist/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +0 -64
- package/dist/constraints/builders/UIConstraint2DBuilder.d.ts +0 -46
- package/dist/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +0 -13
- package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +0 -29
- package/dist/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +0 -13
- package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +0 -29
- package/dist/elements/UIAnchor/UIAnchor.Internal.d.ts +0 -9
- package/dist/elements/UIAnchor/UIAnchor.d.ts +0 -32
- package/dist/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -27
- package/dist/elements/UIAnimatedImage/UIAnimatedImage.d.ts +0 -77
- package/dist/elements/UIElement/UIElement.Internal.d.ts +0 -11
- package/dist/elements/UIElement/UIElement.d.ts +0 -38
- package/dist/elements/UIGraphics/UIGraphics.d.ts +0 -51
- package/dist/elements/UIImage/UIImage.d.ts +0 -32
- package/dist/elements/UIInputDummy/UIInputDummy.Internal.d.ts +0 -30
- package/dist/elements/UIInputDummy/UIInputDummy.d.ts +0 -82
- package/dist/elements/UINineSlice/UINineSlice.Internal.d.ts +0 -23
- package/dist/elements/UINineSlice/UINineSlice.d.ts +0 -60
- package/dist/elements/UIProgress/UIProgress.Internal.d.ts +0 -14
- package/dist/elements/UIProgress/UIProgress.d.ts +0 -45
- package/dist/elements/UIScene/UIScene.Internal.d.ts +0 -43
- package/dist/elements/UIScene/UIScene.d.ts +0 -59
- package/dist/elements/UIText/UIText.Internal.d.ts +0 -26
- package/dist/elements/UIText/UIText.Measuring.d.ts +0 -50
- package/dist/elements/UIText/UIText.Rendering.d.ts +0 -20
- package/dist/elements/UIText/UIText.d.ts +0 -71
- package/dist/index.js +0 -9236
- package/dist/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -63
- package/dist/layers/UILayer/UILayer.d.ts +0 -49
- package/dist/miscellaneous/UIExpression.d.ts +0 -69
- package/dist/miscellaneous/UIMode.d.ts +0 -23
- package/dist/miscellaneous/UIOrientation.d.ts +0 -15
- package/dist/miscellaneous/UIPriority.d.ts +0 -32
- package/dist/miscellaneous/UIRelation.d.ts +0 -23
- package/dist/miscellaneous/UITransparencyMode.d.ts +0 -9
- package/dist/miscellaneous/area/UIArea.d.ts +0 -3
- package/dist/miscellaneous/area/UIAreaCircle.d.ts +0 -15
- package/dist/miscellaneous/area/UIAreaPolygon.d.ts +0 -12
- package/dist/miscellaneous/area/UIAreaRectangle.d.ts +0 -17
- package/dist/miscellaneous/area/UIAreaRoundedRectangle.d.ts +0 -21
- package/dist/miscellaneous/asserts.d.ts +0 -43
- package/dist/miscellaneous/canvas.d.ts +0 -31
- package/dist/miscellaneous/color/UIColor.Internal.d.ts +0 -7
- package/dist/miscellaneous/color/UIColor.d.ts +0 -234
- package/dist/miscellaneous/computeTransform.d.ts +0 -18
- package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +0 -19
- package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +0 -1
- package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +0 -1
- package/dist/miscellaneous/generic-plane/shared.d.ts +0 -38
- package/dist/miscellaneous/insets/UIInsets.Internal.d.ts +0 -11
- package/dist/miscellaneous/insets/UIInsets.d.ts +0 -48
- package/dist/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +0 -9
- package/dist/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +0 -21
- package/dist/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +0 -16
- package/dist/miscellaneous/math.d.ts +0 -5
- package/dist/miscellaneous/micro/UIMicro.Internal.d.ts +0 -31
- package/dist/miscellaneous/micro/UIMicro.d.ts +0 -59
- package/dist/miscellaneous/resize-policy/UIResizePolicy.d.ts +0 -3
- package/dist/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +0 -5
- package/dist/miscellaneous/shared.d.ts +0 -46
- package/dist/miscellaneous/text-span/UITextSpan.d.ts +0 -14
- package/dist/miscellaneous/text-style/UITextStyle.Internal.d.ts +0 -48
- package/dist/miscellaneous/text-style/UITextStyle.d.ts +0 -85
- package/dist/miscellaneous/texture/UITextureView.Internal.d.ts +0 -49
- package/dist/miscellaneous/texture/UITextureView.d.ts +0 -67
- package/dist/miscellaneous/webglCapabilities.d.ts +0 -2
- package/dist/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +0 -17
- package/dist/wrappers/UIInputWrapper/UIInputWrapper.d.ts +0 -13
- package/dist/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +0 -13
- package/dist/wrappers/UISceneWrapper/UISceneWrapper.d.ts +0 -20
- package/dist/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +0 -49
- package/dist/wrappers/UISolverWrapper/UISolverWrapper.d.ts +0 -215
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { assertValidPositiveNumber } from "../asserts";
|
|
2
|
+
import { UIResizePolicy } from "./UIResizePolicy";
|
|
3
|
+
|
|
4
|
+
/** Scales by width with orientation-specific targets */
|
|
5
|
+
export class UIResizePolicyFixedWidth extends UIResizePolicy {
|
|
6
|
+
private fixedWidthLandscapeInternal: number;
|
|
7
|
+
private fixedWidthPortraitInternal: number;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates fixed width resize policy.
|
|
11
|
+
*
|
|
12
|
+
* @param fixedWidthLandscape - Target width when landscape
|
|
13
|
+
* @param fixedWidthPortrait - Target width when portrait
|
|
14
|
+
*/
|
|
15
|
+
constructor(fixedWidthLandscape: number, fixedWidthPortrait: number) {
|
|
16
|
+
super();
|
|
17
|
+
assertValidPositiveNumber(
|
|
18
|
+
fixedWidthLandscape,
|
|
19
|
+
"UIResizePolicyFixedWidth.constructor.fixedWidthLandscape",
|
|
20
|
+
);
|
|
21
|
+
assertValidPositiveNumber(
|
|
22
|
+
fixedWidthPortrait,
|
|
23
|
+
"UIResizePolicyFixedWidth.constructor.fixedWidthPortrait",
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
this.fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
27
|
+
this.fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Target width when landscape */
|
|
31
|
+
public get fixedWidthLandscape(): number {
|
|
32
|
+
return this.fixedWidthLandscapeInternal;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Target width when portrait */
|
|
36
|
+
public get fixedWidthPortrait(): number {
|
|
37
|
+
return this.fixedWidthPortraitInternal;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Target width when landscape */
|
|
41
|
+
public set fixedWidthLandscape(value: number) {
|
|
42
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
43
|
+
if (value !== this.fixedWidthLandscapeInternal) {
|
|
44
|
+
this.fixedWidthLandscapeInternal = value;
|
|
45
|
+
this.dirty = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Target width when portrait */
|
|
50
|
+
public set fixedWidthPortrait(value: number) {
|
|
51
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
52
|
+
if (value !== this.fixedWidthPortraitInternal) {
|
|
53
|
+
this.fixedWidthPortraitInternal = value;
|
|
54
|
+
this.dirty = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public calculateScale(width: number, height: number): number {
|
|
59
|
+
assertValidPositiveNumber(width, "UIResizePolicyFixedWidth.calculateScale.width");
|
|
60
|
+
assertValidPositiveNumber(height, "UIResizePolicyFixedWidth.calculateScale.height");
|
|
61
|
+
return width > height
|
|
62
|
+
? this.fixedWidthLandscapeInternal / width
|
|
63
|
+
: this.fixedWidthPortraitInternal / width;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { assertValidPositiveNumber } from "../asserts";
|
|
2
|
+
import { UIResizePolicy } from "./UIResizePolicy";
|
|
3
|
+
|
|
4
|
+
/** No scaling. Always returns 1. */
|
|
5
|
+
export class UIResizePolicyNone extends UIResizePolicy {
|
|
6
|
+
public calculateScale(width: number, height: number): number {
|
|
7
|
+
assertValidPositiveNumber(width, "UIResizePolicyNone.calculateScale.width");
|
|
8
|
+
assertValidPositiveNumber(height, "UIResizePolicyNone.calculateScale.height");
|
|
9
|
+
return 1;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { UILayer } from "../layers/UILayer/UILayer";
|
|
2
|
+
|
|
3
|
+
/** Objects that belong to a UI layer */
|
|
4
|
+
export interface UILayerElement {
|
|
5
|
+
/** The UI layer containing this element */
|
|
6
|
+
readonly layer: UILayer;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** UI elements with position in 2D space */
|
|
10
|
+
export interface UIPointElement {
|
|
11
|
+
/** Solver variable for x coordinate */
|
|
12
|
+
readonly xVariable: number;
|
|
13
|
+
/** Solver variable for y coordinate */
|
|
14
|
+
readonly yVariable: number;
|
|
15
|
+
|
|
16
|
+
/** X coordinate in world units */
|
|
17
|
+
readonly x: number;
|
|
18
|
+
/** Y coordinate in world units */
|
|
19
|
+
readonly y: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** UI elements with position and dimensions */
|
|
23
|
+
export interface UIPlaneElement extends UIPointElement {
|
|
24
|
+
/** Solver variable for width */
|
|
25
|
+
readonly wVariable: number;
|
|
26
|
+
/** Solver variable for height */
|
|
27
|
+
readonly hVariable: number;
|
|
28
|
+
|
|
29
|
+
/** Width in world units */
|
|
30
|
+
readonly width: number;
|
|
31
|
+
/** Height in world units */
|
|
32
|
+
readonly height: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Checks if object implements UILayerElement.
|
|
37
|
+
* @param obj Object to check
|
|
38
|
+
* @returns True if object has valid layer property
|
|
39
|
+
*/
|
|
40
|
+
export function isUILayerElement(obj: unknown): obj is UILayerElement {
|
|
41
|
+
return typeof obj === "object" && obj !== null && "layer" in obj && obj.layer instanceof UILayer;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Checks if object implements UIPointElement.
|
|
46
|
+
* @param obj Object to check
|
|
47
|
+
* @returns True if object has valid position variables
|
|
48
|
+
*/
|
|
49
|
+
export function isUIPointElement(obj: unknown): obj is UIPointElement {
|
|
50
|
+
return (
|
|
51
|
+
typeof obj === "object" &&
|
|
52
|
+
obj !== null &&
|
|
53
|
+
typeof (obj as UIPointElement).xVariable === "number" &&
|
|
54
|
+
typeof (obj as UIPointElement).yVariable === "number" &&
|
|
55
|
+
typeof (obj as UIPointElement).x === "number" &&
|
|
56
|
+
typeof (obj as UIPointElement).y === "number"
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Checks if object implements UIPlaneElement.
|
|
62
|
+
* @param obj Object to check
|
|
63
|
+
* @returns True if object has valid dimension variables
|
|
64
|
+
*/
|
|
65
|
+
export function isUIPlaneElement(obj: unknown): obj is UIPlaneElement {
|
|
66
|
+
return (
|
|
67
|
+
isUIPointElement(obj) &&
|
|
68
|
+
typeof (obj as UIPlaneElement).wVariable === "number" &&
|
|
69
|
+
typeof (obj as UIPlaneElement).hVariable === "number" &&
|
|
70
|
+
typeof (obj as UIPlaneElement).width === "number" &&
|
|
71
|
+
typeof (obj as UIPlaneElement).height === "number"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { UITextStyleConfig } from "../text-style/UITextStyle.Internal";
|
|
2
|
+
|
|
2
3
|
/** Configuration for creating a text span */
|
|
3
4
|
export interface UITextSpanConfig {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/** Text content */
|
|
6
|
+
text: string;
|
|
7
|
+
/** Style properties */
|
|
8
|
+
style?: Partial<UITextStyleConfig>;
|
|
8
9
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { UITextStyle } from "../text-style/UITextStyle";
|
|
2
|
+
import type { UITextSpanConfig } from "./UITextSpan.Internal";
|
|
3
|
+
|
|
4
|
+
/** Text span with associated style */
|
|
5
|
+
export class UITextSpan {
|
|
6
|
+
/** Text style */
|
|
7
|
+
public style: UITextStyle;
|
|
8
|
+
private textInternal: string;
|
|
9
|
+
private dirtyInternal = true;
|
|
10
|
+
|
|
11
|
+
/** @param config Text span configuration */
|
|
12
|
+
constructor(config: UITextSpanConfig) {
|
|
13
|
+
this.textInternal = config.text;
|
|
14
|
+
this.style = new UITextStyle(config.style);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Text content */
|
|
18
|
+
public get text(): string {
|
|
19
|
+
return this.textInternal;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Indicates whether text or style has been modified.
|
|
24
|
+
* Must be reset to `false` externally by the owner.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
public get dirty(): boolean {
|
|
28
|
+
return this.dirtyInternal || this.style.dirty;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public set text(value: string) {
|
|
32
|
+
if (value !== this.textInternal) {
|
|
33
|
+
this.textInternal = value;
|
|
34
|
+
this.dirtyInternal = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @internal */
|
|
39
|
+
public setDirtyFalse(): void {
|
|
40
|
+
this.dirtyInternal = false;
|
|
41
|
+
this.style.setDirtyFalse();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Complete text style configuration with all properties resolved */
|
|
2
|
+
export interface UITextStyleConfig {
|
|
3
|
+
/** Text color */
|
|
4
|
+
color: string;
|
|
5
|
+
/** Text alignment */
|
|
6
|
+
align: "left" | "center" | "right";
|
|
7
|
+
|
|
8
|
+
/** Font family name */
|
|
9
|
+
fontFamily: string;
|
|
10
|
+
/** Font size in pixels */
|
|
11
|
+
fontSize: number;
|
|
12
|
+
/** Font style */
|
|
13
|
+
fontStyle: "normal" | "italic" | "oblique";
|
|
14
|
+
/** Font weight */
|
|
15
|
+
fontWeight: "normal" | "bold" | "bolder" | "lighter" | number;
|
|
16
|
+
/** Line height in pixels */
|
|
17
|
+
lineHeight: number;
|
|
18
|
+
|
|
19
|
+
/** Whether shadow is enabled */
|
|
20
|
+
enableShadow: boolean;
|
|
21
|
+
/** Shadow horizontal offset in pixels */
|
|
22
|
+
shadowOffsetX: number;
|
|
23
|
+
/** Shadow vertical offset in pixels */
|
|
24
|
+
shadowOffsetY: number;
|
|
25
|
+
/** Shadow blur radius in pixels */
|
|
26
|
+
shadowBlur: number;
|
|
27
|
+
/** Shadow color */
|
|
28
|
+
shadowColor: string;
|
|
29
|
+
|
|
30
|
+
/** Whether stroke is enabled */
|
|
31
|
+
enableStroke: boolean;
|
|
32
|
+
/** Stroke color */
|
|
33
|
+
strokeColor: string;
|
|
34
|
+
/** Stroke thickness in pixels */
|
|
35
|
+
strokeThickness: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const TEXT_STYLE_DEFAULT_COLOR = "#000000";
|
|
39
|
+
export const TEXT_STYLE_DEFAULT_ALIGN = "left" as const;
|
|
40
|
+
export const TEXT_STYLE_DEFAULT_FONT_FAMILY = "Arial";
|
|
41
|
+
export const TEXT_STYLE_DEFAULT_FONT_SIZE = 16;
|
|
42
|
+
export const TEXT_STYLE_DEFAULT_FONT_STYLE = "normal" as const;
|
|
43
|
+
export const TEXT_STYLE_DEFAULT_FONT_WEIGHT = "normal" as const;
|
|
44
|
+
export const TEXT_STYLE_DEFAULT_LINE_HEIGHT = 1.2;
|
|
45
|
+
export const TEXT_STYLE_DEFAULT_ENABLE_SHADOW = false;
|
|
46
|
+
export const TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X = 0;
|
|
47
|
+
export const TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y = 0;
|
|
48
|
+
export const TEXT_STYLE_DEFAULT_SHADOW_BLUR = 0;
|
|
49
|
+
export const TEXT_STYLE_DEFAULT_SHADOW_COLOR = "transparent";
|
|
50
|
+
export const TEXT_STYLE_DEFAULT_ENABLE_STROKE = false;
|
|
51
|
+
export const TEXT_STYLE_DEFAULT_STROKE_COLOR = "#000000";
|
|
52
|
+
export const TEXT_STYLE_DEFAULT_STROKE_THICKNESS = 0;
|