laymur 0.28.0 → 0.29.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.
Files changed (81) hide show
  1. package/README.md +53 -4
  2. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +14 -3
  3. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +38 -5
  4. package/dist/core/constraints/UICustomConstraint.js +1 -1
  5. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +1 -1
  6. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +1 -1
  7. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +1 -1
  8. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +1 -1
  9. package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +6 -0
  10. package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +8 -0
  11. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +1 -1
  12. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +1 -1
  13. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +1 -1
  14. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +1 -1
  15. package/dist/core/elements/UICanvasElement/UICanvasElement.d.ts +54 -0
  16. package/dist/core/elements/UICanvasElement/UICanvasElement.js +70 -0
  17. package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +2 -0
  18. package/dist/core/elements/UIDummy/UIDummy.js +3 -1
  19. package/dist/core/elements/UIGraphics/UIGraphics.Internal.d.ts +42 -2
  20. package/dist/core/elements/UIGraphics/UIGraphics.Internal.js +2 -2
  21. package/dist/core/elements/UIGraphics/UIGraphics.d.ts +48 -34
  22. package/dist/core/elements/UIGraphics/UIGraphics.js +196 -93
  23. package/dist/core/elements/UIImage/UIImage.d.ts +11 -1
  24. package/dist/core/elements/UIImage/UIImage.js +14 -0
  25. package/dist/core/elements/UIScene/UIScene.Internal.d.ts +10 -1
  26. package/dist/core/elements/UIScene/UIScene.Internal.js +1 -0
  27. package/dist/core/elements/UIScene/UIScene.d.ts +11 -1
  28. package/dist/core/elements/UIScene/UIScene.js +29 -5
  29. package/dist/core/elements/UIText/UIText.Interfaces.d.ts +2 -2
  30. package/dist/core/elements/UIText/UIText.Internal.d.ts +14 -1
  31. package/dist/core/elements/UIText/UIText.Internal.js +12 -0
  32. package/dist/core/elements/UIText/UIText.Measuring.d.ts +9 -4
  33. package/dist/core/elements/UIText/UIText.Measuring.js +17 -6
  34. package/dist/core/elements/UIText/UIText.Rendering.d.ts +7 -16
  35. package/dist/core/elements/UIText/UIText.Rendering.js +212 -46
  36. package/dist/core/elements/UIText/UIText.d.ts +58 -28
  37. package/dist/core/elements/UIText/UIText.js +113 -138
  38. package/dist/core/index.d.ts +10 -4
  39. package/dist/core/index.js +5 -1
  40. package/dist/core/layers/UILayer/UILayer.d.ts +17 -3
  41. package/dist/core/layers/UILayer/UILayer.js +35 -4
  42. package/dist/core/layers/UIViewportLayer/UIViewportLayer.d.ts +2 -0
  43. package/dist/core/layers/UIViewportLayer/UIViewportLayer.js +3 -0
  44. package/dist/core/miscellaneous/canvas-surface/UICanvasSurface.d.ts +46 -0
  45. package/dist/core/miscellaneous/canvas-surface/UICanvasSurface.js +86 -0
  46. package/dist/core/miscellaneous/color/UIColor.d.ts +17 -0
  47. package/dist/core/miscellaneous/color/UIColor.js +22 -0
  48. package/dist/core/miscellaneous/color/canvasColor.d.ts +9 -0
  49. package/dist/core/miscellaneous/color/canvasColor.js +15 -0
  50. package/dist/core/miscellaneous/insets/UIInsets.d.ts +3 -0
  51. package/dist/core/miscellaneous/insets/UIInsets.js +15 -0
  52. package/dist/core/miscellaneous/paint/UIGradient.Internal.d.ts +37 -0
  53. package/dist/core/miscellaneous/paint/UIGradient.Internal.js +14 -0
  54. package/dist/core/miscellaneous/paint/UIGradient.d.ts +18 -0
  55. package/dist/core/miscellaneous/paint/UIGradient.js +35 -0
  56. package/dist/core/miscellaneous/paint/UILinearGradient.d.ts +14 -0
  57. package/dist/core/miscellaneous/paint/UILinearGradient.js +22 -0
  58. package/dist/core/miscellaneous/paint/UIPaint.Internal.d.ts +21 -0
  59. package/dist/core/miscellaneous/paint/UIPaint.Internal.js +1 -0
  60. package/dist/core/miscellaneous/paint/UIPaint.d.ts +17 -0
  61. package/dist/core/miscellaneous/paint/UIPaint.js +21 -0
  62. package/dist/core/miscellaneous/paint/UIRadialGradient.d.ts +18 -0
  63. package/dist/core/miscellaneous/paint/UIRadialGradient.js +33 -0
  64. package/dist/core/miscellaneous/shared.d.ts +14 -0
  65. package/dist/core/miscellaneous/shared.js +11 -0
  66. package/dist/core/miscellaneous/text-style/UITextStyle.Internal.d.ts +88 -30
  67. package/dist/core/miscellaneous/text-style/UITextStyle.Internal.js +12 -8
  68. package/dist/core/miscellaneous/text-style/UITextStyle.d.ts +41 -66
  69. package/dist/core/miscellaneous/text-style/UITextStyle.js +165 -294
  70. package/dist/core/miscellaneous/texture/UITextureView.Internal.d.ts +2 -1
  71. package/dist/core/miscellaneous/texture/UITextureView.Internal.js +12 -3
  72. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +1 -1
  73. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +1 -1
  74. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +1 -1
  75. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +6 -2
  76. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.d.ts +41 -9
  77. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +97 -35
  78. package/dist/particles/elements/UIEmitter.Internal.d.ts +3 -0
  79. package/dist/particles/elements/UIEmitter.Internal.js +1 -0
  80. package/dist/particles/elements/UIEmitter.js +3 -2
  81. package/package.json +1 -1
