@motionscript/grids 0.0.0-stage → 0.1.0-alpha.10

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 (133) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +49 -0
  4. package/README.md +117 -2
  5. package/dist/browser/chunks/chunk-TYNFMZ3D.js +2 -0
  6. package/dist/browser/chunks/chunk-TYNFMZ3D.js.map +7 -0
  7. package/dist/browser/index.js +2 -0
  8. package/dist/browser/index.js.map +7 -0
  9. package/dist/browser/kit.js +2 -0
  10. package/dist/browser/kit.js.map +7 -0
  11. package/dist/browser/manifest.json +13 -0
  12. package/dist/engine.d.ts +13 -0
  13. package/dist/engine.d.ts.map +1 -0
  14. package/dist/engine.js +13 -0
  15. package/dist/engine.js.map +1 -0
  16. package/dist/index.d.ts +7 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +7 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/kit/index.d.ts +9 -0
  21. package/dist/kit/index.d.ts.map +1 -0
  22. package/dist/kit/index.js +10 -0
  23. package/dist/kit/index.js.map +1 -0
  24. package/dist/kit/item-effects.d.ts +37 -0
  25. package/dist/kit/item-effects.d.ts.map +1 -0
  26. package/dist/kit/item-effects.js +76 -0
  27. package/dist/kit/item-effects.js.map +1 -0
  28. package/dist/kit/item-grid.d.ts +240 -0
  29. package/dist/kit/item-grid.d.ts.map +1 -0
  30. package/dist/kit/item-grid.js +492 -0
  31. package/dist/kit/item-grid.js.map +1 -0
  32. package/dist/kit/order.d.ts +13 -0
  33. package/dist/kit/order.d.ts.map +1 -0
  34. package/dist/kit/order.js +43 -0
  35. package/dist/kit/order.js.map +1 -0
  36. package/dist/kit/random.d.ts +7 -0
  37. package/dist/kit/random.d.ts.map +1 -0
  38. package/dist/kit/random.js +29 -0
  39. package/dist/kit/random.js.map +1 -0
  40. package/dist/kit/slots/index.d.ts +22 -0
  41. package/dist/kit/slots/index.d.ts.map +1 -0
  42. package/dist/kit/slots/index.js +28 -0
  43. package/dist/kit/slots/index.js.map +1 -0
  44. package/dist/kit/slots/path-templates.d.ts +15 -0
  45. package/dist/kit/slots/path-templates.d.ts.map +1 -0
  46. package/dist/kit/slots/path-templates.js +113 -0
  47. package/dist/kit/slots/path-templates.js.map +1 -0
  48. package/dist/kit/slots/path.d.ts +45 -0
  49. package/dist/kit/slots/path.d.ts.map +1 -0
  50. package/dist/kit/slots/path.js +87 -0
  51. package/dist/kit/slots/path.js.map +1 -0
  52. package/dist/kit/slots/radial.d.ts +30 -0
  53. package/dist/kit/slots/radial.d.ts.map +1 -0
  54. package/dist/kit/slots/radial.js +45 -0
  55. package/dist/kit/slots/radial.js.map +1 -0
  56. package/dist/kit/slots/rectangular.d.ts +42 -0
  57. package/dist/kit/slots/rectangular.d.ts.map +1 -0
  58. package/dist/kit/slots/rectangular.js +79 -0
  59. package/dist/kit/slots/rectangular.js.map +1 -0
  60. package/dist/kit/slots/slot.d.ts +62 -0
  61. package/dist/kit/slots/slot.d.ts.map +1 -0
  62. package/dist/kit/slots/slot.js +41 -0
  63. package/dist/kit/slots/slot.js.map +1 -0
  64. package/dist/kit/slots/sphere.d.ts +36 -0
  65. package/dist/kit/slots/sphere.d.ts.map +1 -0
  66. package/dist/kit/slots/sphere.js +68 -0
  67. package/dist/kit/slots/sphere.js.map +1 -0
  68. package/dist/kit/stagger.d.ts +24 -0
  69. package/dist/kit/stagger.d.ts.map +1 -0
  70. package/dist/kit/stagger.js +90 -0
  71. package/dist/kit/stagger.js.map +1 -0
  72. package/dist/nodes.d.ts +20 -0
  73. package/dist/nodes.d.ts.map +1 -0
  74. package/dist/nodes.js +11 -0
  75. package/dist/nodes.js.map +1 -0
  76. package/dist/path-grid/index.d.ts +2 -0
  77. package/dist/path-grid/index.d.ts.map +1 -0
  78. package/dist/path-grid/index.js +2 -0
  79. package/dist/path-grid/index.js.map +1 -0
  80. package/dist/path-grid/path-grid.d.ts +196 -0
  81. package/dist/path-grid/path-grid.d.ts.map +1 -0
  82. package/dist/path-grid/path-grid.js +149 -0
  83. package/dist/path-grid/path-grid.js.map +1 -0
  84. package/dist/radial-grid/index.d.ts +2 -0
  85. package/dist/radial-grid/index.d.ts.map +1 -0
  86. package/dist/radial-grid/index.js +2 -0
  87. package/dist/radial-grid/index.js.map +1 -0
  88. package/dist/radial-grid/radial-grid.d.ts +177 -0
  89. package/dist/radial-grid/radial-grid.d.ts.map +1 -0
  90. package/dist/radial-grid/radial-grid.js +63 -0
  91. package/dist/radial-grid/radial-grid.js.map +1 -0
  92. package/dist/rectangular-grid/index.d.ts +2 -0
  93. package/dist/rectangular-grid/index.d.ts.map +1 -0
  94. package/dist/rectangular-grid/index.js +2 -0
  95. package/dist/rectangular-grid/index.js.map +1 -0
  96. package/dist/rectangular-grid/rectangular-grid.d.ts +212 -0
  97. package/dist/rectangular-grid/rectangular-grid.d.ts.map +1 -0
  98. package/dist/rectangular-grid/rectangular-grid.js +118 -0
  99. package/dist/rectangular-grid/rectangular-grid.js.map +1 -0
  100. package/dist/sphere-grid/index.d.ts +2 -0
  101. package/dist/sphere-grid/index.d.ts.map +1 -0
  102. package/dist/sphere-grid/index.js +2 -0
  103. package/dist/sphere-grid/index.js.map +1 -0
  104. package/dist/sphere-grid/sphere-grid.d.ts +200 -0
  105. package/dist/sphere-grid/sphere-grid.d.ts.map +1 -0
  106. package/dist/sphere-grid/sphere-grid.js +102 -0
  107. package/dist/sphere-grid/sphere-grid.js.map +1 -0
  108. package/package.json +72 -3
  109. package/registry.json +32 -0
  110. package/src/engine.ts +12 -0
  111. package/src/index.ts +6 -0
  112. package/src/kit/index.ts +18 -0
  113. package/src/kit/item-effects.ts +114 -0
  114. package/src/kit/item-grid.ts +648 -0
  115. package/src/kit/order.ts +41 -0
  116. package/src/kit/random.ts +29 -0
  117. package/src/kit/slots/index.ts +39 -0
  118. package/src/kit/slots/path-templates.ts +120 -0
  119. package/src/kit/slots/path.ts +120 -0
  120. package/src/kit/slots/radial.ts +62 -0
  121. package/src/kit/slots/rectangular.ts +108 -0
  122. package/src/kit/slots/slot.ts +82 -0
  123. package/src/kit/slots/sphere.ts +94 -0
  124. package/src/kit/stagger.ts +96 -0
  125. package/src/nodes.ts +30 -0
  126. package/src/path-grid/index.ts +1 -0
  127. package/src/path-grid/path-grid.ts +186 -0
  128. package/src/radial-grid/index.ts +1 -0
  129. package/src/radial-grid/radial-grid.ts +81 -0
  130. package/src/rectangular-grid/index.ts +1 -0
  131. package/src/rectangular-grid/rectangular-grid.ts +145 -0
  132. package/src/sphere-grid/index.ts +1 -0
  133. package/src/sphere-grid/sphere-grid.ts +129 -0
