laymur 0.16.0 → 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/{dist/elements/UIElement/UIElement.Internal.d.ts → src/core/elements/UIElement/UIElement.Internal.ts} +7 -5
- 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/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/UIDummy/UIDummy.Internal.d.ts +0 -30
- package/dist/elements/UIDummy/UIDummy.d.ts +0 -82
- 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/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 -9246
- 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
- /package/{dist/index.d.ts → src/core/index.ts} +0 -0
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertValidNonNegativeNumber,
|
|
3
|
+
assertValidNumber,
|
|
4
|
+
assertValidPositiveNumber,
|
|
5
|
+
} from "../asserts";
|
|
6
|
+
import type { UITextStyleConfig } from "./UITextStyle.Internal";
|
|
7
|
+
import {
|
|
8
|
+
TEXT_STYLE_DEFAULT_ALIGN,
|
|
9
|
+
TEXT_STYLE_DEFAULT_COLOR,
|
|
10
|
+
TEXT_STYLE_DEFAULT_ENABLE_SHADOW,
|
|
11
|
+
TEXT_STYLE_DEFAULT_ENABLE_STROKE,
|
|
12
|
+
TEXT_STYLE_DEFAULT_FONT_FAMILY,
|
|
13
|
+
TEXT_STYLE_DEFAULT_FONT_SIZE,
|
|
14
|
+
TEXT_STYLE_DEFAULT_FONT_STYLE,
|
|
15
|
+
TEXT_STYLE_DEFAULT_FONT_WEIGHT,
|
|
16
|
+
TEXT_STYLE_DEFAULT_LINE_HEIGHT,
|
|
17
|
+
TEXT_STYLE_DEFAULT_SHADOW_BLUR,
|
|
18
|
+
TEXT_STYLE_DEFAULT_SHADOW_COLOR,
|
|
19
|
+
TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X,
|
|
20
|
+
TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y,
|
|
21
|
+
TEXT_STYLE_DEFAULT_STROKE_COLOR,
|
|
22
|
+
TEXT_STYLE_DEFAULT_STROKE_THICKNESS,
|
|
23
|
+
} from "./UITextStyle.Internal";
|
|
24
|
+
|
|
25
|
+
/** Text style configuration for UI text rendering */
|
|
26
|
+
export class UITextStyle {
|
|
27
|
+
private colorInternal?: string;
|
|
28
|
+
private alignInternal?: "left" | "center" | "right";
|
|
29
|
+
private fontFamilyInternal?: string;
|
|
30
|
+
private fontSizeInternal?: number;
|
|
31
|
+
private fontStyleInternal?: "normal" | "italic" | "oblique";
|
|
32
|
+
private fontWeightInternal?: "normal" | "bold" | "bolder" | "lighter" | number;
|
|
33
|
+
private lineHeightInternal?: number;
|
|
34
|
+
private enableShadowInternal?: boolean;
|
|
35
|
+
private shadowOffsetXInternal?: number;
|
|
36
|
+
private shadowOffsetYInternal?: number;
|
|
37
|
+
private shadowBlurInternal?: number;
|
|
38
|
+
private shadowColorInternal?: string;
|
|
39
|
+
private enableStrokeInternal?: boolean;
|
|
40
|
+
private strokeColorInternal?: string;
|
|
41
|
+
private strokeThicknessInternal?: number;
|
|
42
|
+
|
|
43
|
+
private dirtyInternal = true;
|
|
44
|
+
|
|
45
|
+
/** @param config Partial style configuration. Unspecified properties remain undefined. */
|
|
46
|
+
constructor(config?: Partial<UITextStyleConfig>) {
|
|
47
|
+
this.colorInternal = config?.color;
|
|
48
|
+
this.alignInternal = config?.align;
|
|
49
|
+
this.fontFamilyInternal = config?.fontFamily;
|
|
50
|
+
this.fontSizeInternal = config?.fontSize;
|
|
51
|
+
this.fontStyleInternal = config?.fontStyle;
|
|
52
|
+
this.fontWeightInternal = config?.fontWeight;
|
|
53
|
+
this.lineHeightInternal = config?.lineHeight;
|
|
54
|
+
this.enableShadowInternal = config?.enableShadow;
|
|
55
|
+
this.shadowOffsetXInternal = config?.shadowOffsetX;
|
|
56
|
+
this.shadowOffsetYInternal = config?.shadowOffsetY;
|
|
57
|
+
this.shadowBlurInternal = config?.shadowBlur;
|
|
58
|
+
this.shadowColorInternal = config?.shadowColor;
|
|
59
|
+
this.enableStrokeInternal = config?.enableStroke;
|
|
60
|
+
this.strokeColorInternal = config?.strokeColor;
|
|
61
|
+
this.strokeThicknessInternal = config?.strokeThickness;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Text color */
|
|
65
|
+
public get color(): string | undefined {
|
|
66
|
+
return this.colorInternal;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Text alignment */
|
|
70
|
+
public get align(): "left" | "center" | "right" | undefined {
|
|
71
|
+
return this.alignInternal;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Font family name */
|
|
75
|
+
public get fontFamily(): string | undefined {
|
|
76
|
+
return this.fontFamilyInternal;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Font size in pixels */
|
|
80
|
+
public get fontSize(): number | undefined {
|
|
81
|
+
return this.fontSizeInternal;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Font style */
|
|
85
|
+
public get fontStyle(): "normal" | "italic" | "oblique" | undefined {
|
|
86
|
+
return this.fontStyleInternal;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Font weight */
|
|
90
|
+
public get fontWeight(): "normal" | "bold" | "bolder" | "lighter" | number | undefined {
|
|
91
|
+
return this.fontWeightInternal;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Line height in pixels */
|
|
95
|
+
public get lineHeight(): number | undefined {
|
|
96
|
+
return this.lineHeightInternal;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Whether shadow is enabled */
|
|
100
|
+
public get enableShadow(): boolean | undefined {
|
|
101
|
+
return this.enableShadowInternal;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Shadow horizontal offset in pixels */
|
|
105
|
+
public get shadowOffsetX(): number | undefined {
|
|
106
|
+
return this.shadowOffsetXInternal;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Shadow vertical offset in pixels */
|
|
110
|
+
public get shadowOffsetY(): number | undefined {
|
|
111
|
+
return this.shadowOffsetYInternal;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Shadow blur radius in pixels */
|
|
115
|
+
public get shadowBlur(): number | undefined {
|
|
116
|
+
return this.shadowBlurInternal;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Shadow color */
|
|
120
|
+
public get shadowColor(): string | undefined {
|
|
121
|
+
return this.shadowColorInternal;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Whether stroke is enabled */
|
|
125
|
+
public get enableStroke(): boolean | undefined {
|
|
126
|
+
return this.enableStrokeInternal;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Stroke color */
|
|
130
|
+
public get strokeColor(): string | undefined {
|
|
131
|
+
return this.strokeColorInternal;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Stroke thickness in pixels */
|
|
135
|
+
public get strokeThickness(): number | undefined {
|
|
136
|
+
return this.strokeThicknessInternal;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Indicates whether any property has been modified.
|
|
141
|
+
* Must be reset to `false` externally by the owner.
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
public get dirty(): boolean {
|
|
145
|
+
return this.dirtyInternal;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public set color(value: string | undefined) {
|
|
149
|
+
if (value !== this.colorInternal) {
|
|
150
|
+
this.colorInternal = value;
|
|
151
|
+
this.dirtyInternal = true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public set align(value: "left" | "center" | "right" | undefined) {
|
|
156
|
+
if (value !== this.alignInternal) {
|
|
157
|
+
this.alignInternal = value;
|
|
158
|
+
this.dirtyInternal = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public set fontFamily(value: string | undefined) {
|
|
163
|
+
if (value !== this.fontFamilyInternal) {
|
|
164
|
+
this.fontFamilyInternal = value;
|
|
165
|
+
this.dirtyInternal = true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public set fontSize(value: number | undefined) {
|
|
170
|
+
if (value !== undefined) {
|
|
171
|
+
assertValidPositiveNumber(value, "UITextStyle.fontSize");
|
|
172
|
+
}
|
|
173
|
+
if (value !== this.fontSizeInternal) {
|
|
174
|
+
this.fontSizeInternal = value;
|
|
175
|
+
this.dirtyInternal = true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public set fontStyle(value: "normal" | "italic" | "oblique" | undefined) {
|
|
180
|
+
if (value !== this.fontStyleInternal) {
|
|
181
|
+
this.fontStyleInternal = value;
|
|
182
|
+
this.dirtyInternal = true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public set fontWeight(value: "normal" | "bold" | "bolder" | "lighter" | number | undefined) {
|
|
187
|
+
if (typeof value === "number") {
|
|
188
|
+
assertValidPositiveNumber(value, "UITextStyle.fontWeight");
|
|
189
|
+
}
|
|
190
|
+
if (value !== this.fontWeightInternal) {
|
|
191
|
+
this.fontWeightInternal = value;
|
|
192
|
+
this.dirtyInternal = true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public set lineHeight(value: number | undefined) {
|
|
197
|
+
if (value !== undefined) {
|
|
198
|
+
assertValidNumber(value, "UITextStyle.lineHeight");
|
|
199
|
+
}
|
|
200
|
+
if (value !== this.lineHeightInternal) {
|
|
201
|
+
this.lineHeightInternal = value;
|
|
202
|
+
this.dirtyInternal = true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
public set enableShadow(value: boolean | undefined) {
|
|
207
|
+
if (value !== this.enableShadowInternal) {
|
|
208
|
+
this.enableShadowInternal = value;
|
|
209
|
+
this.dirtyInternal = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
public set shadowOffsetX(value: number | undefined) {
|
|
214
|
+
if (value !== undefined) {
|
|
215
|
+
assertValidNonNegativeNumber(value, "UITextStyle.shadowOffsetX");
|
|
216
|
+
}
|
|
217
|
+
if (value !== this.shadowOffsetXInternal) {
|
|
218
|
+
this.shadowOffsetXInternal = value;
|
|
219
|
+
this.dirtyInternal = true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
public set shadowOffsetY(value: number | undefined) {
|
|
224
|
+
if (value !== undefined) {
|
|
225
|
+
assertValidNonNegativeNumber(value, "UITextStyle.shadowOffsetY");
|
|
226
|
+
}
|
|
227
|
+
if (value !== this.shadowOffsetYInternal) {
|
|
228
|
+
this.shadowOffsetYInternal = value;
|
|
229
|
+
this.dirtyInternal = true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
public set shadowBlur(value: number | undefined) {
|
|
234
|
+
if (value !== undefined) {
|
|
235
|
+
assertValidNonNegativeNumber(value, "UITextStyle.shadowBlur");
|
|
236
|
+
}
|
|
237
|
+
if (value !== this.shadowBlurInternal) {
|
|
238
|
+
this.shadowBlurInternal = value;
|
|
239
|
+
this.dirtyInternal = true;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
public set shadowColor(value: string | undefined) {
|
|
244
|
+
if (value !== this.shadowColorInternal) {
|
|
245
|
+
this.shadowColorInternal = value;
|
|
246
|
+
this.dirtyInternal = true;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
public set enableStroke(value: boolean | undefined) {
|
|
251
|
+
if (value !== this.enableStrokeInternal) {
|
|
252
|
+
this.enableStrokeInternal = value;
|
|
253
|
+
this.dirtyInternal = true;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
public set strokeColor(value: string | undefined) {
|
|
258
|
+
if (value !== this.strokeColorInternal) {
|
|
259
|
+
this.strokeColorInternal = value;
|
|
260
|
+
this.dirtyInternal = true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public set strokeThickness(value: number | undefined) {
|
|
265
|
+
if (value !== undefined) {
|
|
266
|
+
assertValidNonNegativeNumber(value, "UITextStyle.strokeThickness");
|
|
267
|
+
}
|
|
268
|
+
if (value !== this.strokeThicknessInternal) {
|
|
269
|
+
this.strokeThicknessInternal = value;
|
|
270
|
+
this.dirtyInternal = true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Resolves complete style from primary and fallback sources.
|
|
276
|
+
* @param primary First style to check for each property
|
|
277
|
+
* @param fallback Second style to check if primary is undefined
|
|
278
|
+
* @returns Complete style configuration with all defaults applied
|
|
279
|
+
*/
|
|
280
|
+
public static resolve(primary?: UITextStyle, fallback?: UITextStyle): UITextStyleConfig {
|
|
281
|
+
const fontSize =
|
|
282
|
+
primary?.fontSizeInternal ?? fallback?.fontSizeInternal ?? TEXT_STYLE_DEFAULT_FONT_SIZE;
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
color: primary?.colorInternal ?? fallback?.colorInternal ?? TEXT_STYLE_DEFAULT_COLOR,
|
|
286
|
+
align: primary?.alignInternal ?? fallback?.alignInternal ?? TEXT_STYLE_DEFAULT_ALIGN,
|
|
287
|
+
fontFamily:
|
|
288
|
+
primary?.fontFamilyInternal ??
|
|
289
|
+
fallback?.fontFamilyInternal ??
|
|
290
|
+
TEXT_STYLE_DEFAULT_FONT_FAMILY,
|
|
291
|
+
fontSize,
|
|
292
|
+
fontStyle:
|
|
293
|
+
primary?.fontStyleInternal ?? fallback?.fontStyleInternal ?? TEXT_STYLE_DEFAULT_FONT_STYLE,
|
|
294
|
+
fontWeight:
|
|
295
|
+
primary?.fontWeightInternal ??
|
|
296
|
+
fallback?.fontWeightInternal ??
|
|
297
|
+
TEXT_STYLE_DEFAULT_FONT_WEIGHT,
|
|
298
|
+
lineHeight:
|
|
299
|
+
primary?.lineHeightInternal ??
|
|
300
|
+
fallback?.lineHeightInternal ??
|
|
301
|
+
fontSize * TEXT_STYLE_DEFAULT_LINE_HEIGHT,
|
|
302
|
+
enableShadow:
|
|
303
|
+
primary?.enableShadowInternal ??
|
|
304
|
+
fallback?.enableShadowInternal ??
|
|
305
|
+
TEXT_STYLE_DEFAULT_ENABLE_SHADOW,
|
|
306
|
+
shadowOffsetX:
|
|
307
|
+
primary?.shadowOffsetXInternal ??
|
|
308
|
+
fallback?.shadowOffsetXInternal ??
|
|
309
|
+
TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X,
|
|
310
|
+
shadowOffsetY:
|
|
311
|
+
primary?.shadowOffsetYInternal ??
|
|
312
|
+
fallback?.shadowOffsetYInternal ??
|
|
313
|
+
TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y,
|
|
314
|
+
shadowBlur:
|
|
315
|
+
primary?.shadowBlurInternal ??
|
|
316
|
+
fallback?.shadowBlurInternal ??
|
|
317
|
+
TEXT_STYLE_DEFAULT_SHADOW_BLUR,
|
|
318
|
+
shadowColor:
|
|
319
|
+
primary?.shadowColorInternal ??
|
|
320
|
+
fallback?.shadowColorInternal ??
|
|
321
|
+
TEXT_STYLE_DEFAULT_SHADOW_COLOR,
|
|
322
|
+
enableStroke:
|
|
323
|
+
primary?.enableStrokeInternal ??
|
|
324
|
+
fallback?.enableStrokeInternal ??
|
|
325
|
+
TEXT_STYLE_DEFAULT_ENABLE_STROKE,
|
|
326
|
+
strokeColor:
|
|
327
|
+
primary?.strokeColorInternal ??
|
|
328
|
+
fallback?.strokeColorInternal ??
|
|
329
|
+
TEXT_STYLE_DEFAULT_STROKE_COLOR,
|
|
330
|
+
strokeThickness:
|
|
331
|
+
primary?.strokeThicknessInternal ??
|
|
332
|
+
fallback?.strokeThicknessInternal ??
|
|
333
|
+
TEXT_STYLE_DEFAULT_STROKE_THICKNESS,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** @internal */
|
|
338
|
+
public setDirtyFalse(): void {
|
|
339
|
+
this.dirtyInternal = false;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** Sets all properties to default values */
|
|
343
|
+
public setDefaults(): void {
|
|
344
|
+
if (
|
|
345
|
+
this.colorInternal !== TEXT_STYLE_DEFAULT_COLOR ||
|
|
346
|
+
this.alignInternal !== TEXT_STYLE_DEFAULT_ALIGN ||
|
|
347
|
+
this.fontFamilyInternal !== TEXT_STYLE_DEFAULT_FONT_FAMILY ||
|
|
348
|
+
this.fontSizeInternal !== TEXT_STYLE_DEFAULT_FONT_SIZE ||
|
|
349
|
+
this.fontStyleInternal !== TEXT_STYLE_DEFAULT_FONT_STYLE ||
|
|
350
|
+
this.fontWeightInternal !== TEXT_STYLE_DEFAULT_FONT_WEIGHT ||
|
|
351
|
+
this.lineHeightInternal !== TEXT_STYLE_DEFAULT_FONT_SIZE * TEXT_STYLE_DEFAULT_LINE_HEIGHT ||
|
|
352
|
+
this.enableShadowInternal !== TEXT_STYLE_DEFAULT_ENABLE_SHADOW ||
|
|
353
|
+
this.shadowOffsetXInternal !== TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X ||
|
|
354
|
+
this.shadowOffsetYInternal !== TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y ||
|
|
355
|
+
this.shadowBlurInternal !== TEXT_STYLE_DEFAULT_SHADOW_BLUR ||
|
|
356
|
+
this.shadowColorInternal !== TEXT_STYLE_DEFAULT_SHADOW_COLOR ||
|
|
357
|
+
this.enableStrokeInternal !== TEXT_STYLE_DEFAULT_ENABLE_STROKE ||
|
|
358
|
+
this.strokeColorInternal !== TEXT_STYLE_DEFAULT_STROKE_COLOR ||
|
|
359
|
+
this.strokeThicknessInternal !== TEXT_STYLE_DEFAULT_STROKE_THICKNESS
|
|
360
|
+
) {
|
|
361
|
+
this.colorInternal = TEXT_STYLE_DEFAULT_COLOR;
|
|
362
|
+
this.alignInternal = TEXT_STYLE_DEFAULT_ALIGN;
|
|
363
|
+
this.fontFamilyInternal = TEXT_STYLE_DEFAULT_FONT_FAMILY;
|
|
364
|
+
this.fontSizeInternal = TEXT_STYLE_DEFAULT_FONT_SIZE;
|
|
365
|
+
this.fontStyleInternal = TEXT_STYLE_DEFAULT_FONT_STYLE;
|
|
366
|
+
this.fontWeightInternal = TEXT_STYLE_DEFAULT_FONT_WEIGHT;
|
|
367
|
+
this.lineHeightInternal = TEXT_STYLE_DEFAULT_FONT_SIZE * TEXT_STYLE_DEFAULT_LINE_HEIGHT;
|
|
368
|
+
this.enableShadowInternal = TEXT_STYLE_DEFAULT_ENABLE_SHADOW;
|
|
369
|
+
this.shadowOffsetXInternal = TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X;
|
|
370
|
+
this.shadowOffsetYInternal = TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y;
|
|
371
|
+
this.shadowBlurInternal = TEXT_STYLE_DEFAULT_SHADOW_BLUR;
|
|
372
|
+
this.shadowColorInternal = TEXT_STYLE_DEFAULT_SHADOW_COLOR;
|
|
373
|
+
this.enableStrokeInternal = TEXT_STYLE_DEFAULT_ENABLE_STROKE;
|
|
374
|
+
this.strokeColorInternal = TEXT_STYLE_DEFAULT_STROKE_COLOR;
|
|
375
|
+
this.strokeThicknessInternal = TEXT_STYLE_DEFAULT_STROKE_THICKNESS;
|
|
376
|
+
this.dirtyInternal = true;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/** Sets all properties to undefined */
|
|
381
|
+
public clear(): void {
|
|
382
|
+
if (
|
|
383
|
+
this.colorInternal !== undefined ||
|
|
384
|
+
this.alignInternal !== undefined ||
|
|
385
|
+
this.fontFamilyInternal !== undefined ||
|
|
386
|
+
this.fontSizeInternal !== undefined ||
|
|
387
|
+
this.fontStyleInternal !== undefined ||
|
|
388
|
+
this.fontWeightInternal !== undefined ||
|
|
389
|
+
this.lineHeightInternal !== undefined ||
|
|
390
|
+
this.enableShadowInternal !== undefined ||
|
|
391
|
+
this.shadowOffsetXInternal !== undefined ||
|
|
392
|
+
this.shadowOffsetYInternal !== undefined ||
|
|
393
|
+
this.shadowBlurInternal !== undefined ||
|
|
394
|
+
this.shadowColorInternal !== undefined ||
|
|
395
|
+
this.enableStrokeInternal !== undefined ||
|
|
396
|
+
this.strokeColorInternal !== undefined ||
|
|
397
|
+
this.strokeThicknessInternal !== undefined
|
|
398
|
+
) {
|
|
399
|
+
this.colorInternal = undefined;
|
|
400
|
+
this.alignInternal = undefined;
|
|
401
|
+
this.fontFamilyInternal = undefined;
|
|
402
|
+
this.fontSizeInternal = undefined;
|
|
403
|
+
this.fontStyleInternal = undefined;
|
|
404
|
+
this.fontWeightInternal = undefined;
|
|
405
|
+
this.lineHeightInternal = undefined;
|
|
406
|
+
this.enableShadowInternal = undefined;
|
|
407
|
+
this.shadowOffsetXInternal = undefined;
|
|
408
|
+
this.shadowOffsetYInternal = undefined;
|
|
409
|
+
this.shadowBlurInternal = undefined;
|
|
410
|
+
this.shadowColorInternal = undefined;
|
|
411
|
+
this.enableStrokeInternal = undefined;
|
|
412
|
+
this.strokeColorInternal = undefined;
|
|
413
|
+
this.strokeThicknessInternal = undefined;
|
|
414
|
+
this.dirtyInternal = true;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/** Copies from another style instance */
|
|
419
|
+
public copy(value: UITextStyle): void {
|
|
420
|
+
if (
|
|
421
|
+
this.colorInternal !== value.colorInternal ||
|
|
422
|
+
this.alignInternal !== value.alignInternal ||
|
|
423
|
+
this.fontFamilyInternal !== value.fontFamilyInternal ||
|
|
424
|
+
this.fontSizeInternal !== value.fontSizeInternal ||
|
|
425
|
+
this.fontStyleInternal !== value.fontStyleInternal ||
|
|
426
|
+
this.fontWeightInternal !== value.fontWeightInternal ||
|
|
427
|
+
this.lineHeightInternal !== value.lineHeightInternal ||
|
|
428
|
+
this.enableShadowInternal !== value.enableShadowInternal ||
|
|
429
|
+
this.shadowOffsetXInternal !== value.shadowOffsetXInternal ||
|
|
430
|
+
this.shadowOffsetYInternal !== value.shadowOffsetYInternal ||
|
|
431
|
+
this.shadowBlurInternal !== value.shadowBlurInternal ||
|
|
432
|
+
this.shadowColorInternal !== value.shadowColorInternal ||
|
|
433
|
+
this.enableStrokeInternal !== value.enableStrokeInternal ||
|
|
434
|
+
this.strokeColorInternal !== value.strokeColorInternal ||
|
|
435
|
+
this.strokeThicknessInternal !== value.strokeThicknessInternal
|
|
436
|
+
) {
|
|
437
|
+
this.colorInternal = value.colorInternal;
|
|
438
|
+
this.alignInternal = value.alignInternal;
|
|
439
|
+
this.fontFamilyInternal = value.fontFamilyInternal;
|
|
440
|
+
this.fontSizeInternal = value.fontSizeInternal;
|
|
441
|
+
this.fontStyleInternal = value.fontStyleInternal;
|
|
442
|
+
this.fontWeightInternal = value.fontWeightInternal;
|
|
443
|
+
this.lineHeightInternal = value.lineHeightInternal;
|
|
444
|
+
this.enableShadowInternal = value.enableShadowInternal;
|
|
445
|
+
this.shadowOffsetXInternal = value.shadowOffsetXInternal;
|
|
446
|
+
this.shadowOffsetYInternal = value.shadowOffsetYInternal;
|
|
447
|
+
this.shadowBlurInternal = value.shadowBlurInternal;
|
|
448
|
+
this.shadowColorInternal = value.shadowColorInternal;
|
|
449
|
+
this.enableStrokeInternal = value.enableStrokeInternal;
|
|
450
|
+
this.strokeColorInternal = value.strokeColorInternal;
|
|
451
|
+
this.strokeThicknessInternal = value.strokeThicknessInternal;
|
|
452
|
+
this.dirtyInternal = true;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Calculates maximum padding required for stroke and shadow.
|
|
458
|
+
* @returns Padding in pixels needed on all sides
|
|
459
|
+
*/
|
|
460
|
+
public calculatePadding(): number {
|
|
461
|
+
let padding = 0;
|
|
462
|
+
|
|
463
|
+
if (this.enableStrokeInternal !== undefined) {
|
|
464
|
+
padding += this.strokeThicknessInternal ?? 0;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (this.enableShadowInternal !== undefined) {
|
|
468
|
+
const blur = this.shadowBlurInternal ?? 0;
|
|
469
|
+
const offsetX = this.shadowOffsetXInternal ?? 0;
|
|
470
|
+
const offsetY = this.shadowOffsetYInternal ?? 0;
|
|
471
|
+
const shadowSpread = blur * 2;
|
|
472
|
+
const shadowMaxX = Math.abs(offsetX) + shadowSpread;
|
|
473
|
+
const shadowMaxY = Math.abs(offsetY) + shadowSpread;
|
|
474
|
+
padding += Math.max(shadowMaxX, shadowMaxY);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return Math.ceil(padding);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Texture } from "three";
|
|
2
|
+
|
|
3
|
+
export const TEXTURE_DEFAULT_TEXTURE = new Texture();
|
|
4
|
+
export const TEXTURE_DEFAULT_SIZE = 2;
|
|
5
|
+
|
|
6
|
+
/** Rectangle coordinates and dimensions in atlas */
|
|
7
|
+
export interface UITextureRect {
|
|
8
|
+
/** X coordinate in pixels */
|
|
9
|
+
x: number;
|
|
10
|
+
/** Y coordinate in pixels */
|
|
11
|
+
y: number;
|
|
12
|
+
/** Width in pixels */
|
|
13
|
+
w: number;
|
|
14
|
+
/** Height in pixels */
|
|
15
|
+
h: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Size dimensions */
|
|
19
|
+
export interface UITextureSize {
|
|
20
|
+
/** Width in pixels */
|
|
21
|
+
w: number;
|
|
22
|
+
/** Height in pixels */
|
|
23
|
+
h: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Transparent padding around visible content */
|
|
27
|
+
export interface UITextureTrim {
|
|
28
|
+
/** Left padding in world units */
|
|
29
|
+
left: number;
|
|
30
|
+
/** Right padding in world units */
|
|
31
|
+
right: number;
|
|
32
|
+
/** Top padding in world units */
|
|
33
|
+
top: number;
|
|
34
|
+
/** Bottom padding in world units */
|
|
35
|
+
bottom: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Configuration for texture atlas sprite */
|
|
39
|
+
export interface UITextureAtlasConfig {
|
|
40
|
+
/** Source texture atlas */
|
|
41
|
+
texture: Texture;
|
|
42
|
+
/** Rectangle in atlas containing sprite */
|
|
43
|
+
frame: UITextureRect;
|
|
44
|
+
/** Whether sprite is rotated 90 degrees clockwise */
|
|
45
|
+
rotated?: boolean;
|
|
46
|
+
/** Position and size within original image before trimming */
|
|
47
|
+
spriteSourceSize: UITextureRect;
|
|
48
|
+
/** Original image dimensions before trimming */
|
|
49
|
+
sourceSize: UITextureSize;
|
|
50
|
+
/** Scale factor for resolution independence */
|
|
51
|
+
scale?: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Texture configuration from direct texture or atlas sprite */
|
|
55
|
+
export type UITextureConfig = Texture | UITextureAtlasConfig;
|