@@ -1,9 +1,67 @@
1
+ import type { UIColorConfig } from "../color/UIColor.Internal.js";
2
+ import type { UILineJoin, UIPaint, UIPaintConfig } from "../paint/UIPaint.Internal.js";
1
3
  /** Text alignment. `start` and `end` are resolved against the text direction. */
2
4
  export type UITextAlign = "start" | "left" | "center" | "right" | "end";
3
- /** Complete text style configuration with all properties resolved */
5
+ /** Font style */
6
+ export type UITextFontStyle = "normal" | "italic" | "oblique";
7
+ /** Font weight */
8
+ export type UITextFontWeight = "normal" | "bold" | "bolder" | "lighter" | number;
9
+ /** Box a gradient of the fill or of a stroke is laid over */
10
+ export declare enum UITextPaintBox {
11
+ /** Each line, as high as its line box (see `UIText.lineBox`) */
12
+ LINE = 0,
13
+ /** The whole text without its padding */
14
+ TEXT = 1
15
+ }
16
+ /** Outline around the glyphs */
17
+ export interface UITextStrokeConfig {
18
+ /** Color or gradient of the outline */
19
+ paint: UIPaintConfig;
20
+ /** Width of the outline outside the glyphs, or outside the previous outline, in pixels */
21
+ thickness: number;
22
+ /** How the corners are joined. Round by default. */
23
+ join?: UILineJoin;
24
+ }
25
+ /** Outline around the glyphs, as stored by a style */
26
+ export interface UITextStroke {
27
+ /** Color or gradient of the outline */
28
+ readonly paint: UIPaint;
29
+ /** Width of the outline outside the glyphs, or outside the previous outline, in pixels */
30
+ readonly thickness: number;
31
+ /** How the corners are joined */
32
+ readonly join: UILineJoin;
33
+ }
34
+ /**
35
+ * Shadow cast by the glyphs together with their outlines. A shadow without an offset and with a
36
+ * blur is a glow.
37
+ */
38
+ export interface UITextShadowConfig {
39
+ /** Shadow color. A string is a `UIColor` name or a CSS color. */
40
+ color: UIColorConfig;
41
+ /** Horizontal offset in pixels, 0 by default */
42
+ offsetX?: number;
43
+ /** Vertical offset in pixels, down is positive, 0 by default */
44
+ offsetY?: number;
45
+ /** Blur radius in pixels, 0 by default */
46
+ blur?: number;
47
+ }
48
+ /** Shadow, as stored by a style */
49
+ export interface UITextShadow {
50
+ /** Shadow color as a CSS color */
51
+ readonly color: string;
52
+ /** Horizontal offset in pixels */
53
+ readonly offsetX: number;
54
+ /** Vertical offset in pixels, down is positive */
55
+ readonly offsetY: number;
56
+ /** Blur radius in pixels */
57
+ readonly blur: number;
58
+ }
59
+ /** Text style configuration */
4
60
  export interface UITextStyleConfig {
5
- /** Text color */
6
- color: string;
61
+ /** Color or gradient of the glyphs. A string is a `UIColor` name or a CSS color. */
62
+ color: UIPaintConfig;
63
+ /** Box the gradients of the fill and of the strokes are laid over */
64
+ paintBox: UITextPaintBox;
7
65
  /** Text alignment */
8
66
  align: UITextAlign;
9
67
  /** Font family name */
@@ -11,43 +69,43 @@ export interface UITextStyleConfig {
11
69
  /** Font size in pixels */
12
70
  fontSize: number;
13
71
  /** Font style */
14
- fontStyle: "normal" | "italic" | "oblique";
72
+ fontStyle: UITextFontStyle;
15
73
  /** Font weight */
16
- fontWeight: "normal" | "bold" | "bolder" | "lighter" | number;
74
+ fontWeight: UITextFontWeight;
17
75
  /**
18
- * Line height in pixels: the distance between baselines, not a multiple of the font size.
76
+ * Line height in pixels, the distance between baselines, not a multiple of the font size.
19
77
  * Defaults to 1.2 times the font size.
20
78
  */
21
79
  lineHeight: number;
22
- /** Whether shadow is enabled */
23
- enableShadow: boolean;
24
- /** Shadow horizontal offset in pixels */
25
- shadowOffsetX: number;
26
- /** Shadow vertical offset in pixels */
27
- shadowOffsetY: number;
28
- /** Shadow blur radius in pixels */
29
- shadowBlur: number;
30
- /** Shadow color */
31
- shadowColor: string;
32
- /** Whether stroke is enabled */
33
- enableStroke: boolean;
34
- /** Stroke color */
35
- strokeColor: string;
36
- /** Stroke thickness in pixels */
37
- strokeThickness: number;
80
+ /**
81
+ * Outlines from the innermost to the outermost. Each one lies outside the previous one, so the
82
+ * text is as wide as the sum of their thicknesses on each side.
83
+ */
84
+ strokes: readonly UITextStrokeConfig[];
85
+ /** Shadows and glows, the first one on top */
86
+ shadows: readonly UITextShadowConfig[];
87
+ }
88
+ /** Text style with every property resolved, as the text is measured and drawn with */
89
+ export interface UIResolvedTextStyle {
90
+ color: UIPaint;
91
+ paintBox: UITextPaintBox;
92
+ align: UITextAlign;
93
+ fontFamily: string;
94
+ fontSize: number;
95
+ fontStyle: UITextFontStyle;
96
+ fontWeight: UITextFontWeight;
97
+ lineHeight: number;
98
+ strokes: readonly UITextStroke[];
99
+ shadows: readonly UITextShadow[];
38
100
  }
39
101
  export declare const TEXT_STYLE_DEFAULT_COLOR = "#000000";
102
+ export declare const TEXT_STYLE_DEFAULT_PAINT_BOX = UITextPaintBox.LINE;
40
103
  export declare const TEXT_STYLE_DEFAULT_ALIGN: "start";
41
104
  export declare const TEXT_STYLE_DEFAULT_FONT_FAMILY = "Arial";
42
105
  export declare const TEXT_STYLE_DEFAULT_FONT_SIZE = 16;
43
106
  export declare const TEXT_STYLE_DEFAULT_FONT_STYLE: "normal";
44
107
  export declare const TEXT_STYLE_DEFAULT_FONT_WEIGHT: "normal";
45
108
  export declare const TEXT_STYLE_DEFAULT_LINE_HEIGHT = 1.2;
46
- export declare const TEXT_STYLE_DEFAULT_ENABLE_SHADOW = false;
47
- export declare const TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X = 0;
48
- export declare const TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y = 0;
49
- export declare const TEXT_STYLE_DEFAULT_SHADOW_BLUR = 0;
50
- export declare const TEXT_STYLE_DEFAULT_SHADOW_COLOR = "transparent";
51
- export declare const TEXT_STYLE_DEFAULT_ENABLE_STROKE = false;
52
- export declare const TEXT_STYLE_DEFAULT_STROKE_COLOR = "#000000";
53
- export declare const TEXT_STYLE_DEFAULT_STROKE_THICKNESS = 0;
109
+ export declare const TEXT_STYLE_DEFAULT_STROKES: readonly UITextStroke[];
110
+ export declare const TEXT_STYLE_DEFAULT_SHADOWS: readonly UITextShadow[];
111
+ export declare const TEXT_STYLE_DEFAULT_STROKE_JOIN: "round";
@@ -1,15 +1,19 @@
1
+ /** Box a gradient of the fill or of a stroke is laid over */
2
+ export var UITextPaintBox;
3
+ (function (UITextPaintBox) {
4
+ /** Each line, as high as its line box (see `UIText.lineBox`) */
5
+ UITextPaintBox[UITextPaintBox["LINE"] = 0] = "LINE";
6
+ /** The whole text without its padding */
7
+ UITextPaintBox[UITextPaintBox["TEXT"] = 1] = "TEXT";
8
+ })(UITextPaintBox || (UITextPaintBox = {}));
1
9
  export const TEXT_STYLE_DEFAULT_COLOR = "#000000";
10
+ export const TEXT_STYLE_DEFAULT_PAINT_BOX = UITextPaintBox.LINE;
2
11
  export const TEXT_STYLE_DEFAULT_ALIGN = "start";
3
12
  export const TEXT_STYLE_DEFAULT_FONT_FAMILY = "Arial";
4
13
  export const TEXT_STYLE_DEFAULT_FONT_SIZE = 16;
5
14
  export const TEXT_STYLE_DEFAULT_FONT_STYLE = "normal";
6
15
  export const TEXT_STYLE_DEFAULT_FONT_WEIGHT = "normal";
7
16
  export const TEXT_STYLE_DEFAULT_LINE_HEIGHT = 1.2;
8
- export const TEXT_STYLE_DEFAULT_ENABLE_SHADOW = false;
9
- export const TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X = 0;
10
- export const TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y = 0;
11
- export const TEXT_STYLE_DEFAULT_SHADOW_BLUR = 0;
12
- export const TEXT_STYLE_DEFAULT_SHADOW_COLOR = "transparent";
13
- export const TEXT_STYLE_DEFAULT_ENABLE_STROKE = false;
14
- export const TEXT_STYLE_DEFAULT_STROKE_COLOR = "#000000";
15
- export const TEXT_STYLE_DEFAULT_STROKE_THICKNESS = 0;
17
+ export const TEXT_STYLE_DEFAULT_STROKES = Object.freeze([]);
18
+ export const TEXT_STYLE_DEFAULT_SHADOWS = Object.freeze([]);
19
+ export const TEXT_STYLE_DEFAULT_STROKE_JOIN = "round";
@@ -1,26 +1,19 @@
1
- import type { UITextAlign, UITextStyleConfig } from "./UITextStyle.Internal.js";
2
- /** Text style configuration for UI text rendering */
1
+ import type { UIPaint, UIPaintConfig } from "../paint/UIPaint.Internal.js";
2
+ import type { UITextAlign, UITextFontStyle, UITextFontWeight, UITextPaintBox, UITextShadow, UITextShadowConfig, UITextStroke, UITextStrokeConfig, UITextStyleConfig } from "./UITextStyle.Internal.js";
3
+ /**
4
+ * Text style of a span or of a whole text. Properties left undefined are taken from the
5
+ * fallback style, the common style of the text for a span, then from the defaults. Lists of
6
+ * strokes and shadows are taken as a whole.
7
+ */
3
8
  export declare class UITextStyle {
4
- private colorInternal?;
5
- private alignInternal?;
6
- private fontFamilyInternal?;
7
- private fontSizeInternal?;
8
- private fontStyleInternal?;
9
- private fontWeightInternal?;
10
- private lineHeightInternal?;
11
- private enableShadowInternal?;
12
- private shadowOffsetXInternal?;
13
- private shadowOffsetYInternal?;
14
- private shadowBlurInternal?;
15
- private shadowColorInternal?;
16
- private enableStrokeInternal?;
17
- private strokeColorInternal?;
18
- private strokeThicknessInternal?;
9
+ private readonly values;
19
10
  private dirtyInternal;
20
11
  /** @param config Partial style configuration. Unspecified properties remain undefined. */
21
12
  constructor(config?: Partial<UITextStyleConfig>);
22
- /** Text color */
23
- get color(): string | undefined;
13
+ /** Color or gradient of the glyphs. A color is kept as a CSS string. */
14
+ get color(): UIPaint | undefined;
15
+ /** Box the gradients of the fill and of the strokes are laid over */
16
+ get paintBox(): UITextPaintBox | undefined;
24
17
  /** Text alignment */
25
18
  get align(): UITextAlign | undefined;
26
19
  /** Font family name */
@@ -28,60 +21,41 @@ export declare class UITextStyle {
28
21
  /** Font size in pixels */
29
22
  get fontSize(): number | undefined;
30
23
  /** Font style */
31
- get fontStyle(): "normal" | "italic" | "oblique" | undefined;
24
+ get fontStyle(): UITextFontStyle | undefined;
32
25
  /** Font weight */
33
- get fontWeight(): "normal" | "bold" | "bolder" | "lighter" | number | undefined;
34
- /**
35
- * Line height in pixels: the distance between baselines, not a multiple of the font size.
36
- * Defaults to 1.2 times the font size.
37
- */
26
+ get fontWeight(): UITextFontWeight | undefined;
27
+ /** Line height in pixels, the distance between baselines */
38
28
  get lineHeight(): number | undefined;
39
- /** Whether shadow is enabled */
40
- get enableShadow(): boolean | undefined;
41
- /** Shadow horizontal offset in pixels */
42
- get shadowOffsetX(): number | undefined;
43
- /** Shadow vertical offset in pixels */
44
- get shadowOffsetY(): number | undefined;
45
- /** Shadow blur radius in pixels */
46
- get shadowBlur(): number | undefined;
47
- /** Shadow color */
48
- get shadowColor(): string | undefined;
49
- /** Whether stroke is enabled */
50
- get enableStroke(): boolean | undefined;
51
- /** Stroke color */
52
- get strokeColor(): string | undefined;
53
- /** Stroke thickness in pixels */
54
- get strokeThickness(): number | undefined;
55
- set color(value: string | undefined);
29
+ /** Outlines from the innermost to the outermost */
30
+ get strokes(): readonly UITextStroke[] | undefined;
31
+ /** Shadows and glows, the first one on top */
32
+ get shadows(): readonly UITextShadow[] | undefined;
33
+ /** Color or gradient of the glyphs. A string is a `UIColor` name or a CSS color. */
34
+ set color(value: UIPaintConfig | undefined);
35
+ /** Box the gradients of the fill and of the strokes are laid over */
36
+ set paintBox(value: UITextPaintBox | undefined);
37
+ /** Text alignment */
56
38
  set align(value: UITextAlign | undefined);
39
+ /** Font family name */
57
40
  set fontFamily(value: string | undefined);
41
+ /** Font size in pixels */
58
42
  set fontSize(value: number | undefined);
59
- set fontStyle(value: "normal" | "italic" | "oblique" | undefined);
60
- set fontWeight(value: "normal" | "bold" | "bolder" | "lighter" | number | undefined);
43
+ /** Font style */
44
+ set fontStyle(value: UITextFontStyle | undefined);
45
+ /** Font weight */
46
+ set fontWeight(value: UITextFontWeight | undefined);
47
+ /** Line height in pixels, the distance between baselines */
61
48
  set lineHeight(value: number | undefined);
62
- set enableShadow(value: boolean | undefined);
63
- set shadowOffsetX(value: number | undefined);
64
- set shadowOffsetY(value: number | undefined);
65
- set shadowBlur(value: number | undefined);
66
- set shadowColor(value: string | undefined);
67
- set enableStroke(value: boolean | undefined);
68
- set strokeColor(value: string | undefined);
69
- set strokeThickness(value: number | undefined);
70
49
  /**
71
- * Resolves complete style from primary and fallback sources.
72
- * @param primary First style to check for each property
73
- * @param fallback Second style to check if primary is undefined
74
- * @returns Complete style configuration with all defaults applied
50
+ * Outlines from the innermost to the outermost. Each one lies outside the previous one. An
51
+ * empty list draws no outline, undefined takes the outlines of the fallback style.
75
52
  */
76
- static resolve(primary?: UITextStyle, fallback?: UITextStyle): UITextStyleConfig;
53
+ set strokes(value: readonly UITextStrokeConfig[] | undefined);
77
54
  /**
78
- * Calculates maximum padding required for stroke and shadow of a resolved style.
79
- * The stroke is centered on the glyph outline, so only half of it is outside.
80
- * The shadow is cast by the stroke as well as by the fill.
81
- * @param style Resolved style
82
- * @returns Padding in pixels needed on all sides
55
+ * Shadows and glows, the first one on top. An empty list draws no shadow, undefined takes the
56
+ * shadows of the fallback style.
83
57
  */
84
- static calculatePadding(style: UITextStyleConfig): number;
58
+ set shadows(value: readonly UITextShadowConfig[] | undefined);
85
59
  /** Sets all properties to default values */
86
60
  setDefaults(): void;
87
61
  /** Sets all properties to undefined */
@@ -89,11 +63,12 @@ export declare class UITextStyle {
89
63
  /** Copies from another style instance */
90
64
  copy(value: UITextStyle): void;
91
65
  /**
92
- * Calculates maximum padding required for stroke and shadow.
66
+ * Calculates the padding needed on every side for outlines and shadows.
93
67
  * Properties left undefined here are taken from `fallback`, then from defaults,
94
- * so a span style is measured with the stroke and shadow it is drawn with.
68
+ * so a span style is measured with the outlines and shadows it is drawn with.
95
69
  * @param fallback Style that supplies undefined properties (usually the common style)
96
- * @returns Padding in pixels needed on all sides
70
+ * @returns Padding in pixels
97
71
  */
98
72
  calculatePadding(fallback?: UITextStyle): number;
73
+ private setValue;
99
74
  }