@@ -0,0 +1,200 @@
1
+ import { type NodeOf, type Node2D as _Node2D, type Node2DProps as _Node2DProps } from "@motionscript/sdk";
2
+ import { ItemGrid } from "../kit/index.js";
3
+ /**
4
+ * Children spread over a sphere — a Fibonacci lattice, as even as any number
5
+ * of points gets — and seen through a camera of the grid's own, so the far
6
+ * side is smaller, drawn first, and hidden where a face turns away.
7
+ *
8
+ * `outward` lays each item flat on the surface; `billboard` keeps each one
9
+ * facing the viewer, like labels on a globe. `turnTo` brings any item round
10
+ * to the front.
11
+ */
12
+ export declare const SphereGrid: import("@motionscript/sdk").Component<"sphereGrid", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
13
+ readonly radius: import("@motionscript/sdk").Type<number, number, false>;
14
+ readonly yaw: import("@motionscript/sdk").Type<number, number, false>;
15
+ readonly pitch: import("@motionscript/sdk").Type<number, number, false>;
16
+ readonly roll: import("@motionscript/sdk").Type<number, number, false>;
17
+ readonly facing: import("@motionscript/sdk").Type<"outward" | "billboard", "outward" | "billboard", false>;
18
+ readonly focalLength: import("@motionscript/sdk").Type<number, number, false>;
19
+ readonly depthFade: import("@motionscript/sdk").Type<number, number, false>;
20
+ readonly cullBackfaces: boolean;
21
+ readonly spinSpeed: import("@motionscript/sdk").Type<number, number, false>;
22
+ readonly order: import("@motionscript/sdk").Type<number[], number[], false>;
23
+ readonly spread: import("@motionscript/sdk").Type<number, number, false>;
24
+ readonly arrangeLike: import("@motionscript/sdk").Type<string, import("@motionscript/sdk").NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
25
+ readonly revealState: import("@motionscript/sdk").Type<import("../index.js").RevealState | null | undefined, import("../index.js").RevealState | null | undefined, false>;
26
+ readonly waveState: import("@motionscript/sdk").Type<import("../index.js").WaveState | null | undefined, import("../index.js").WaveState | null | undefined, false>;
27
+ readonly focusState: import("@motionscript/sdk").Type<import("../index.js").FocusState | null | undefined, import("../index.js").FocusState | null | undefined, false>;
28
+ readonly transition: import("@motionscript/sdk").Type<ItemGrid.GridTransition | null | undefined, ItemGrid.GridTransition | null | undefined, false>;
29
+ readonly transitionSource: import("@motionscript/sdk").Type<string, import("@motionscript/sdk").NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
30
+ }>, {
31
+ readonly spin: {
32
+ readonly axis: import("@motionscript/sdk").Type<"x" | "y" | "z", "x" | "y" | "z", false>;
33
+ readonly degrees: import("@motionscript/sdk").Type<number, number, false>;
34
+ };
35
+ readonly orientTo: {
36
+ readonly yaw: import("@motionscript/sdk").Type<45 | undefined, 45 | undefined, false>;
37
+ readonly pitch: import("@motionscript/sdk").Type<20 | undefined, 20 | undefined, false>;
38
+ readonly roll: import("@motionscript/sdk").Type<0 | undefined, 0 | undefined, false>;
39
+ };
40
+ readonly turnTo: {
41
+ readonly item: import("@motionscript/sdk").Type<number, number, false>;
42
+ };
43
+ readonly radiusTo: {
44
+ readonly radius: import("@motionscript/sdk").Type<300 | undefined, 300 | undefined, false>;
45
+ };
46
+ readonly focalLengthTo: {
47
+ readonly focalLength: import("@motionscript/sdk").Type<600 | undefined, 600 | undefined, false>;
48
+ };
49
+ readonly reveal: {
50
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
51
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
52
+ readonly style: import("@motionscript/sdk").Type<"center" | "scale" | "fade" | "rise" | "flip" | "spin", "center" | "scale" | "fade" | "rise" | "flip" | "spin", false>;
53
+ };
54
+ readonly conceal: {
55
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
56
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
57
+ readonly style: import("@motionscript/sdk").Type<"center" | "scale" | "fade" | "rise" | "flip" | "spin", "center" | "scale" | "fade" | "rise" | "flip" | "spin", false>;
58
+ };
59
+ readonly wave: {
60
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
61
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
62
+ readonly style: import("@motionscript/sdk").Type<"scale" | "fade" | "spin" | "lift", "scale" | "fade" | "spin" | "lift", false>;
63
+ readonly amount: import("@motionscript/sdk").Type<number, number, false>;
64
+ };
65
+ readonly focus: {
66
+ readonly item: import("@motionscript/sdk").Type<number, number, false>;
67
+ readonly dim: import("@motionscript/sdk").Type<number, number, false>;
68
+ readonly grow: import("@motionscript/sdk").Type<number, number, false>;
69
+ };
70
+ readonly unfocus: unknown;
71
+ readonly spreadTo: {
72
+ readonly spread: import("@motionscript/sdk").Type<number, number, false>;
73
+ };
74
+ readonly shuffle: {
75
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
76
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
77
+ readonly seed: import("@motionscript/sdk").Type<number, number, false>;
78
+ };
79
+ readonly swap: {
80
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
81
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
82
+ readonly first: import("@motionscript/sdk").Type<number, number, false>;
83
+ readonly second: import("@motionscript/sdk").Type<number, number, false>;
84
+ };
85
+ readonly reorder: {
86
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
87
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
88
+ readonly order: import("@motionscript/sdk").Type<string, string, false>;
89
+ };
90
+ readonly morphInto: {
91
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
92
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
93
+ readonly target: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
94
+ };
95
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
96
+ readonly radius: import("@motionscript/sdk").Type<number, number, false>;
97
+ readonly yaw: import("@motionscript/sdk").Type<number, number, false>;
98
+ readonly pitch: import("@motionscript/sdk").Type<number, number, false>;
99
+ readonly roll: import("@motionscript/sdk").Type<number, number, false>;
100
+ readonly facing: import("@motionscript/sdk").Type<"outward" | "billboard", "outward" | "billboard", false>;
101
+ readonly focalLength: import("@motionscript/sdk").Type<number, number, false>;
102
+ readonly depthFade: import("@motionscript/sdk").Type<number, number, false>;
103
+ readonly cullBackfaces: boolean;
104
+ readonly spinSpeed: import("@motionscript/sdk").Type<number, number, false>;
105
+ readonly order: import("@motionscript/sdk").Type<number[], number[], false>;
106
+ readonly spread: import("@motionscript/sdk").Type<number, number, false>;
107
+ readonly arrangeLike: import("@motionscript/sdk").Type<string, import("@motionscript/sdk").NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
108
+ readonly revealState: import("@motionscript/sdk").Type<import("../index.js").RevealState | null | undefined, import("../index.js").RevealState | null | undefined, false>;
109
+ readonly waveState: import("@motionscript/sdk").Type<import("../index.js").WaveState | null | undefined, import("../index.js").WaveState | null | undefined, false>;
110
+ readonly focusState: import("@motionscript/sdk").Type<import("../index.js").FocusState | null | undefined, import("../index.js").FocusState | null | undefined, false>;
111
+ readonly transition: import("@motionscript/sdk").Type<ItemGrid.GridTransition | null | undefined, ItemGrid.GridTransition | null | undefined, false>;
112
+ readonly transitionSource: import("@motionscript/sdk").Type<string, import("@motionscript/sdk").NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
113
+ }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
114
+ readonly radius: import("@motionscript/sdk").Type<number, number, false>;
115
+ readonly yaw: import("@motionscript/sdk").Type<number, number, false>;
116
+ readonly pitch: import("@motionscript/sdk").Type<number, number, false>;
117
+ readonly roll: import("@motionscript/sdk").Type<number, number, false>;
118
+ readonly facing: import("@motionscript/sdk").Type<"outward" | "billboard", "outward" | "billboard", false>;
119
+ readonly focalLength: import("@motionscript/sdk").Type<number, number, false>;
120
+ readonly depthFade: import("@motionscript/sdk").Type<number, number, false>;
121
+ readonly cullBackfaces: boolean;
122
+ readonly spinSpeed: import("@motionscript/sdk").Type<number, number, false>;
123
+ readonly order: import("@motionscript/sdk").Type<number[], number[], false>;
124
+ readonly spread: import("@motionscript/sdk").Type<number, number, false>;
125
+ readonly arrangeLike: import("@motionscript/sdk").Type<string, import("@motionscript/sdk").NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
126
+ readonly revealState: import("@motionscript/sdk").Type<import("../index.js").RevealState | null | undefined, import("../index.js").RevealState | null | undefined, false>;
127
+ readonly waveState: import("@motionscript/sdk").Type<import("../index.js").WaveState | null | undefined, import("../index.js").WaveState | null | undefined, false>;
128
+ readonly focusState: import("@motionscript/sdk").Type<import("../index.js").FocusState | null | undefined, import("../index.js").FocusState | null | undefined, false>;
129
+ readonly transition: import("@motionscript/sdk").Type<ItemGrid.GridTransition | null | undefined, ItemGrid.GridTransition | null | undefined, false>;
130
+ readonly transitionSource: import("@motionscript/sdk").Type<string, import("@motionscript/sdk").NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
131
+ }>, {
132
+ readonly spin: {
133
+ readonly axis: import("@motionscript/sdk").Type<"x" | "y" | "z", "x" | "y" | "z", false>;
134
+ readonly degrees: import("@motionscript/sdk").Type<number, number, false>;
135
+ };
136
+ readonly orientTo: {
137
+ readonly yaw: import("@motionscript/sdk").Type<45 | undefined, 45 | undefined, false>;
138
+ readonly pitch: import("@motionscript/sdk").Type<20 | undefined, 20 | undefined, false>;
139
+ readonly roll: import("@motionscript/sdk").Type<0 | undefined, 0 | undefined, false>;
140
+ };
141
+ readonly turnTo: {
142
+ readonly item: import("@motionscript/sdk").Type<number, number, false>;
143
+ };
144
+ readonly radiusTo: {
145
+ readonly radius: import("@motionscript/sdk").Type<300 | undefined, 300 | undefined, false>;
146
+ };
147
+ readonly focalLengthTo: {
148
+ readonly focalLength: import("@motionscript/sdk").Type<600 | undefined, 600 | undefined, false>;
149
+ };
150
+ readonly reveal: {
151
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
152
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
153
+ readonly style: import("@motionscript/sdk").Type<"center" | "scale" | "fade" | "rise" | "flip" | "spin", "center" | "scale" | "fade" | "rise" | "flip" | "spin", false>;
154
+ };
155
+ readonly conceal: {
156
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
157
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
158
+ readonly style: import("@motionscript/sdk").Type<"center" | "scale" | "fade" | "rise" | "flip" | "spin", "center" | "scale" | "fade" | "rise" | "flip" | "spin", false>;
159
+ };
160
+ readonly wave: {
161
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
162
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
163
+ readonly style: import("@motionscript/sdk").Type<"scale" | "fade" | "spin" | "lift", "scale" | "fade" | "spin" | "lift", false>;
164
+ readonly amount: import("@motionscript/sdk").Type<number, number, false>;
165
+ };
166
+ readonly focus: {
167
+ readonly item: import("@motionscript/sdk").Type<number, number, false>;
168
+ readonly dim: import("@motionscript/sdk").Type<number, number, false>;
169
+ readonly grow: import("@motionscript/sdk").Type<number, number, false>;
170
+ };
171
+ readonly unfocus: unknown;
172
+ readonly spreadTo: {
173
+ readonly spread: import("@motionscript/sdk").Type<number, number, false>;
174
+ };
175
+ readonly shuffle: {
176
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
177
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
178
+ readonly seed: import("@motionscript/sdk").Type<number, number, false>;
179
+ };
180
+ readonly swap: {
181
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
182
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
183
+ readonly first: import("@motionscript/sdk").Type<number, number, false>;
184
+ readonly second: import("@motionscript/sdk").Type<number, number, false>;
185
+ };
186
+ readonly reorder: {
187
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
188
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
189
+ readonly order: import("@motionscript/sdk").Type<string, string, false>;
190
+ };
191
+ readonly morphInto: {
192
+ readonly staggerOrder: import("@motionscript/sdk").Type<"path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", "path" | "row" | "column" | "angle" | "depth" | "index" | "reverse" | "random" | "centerOut" | "edgesIn", false>;
193
+ readonly stagger: import("@motionscript/sdk").Type<number, number, false>;
194
+ readonly target: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
195
+ };
196
+ }, _Node2D<_Node2DProps>>>>;
197
+ export type SphereGrid = NodeOf<typeof SphereGrid>;
198
+ /** What a call or a document row may set. */
199
+ export type SphereGridProps = NonNullable<Parameters<typeof SphereGrid>[0]>;
200
+ //# sourceMappingURL=sphere-grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sphere-grid.d.ts","sourceRoot":"","sources":["../../src/sphere-grid/sphere-grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EAGX,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EACjC,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,QAAQ,EAQT,MAAM,QAAQ,CAAA;AAmCf;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BA6DV,CAAA;AAEb,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAA;AAClD,6CAA6C;AAC7C,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,102 @@
1
+ import { component2d, Types, } from "@motionscript/sdk";
2
+ import { ItemGrid, normalizeOrder, SPHERE_AXES, SPHERE_FACINGS, sphereFaceForward, wrapDegrees, } from "../kit/index.js";
3
+ const own = {
4
+ radius: Types.number(220, { min: 0, step: 1 }),
5
+ yaw: Types.number(0, { step: 1, unit: "°" }),
6
+ pitch: Types.number(0, { step: 1, unit: "°" }),
7
+ roll: Types.number(0, { step: 1, unit: "°" }),
8
+ facing: Types.oneOf(SPHERE_FACINGS, { default: "outward" }),
9
+ focalLength: Types.number(900, { min: 100, step: 10 }),
10
+ depthFade: Types.number(0.5, { min: 0, max: 1, step: 0.05 }),
11
+ cullBackfaces: false,
12
+ spinSpeed: Types.number(0, { step: 1, unit: "°/s" }),
13
+ };
14
+ function arrangement(s) {
15
+ return {
16
+ kind: "sphere",
17
+ radius: s.radius,
18
+ yaw: s.yaw,
19
+ pitch: s.pitch,
20
+ roll: s.roll,
21
+ facing: s.facing,
22
+ focalLength: s.focalLength,
23
+ depthFade: s.depthFade,
24
+ cullBackfaces: s.cullBackfaces,
25
+ spinSpeed: s.spinSpeed,
26
+ };
27
+ }
28
+ const arranger = { arrangement };
29
+ const AXIS_PROP = { x: "pitch", y: "yaw", z: "roll" };
30
+ /**
31
+ * Children spread over a sphere — a Fibonacci lattice, as even as any number
32
+ * of points gets — and seen through a camera of the grid's own, so the far
33
+ * side is smaller, drawn first, and hidden where a face turns away.
34
+ *
35
+ * `outward` lays each item flat on the surface; `billboard` keeps each one
36
+ * facing the viewer, like labels on a globe. `turnTo` brings any item round
37
+ * to the front.
38
+ */
39
+ export const SphereGrid = ItemGrid.define(component2d({
40
+ key: "sphereGrid",
41
+ state: { ...ItemGrid.state, ...own },
42
+ defaults: ItemGrid.defaults,
43
+ commands: {
44
+ ...ItemGrid.commands,
45
+ /** Turn the sphere about an axis by `degrees` — `y` spins it like a globe. */
46
+ spin: {
47
+ args: {
48
+ axis: Types.oneOf(SPHERE_AXES, { default: "y" }),
49
+ degrees: Types.number(360, { step: 15, unit: "°" }),
50
+ },
51
+ run: (timeline, s) => {
52
+ const key = AXIS_PROP[timeline.args.axis ?? "y"] ?? "yaw";
53
+ return timeline.tween({ [key]: s[key] + (timeline.args.degrees ?? 360) });
54
+ },
55
+ },
56
+ /** Turn the sphere to a set orientation. */
57
+ orientTo: {
58
+ args: {
59
+ yaw: ItemGrid.hinted(45, { unit: "°" }),
60
+ pitch: ItemGrid.hinted(20, { unit: "°" }),
61
+ roll: ItemGrid.hinted(0, { unit: "°" }),
62
+ },
63
+ run: (timeline, s) => timeline.tween({
64
+ yaw: timeline.args.yaw ?? s.yaw,
65
+ pitch: timeline.args.pitch ?? s.pitch,
66
+ roll: timeline.args.roll ?? s.roll,
67
+ }),
68
+ },
69
+ /**
70
+ * Turn the sphere the shorter way until an item (by its place in the layers)
71
+ * faces the viewer. It turns from the orientation the sphere is given: the
72
+ * yaw its `spinSpeed` adds by the time the command runs is not counted, as
73
+ * commands are built against the tree standing at time 0.
74
+ */
75
+ turnTo: {
76
+ args: { item: Types.number(0, { min: 0, step: 1 }) },
77
+ run: (timeline, s, children) => {
78
+ const count = children.length;
79
+ const slot = normalizeOrder(s.order, count).indexOf(Math.round(timeline.args.item ?? 0));
80
+ if (slot < 0)
81
+ return timeline.tween({});
82
+ const facing = sphereFaceForward(count, slot);
83
+ return timeline.tween({
84
+ yaw: s.yaw + wrapDegrees(facing.yaw - s.yaw),
85
+ pitch: s.pitch + wrapDegrees(facing.pitch - s.pitch),
86
+ roll: 0,
87
+ });
88
+ },
89
+ },
90
+ radiusTo: {
91
+ args: { radius: ItemGrid.hinted(300, { min: 0 }) },
92
+ run: (timeline, s) => timeline.tween({ radius: timeline.args.radius ?? s.radius }),
93
+ },
94
+ /** Dolly the camera: a shorter focal length exaggerates the depth, a longer one flattens it. */
95
+ focalLengthTo: {
96
+ args: { focalLength: ItemGrid.hinted(600, { min: 100 }) },
97
+ run: (timeline, s) => timeline.tween({ focalLength: timeline.args.focalLength ?? s.focalLength }),
98
+ },
99
+ },
100
+ ...ItemGrid.fields(arranger),
101
+ }), arranger);
102
+ //# sourceMappingURL=sphere-grid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sphere-grid.js","sourceRoot":"","sources":["../../src/sphere-grid/sphere-grid.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,GAMN,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,WAAW,GAGZ,MAAM,QAAQ,CAAA;AAEf,MAAM,GAAG,GAAG;IACV,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC9C,GAAG,EAAE,KAAK,CAAC,MAAM,CA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AAC;oBAC5C,KAAK,EAAE,CAAC,CAAC,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;oBACpD,IAAI,EAAE,CAAC;iBACR,CAAC,CAAA;YACJ,CAAC;SACF;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE;YAClD,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;SACnF;QACD,gGAAgG;QAChG,aAAa,EAAE;YACb,IAAI,EAAE,EAAE,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE;YACzD,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;SAClG;KACF;IACD,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC;CAC7B,CAAC,EAAE,QAAQ,CAAC,CAAA","sourcesContent":["import {\n component2d,\n Types,\n type NodeOf,\n type Values,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n} from \"@motionscript/sdk\"\n\nimport {\n ItemGrid,\n normalizeOrder,\n SPHERE_AXES,\n SPHERE_FACINGS,\n sphereFaceForward,\n wrapDegrees,\n type SphereArrangement,\n type SphereAxis,\n} from \"../kit\"\n\nconst own = {\n radius: Types.number(220, { min: 0, step: 1 }),\n yaw: Types.number(0, { step: 1, unit: \"°\" }),\n pitch: Types.number(0, { step: 1, unit: \"°\" }),\n roll: Types.number(0, { step: 1, unit: \"°\" }),\n facing: Types.oneOf(SPHERE_FACINGS, { default: \"outward\" }),\n focalLength: Types.number(900, { min: 100, step: 10 }),\n depthFade: Types.number(0.5, { min: 0, max: 1, step: 0.05 }),\n cullBackfaces: false,\n spinSpeed: Types.number(0, { step: 1, unit: \"°/s\" }),\n}\n\ntype Own = Values<typeof own>\n\nfunction arrangement(s: Own): SphereArrangement {\n return {\n kind: \"sphere\",\n radius: s.radius,\n yaw: s.yaw,\n pitch: s.pitch,\n roll: s.roll,\n facing: s.facing,\n focalLength: s.focalLength,\n depthFade: s.depthFade,\n cullBackfaces: s.cullBackfaces,\n spinSpeed: s.spinSpeed,\n }\n}\n\nconst arranger: ItemGrid.Arranger<Own> = { arrangement }\n\nconst AXIS_PROP: Record<SphereAxis, \"yaw\" | \"pitch\" | \"roll\"> = { x: \"pitch\", y: \"yaw\", z: \"roll\" }\n\n/**\n * Children spread over a sphere — a Fibonacci lattice, as even as any number\n * of points gets — and seen through a camera of the grid's own, so the far\n * side is smaller, drawn first, and hidden where a face turns away.\n *\n * `outward` lays each item flat on the surface; `billboard` keeps each one\n * facing the viewer, like labels on a globe. `turnTo` brings any item round\n * to the front.\n */\nexport const SphereGrid = ItemGrid.define(component2d({\n key: \"sphereGrid\",\n state: { ...ItemGrid.state, ...own },\n defaults: ItemGrid.defaults,\n commands: {\n ...ItemGrid.commands,\n /** Turn the sphere about an axis by `degrees` — `y` spins it like a globe. */\n spin: {\n args: {\n axis: Types.oneOf(SPHERE_AXES, { default: \"y\" }),\n degrees: Types.number(360, { step: 15, unit: \"°\" }),\n },\n run: (timeline, s) => {\n const key = AXIS_PROP[timeline.args.axis ?? \"y\"] ?? \"yaw\"\n return timeline.tween({ [key]: s[key] + (timeline.args.degrees ?? 360) })\n },\n },\n /** Turn the sphere to a set orientation. */\n orientTo: {\n args: {\n yaw: ItemGrid.hinted(45, { unit: \"°\" }),\n pitch: ItemGrid.hinted(20, { unit: \"°\" }),\n roll: ItemGrid.hinted(0, { unit: \"°\" }),\n },\n run: (timeline, s) => timeline.tween({\n yaw: timeline.args.yaw ?? s.yaw,\n pitch: timeline.args.pitch ?? s.pitch,\n roll: timeline.args.roll ?? s.roll,\n }),\n },\n /**\n * Turn the sphere the shorter way until an item (by its place in the layers)\n * faces the viewer. It turns from the orientation the sphere is given: the\n * yaw its `spinSpeed` adds by the time the command runs is not counted, as\n * commands are built against the tree standing at time 0.\n */\n turnTo: {\n args: { item: Types.number(0, { min: 0, step: 1 }) },\n run: (timeline, s, children) => {\n const count = children.length\n const slot = normalizeOrder(s.order, count).indexOf(Math.round(timeline.args.item ?? 0))\n if (slot < 0) return timeline.tween({})\n const facing = sphereFaceForward(count, slot)\n return timeline.tween({\n yaw: s.yaw + wrapDegrees(facing.yaw - s.yaw),\n pitch: s.pitch + wrapDegrees(facing.pitch - s.pitch),\n roll: 0,\n })\n },\n },\n radiusTo: {\n args: { radius: ItemGrid.hinted(300, { min: 0 }) },\n run: (timeline, s) => timeline.tween({ radius: timeline.args.radius ?? s.radius }),\n },\n /** Dolly the camera: a shorter focal length exaggerates the depth, a longer one flattens it. */\n focalLengthTo: {\n args: { focalLength: ItemGrid.hinted(600, { min: 100 }) },\n run: (timeline, s) => timeline.tween({ focalLength: timeline.args.focalLength ?? s.focalLength }),\n },\n },\n ...ItemGrid.fields(arranger),\n}), arranger)\n\nexport type SphereGrid = NodeOf<typeof SphereGrid>\n/** What a call or a document row may set. */\nexport type SphereGridProps = NonNullable<Parameters<typeof SphereGrid>[0]>\n"]}
package/package.json CHANGED
@@ -1,6 +1,75 @@
1
1
  {
2
2
  "name": "@motionscript/grids",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.10",
4
+ "type": "module",
5
+ "description": "Grid layouts for Motion Script: rectangular, radial, path and spherical arrangements of a node's children, with staggered reveals, waves, focus and morphs between them.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/motionscript-dev/motionscript.git",
9
+ "directory": "packages/components/grids"
10
+ },
11
+ "homepage": "https://motionscript.dev",
12
+ "bugs": {
13
+ "url": "https://github.com/motionscript-dev/motionscript/issues"
14
+ },
15
+ "main": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "sideEffects": false,
18
+ "files": [
19
+ "NOTICE",
20
+ "dist",
21
+ "src",
22
+ "registry.json",
23
+ "CHANGELOG.md",
24
+ "!dist/**/*.tsbuildinfo",
25
+ "!src/**/tests/**",
26
+ "!src/**/*.test.ts",
27
+ "!src/**/*.test.tsx",
28
+ "!src/**/*.fixtures.ts"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "default": "./dist/index.js"
37
+ },
38
+ "./kit": {
39
+ "types": "./dist/engine.d.ts",
40
+ "default": "./dist/engine.js"
41
+ }
42
+ },
43
+ "keywords": [
44
+ "motion-script",
45
+ "motion script",
46
+ "grid",
47
+ "layout",
48
+ "animation"
49
+ ],
50
+ "license": "Apache-2.0",
51
+ "author": "Motionscript",
52
+ "peerDependencies": {
53
+ "@motionscript/sdk": "^0.1.0-alpha.10"
54
+ },
55
+ "devDependencies": {
56
+ "@types/node": "^25.6.2",
57
+ "eslint": "^9.39.4",
58
+ "eslint-import-resolver-typescript": "^4.4.4",
59
+ "eslint-plugin-import-x": "^4.16.1",
60
+ "tsc-alias": "^1.8.16",
61
+ "typescript": "^6.0.3",
62
+ "typescript-eslint": "^8.48.0",
63
+ "vitest": "^4.1.5",
64
+ "@motionscript/core": "0.1.0-alpha.10",
65
+ "@motionscript/sdk": "0.1.0-alpha.10"
66
+ },
67
+ "scripts": {
68
+ "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths && node ../../../scripts/build-browser.mjs",
69
+ "dev": "tsc -p tsconfig.build.json --watch & tsc-alias -p tsconfig.build.json --resolve-full-paths -w",
70
+ "clean": "rimraf --glob dist .turbo *.tsbuildinfo",
71
+ "test": "vitest",
72
+ "lint": "eslint .",
73
+ "typecheck": "tsc -p tsconfig.json --noEmit"
74
+ }
6
75
  }
package/registry.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "kit": {
3
+ "barrel": "src/engine.ts",
4
+ "specifier": "@motionscript/grids/kit"
5
+ },
6
+ "items": [
7
+ {
8
+ "name": "rectangular-grid",
9
+ "description": "Children in rows and columns, with brick offsets and cells that fit, fix or fill.",
10
+ "root": "src/rectangular-grid",
11
+ "files": ["index.ts", "rectangular-grid.ts"]
12
+ },
13
+ {
14
+ "name": "radial-grid",
15
+ "description": "Children round a circle or along an arc, turned to face out if you like.",
16
+ "root": "src/radial-grid",
17
+ "files": ["index.ts", "radial-grid.ts"]
18
+ },
19
+ {
20
+ "name": "path-grid",
21
+ "description": "Children spaced along a template, a path of their own, or a Path node in the scene.",
22
+ "root": "src/path-grid",
23
+ "files": ["index.ts", "path-grid.ts"]
24
+ },
25
+ {
26
+ "name": "sphere-grid",
27
+ "description": "Children spread evenly over a sphere, seen through a camera of its own.",
28
+ "root": "src/sphere-grid",
29
+ "files": ["index.ts", "sphere-grid.ts"]
30
+ }
31
+ ]
32
+ }
package/src/engine.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The item grid **kit**: what the four grids share, and what a copied one does
3
+ * not copy.
4
+ *
5
+ * A copy takes a grid's own files into your project and rewrites its reach for
6
+ * these to `@motionscript/grids`, so the shared parts stay a real
7
+ * dependency. That is not a size decision. `ItemGrid` keeps the register of
8
+ * grids a morph looks another grid's arrangement up in, so a second copy of it
9
+ * would be a second register, and a morph from one grid to another would only
10
+ * find the grids its own copy was told of.
11
+ */
12
+ export * from "./kit"
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./rectangular-grid"
2
+ export * from "./radial-grid"
3
+ export * from "./path-grid"
4
+ export * from "./sphere-grid"
5
+ export * from "./engine"
6
+ export { NODES } from "./nodes"
@@ -0,0 +1,18 @@
1
+ export * from "./slots"
2
+ export * from "./stagger"
3
+ export * from "./item-effects"
4
+ export * from "./order"
5
+ export * from "./random"
6
+ export * as ItemGrid from "./item-grid"
7
+ export {
8
+ contentBoxOf,
9
+ ITEM_GRID_TYPES,
10
+ staggerArgs,
11
+ TRANSITION_STAGGER,
12
+ type GridSnapshot,
13
+ type GridTransition,
14
+ type StaggerArgs,
15
+ } from "./item-grid"
16
+
17
+ // Once this kit's own; kept on its barrel for whoever imports them from it.
18
+ export { findNode2D, frameIn } from "@motionscript/sdk"
@@ -0,0 +1,114 @@
1
+ import type { Size2D } from "@motionscript/sdk"
2
+
3
+ import type { Slot } from "./slots"
4
+
5
+ /**
6
+ * What an item does on its way in (or out): grow from nothing, fade, fly out of
7
+ * the grid's centre, rise into place, flip up, or spin in.
8
+ */
9
+ export const REVEAL_STYLES = ["scale", "fade", "center", "rise", "flip", "spin"] as const
10
+ export type RevealStyle = (typeof REVEAL_STYLES)[number]
11
+
12
+ /** What a wave does to each item as it passes. */
13
+ export const WAVE_STYLES = ["scale", "lift", "fade", "spin"] as const
14
+ export type WaveStyle = (typeof WAVE_STYLES)[number]
15
+
16
+ /**
17
+ * How far into view each item is, `1` shown and `0` gone — past `1` on the
18
+ * way to it under an overshooting ease. Absent means every item is shown.
19
+ */
20
+ export interface RevealState {
21
+ style: RevealStyle
22
+ values: readonly number[]
23
+ }
24
+
25
+ /** Each item's share of the wave passing through it, `0` at rest and `1` at the crest. */
26
+ export interface WaveState {
27
+ style: WaveStyle
28
+ /** How big the crest is — a share of the item's size, opacity or a turn, by style. */
29
+ amount: number
30
+ values: readonly number[]
31
+ }
32
+
33
+ /** Each item's emphasis: `1` the focus, `-1` pushed back, `0` untouched. */
34
+ export interface FocusState {
35
+ /** How far the others fade, `0..1`. */
36
+ dim: number
37
+ /** How much the focus grows, as a share of its size; the others shrink by half that. */
38
+ grow: number
39
+ values: readonly number[]
40
+ }
41
+
42
+ /** Layer item `i`'s reveal, wave and focus onto its slot, in place. */
43
+ export function applyItemEffects(
44
+ s: Slot,
45
+ i: number,
46
+ size: Size2D,
47
+ reveal: RevealState | null | undefined,
48
+ wave: WaveState | null | undefined,
49
+ focus: FocusState | null | undefined,
50
+ ): void {
51
+ if (reveal) applyReveal(s, reveal.style, reveal.values[i] ?? 1, size)
52
+ if (wave) applyWave(s, wave, wave.values[i] ?? 0, size)
53
+ if (focus) applyFocus(s, focus, focus.values[i] ?? 0)
54
+ }
55
+
56
+ function applyReveal(s: Slot, style: RevealStyle, v: number, size: Size2D): void {
57
+ if (v === 1) return
58
+ const shown = clamp01(v)
59
+ switch (style) {
60
+ case "fade":
61
+ s.opacity *= shown
62
+ break
63
+ case "center":
64
+ s.x *= v
65
+ s.y *= v
66
+ s.depth *= v
67
+ s.opacity *= clamp01(v * 4)
68
+ break
69
+ case "rise":
70
+ s.y -= (1 - v) * Math.max(40, size.height)
71
+ s.opacity *= shown
72
+ break
73
+ case "flip":
74
+ s.rotationX += (1 - v) * 90
75
+ break
76
+ case "spin":
77
+ s.rotation -= (1 - v) * 180
78
+ s.scale *= Math.max(0, v)
79
+ break
80
+ default:
81
+ s.scale *= Math.max(0, v)
82
+ }
83
+ }
84
+
85
+ function applyWave(s: Slot, wave: WaveState, w: number, size: Size2D): void {
86
+ if (w === 0) return
87
+ switch (wave.style) {
88
+ case "lift":
89
+ s.y += wave.amount * w * Math.max(40, size.height)
90
+ break
91
+ case "fade":
92
+ s.opacity *= clamp01(1 - wave.amount * w)
93
+ break
94
+ case "spin":
95
+ s.rotation += wave.amount * w * 360
96
+ break
97
+ default:
98
+ s.scale *= 1 + wave.amount * w
99
+ }
100
+ }
101
+
102
+ function applyFocus(s: Slot, focus: FocusState, f: number): void {
103
+ if (f === 0) return
104
+ if (f > 0) {
105
+ s.scale *= 1 + focus.grow * f
106
+ return
107
+ }
108
+ s.opacity *= clamp01(1 - focus.dim * -f)
109
+ s.scale *= Math.max(0, 1 + focus.grow * 0.5 * f)
110
+ }
111
+
112
+ function clamp01(v: number): number {
113
+ return v < 0 ? 0 : v > 1 ? 1 : v
114
+ }