@runtypelabs/terminal-animations 0.1.1 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/terminal-animations",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Terminal loading animations for Runtype CLI — AnimatedVariant, LoadingAnimation, and variant library.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/components.js CHANGED
@@ -19,11 +19,27 @@ const createVariantComponent = variantId => {
19
19
 
20
20
  export const animationIds = variantNames;
21
21
 
22
- export const AnimationGrid = ({grid}) =>
22
+ export const scaleGrid = (grid, scale = 1) => {
23
+ const normalizedScale = Number.isInteger(scale) && scale > 1 ? scale : 1;
24
+ if (normalizedScale === 1) {
25
+ return grid;
26
+ }
27
+
28
+ return grid.flatMap(row => {
29
+ const scaledRow = row.map(cell => ({
30
+ ...cell,
31
+ text: typeof cell.text === "string" ? cell.text.repeat(normalizedScale) : cell.text
32
+ }));
33
+
34
+ return Array.from({length: normalizedScale}, () => scaledRow.map(cell => ({...cell})));
35
+ });
36
+ };
37
+
38
+ export const AnimationGrid = ({grid, scale = 1}) =>
23
39
  React.createElement(
24
40
  Box,
25
41
  {flexDirection: "column"},
26
- ...grid.map((row, rowIndex) =>
42
+ ...scaleGrid(grid, scale).map((row, rowIndex) =>
27
43
  React.createElement(
28
44
  Box,
29
45
  {key: `row-${rowIndex}`},
@@ -49,7 +65,10 @@ export const AnimatedVariant = ({
49
65
  frame: controlledFrame,
50
66
  initialFrame = 0,
51
67
  speed,
52
- autoplay = true
68
+ autoplay = true,
69
+ scale = 1,
70
+ width,
71
+ height
53
72
  }) => {
54
73
  const variant = useMemo(() => getVariant(variantId), [variantId]);
55
74
  const [localFrame, setLocalFrame] = useState(initialFrame);
@@ -80,9 +99,9 @@ export const AnimatedVariant = ({
80
99
  }
81
100
 
82
101
  const frame = controlledFrame ?? localFrame;
83
- const grid = variant.painter(frame);
102
+ const grid = variant.painter(frame, {width, height});
84
103
 
85
- return React.createElement(AnimationGrid, {grid});
104
+ return React.createElement(AnimationGrid, {grid, scale});
86
105
  };
87
106
 
88
107
  export const NeonPulse = createVariantComponent("neon-pulse");
@@ -95,6 +114,7 @@ export const QuantumLag = createVariantComponent("quantum-lag");
95
114
  export const SignalBloom = createVariantComponent("signal-bloom");
96
115
  export const GhostShell = createVariantComponent("ghost-shell");
97
116
  export const CoreBreach = createVariantComponent("core-breach");
117
+ export const StartupGridIconCompactLightInverted = createVariantComponent("startup-grid-icon-compact-light-inverted");
98
118
 
99
119
  export const animationComponents = {
100
120
  NeonPulse,
@@ -106,5 +126,5 @@ export const animationComponents = {
106
126
  QuantumLag,
107
127
  SignalBloom,
108
128
  GhostShell,
109
- CoreBreach
129
+ CoreBreach,
110
130
  };
@@ -0,0 +1,506 @@
1
+ const DEFAULT_CANVAS_WIDTH = 64;
2
+ const DEFAULT_CANVAS_HEIGHT = 30;
3
+ const BG = "#010204";
4
+
5
+ const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
6
+ const lerp = (start, end, amount) => start + (end - start) * amount;
7
+ const mod = (value, divisor) => {
8
+ const result = value % divisor;
9
+ return result < 0 ? result + divisor : result;
10
+ };
11
+
12
+ const rgb = (r, g, b) => ({
13
+ r: clamp(Math.round(r), 0, 255),
14
+ g: clamp(Math.round(g), 0, 255),
15
+ b: clamp(Math.round(b), 0, 255)
16
+ });
17
+
18
+ const hexToRgb = hex => {
19
+ const normalized = hex.replace("#", "");
20
+ return rgb(
21
+ Number.parseInt(normalized.slice(0, 2), 16),
22
+ Number.parseInt(normalized.slice(2, 4), 16),
23
+ Number.parseInt(normalized.slice(4, 6), 16)
24
+ );
25
+ };
26
+
27
+ const rgbToHex = color =>
28
+ `#${[color.r, color.g, color.b]
29
+ .map(channel => channel.toString(16).padStart(2, "0"))
30
+ .join("")}`;
31
+
32
+ const mixRgb = (left, right, amount) =>
33
+ rgb(
34
+ lerp(left.r, right.r, amount),
35
+ lerp(left.g, right.g, amount),
36
+ lerp(left.b, right.b, amount)
37
+ );
38
+
39
+ const makeCell = (
40
+ text,
41
+ color = "#ffffff",
42
+ backgroundColor = BG,
43
+ dimColor = false,
44
+ bold = false
45
+ ) => ({
46
+ text,
47
+ color,
48
+ backgroundColor,
49
+ dimColor,
50
+ bold
51
+ });
52
+
53
+ const blankCell = (backgroundColor = BG) =>
54
+ makeCell(" ", backgroundColor, backgroundColor, true, false);
55
+
56
+ const renderCanvas = (height, width, painter) => {
57
+ const rows = [];
58
+
59
+ for (let row = 0; row < height; row += 1) {
60
+ const columns = [];
61
+
62
+ for (let column = 0; column < width; column += 1) {
63
+ columns.push(painter(row, column));
64
+ }
65
+
66
+ rows.push(columns);
67
+ }
68
+
69
+ return rows;
70
+ };
71
+
72
+ const createGrid = (width, height) =>
73
+ Array.from({length: height}, () =>
74
+ Array.from({length: width}, () => ({
75
+ h: 0,
76
+ v: 0,
77
+ d1: 0,
78
+ d2: 0,
79
+ weight: 0,
80
+ depthSum: 0,
81
+ depthMin: Number.POSITIVE_INFINITY
82
+ }))
83
+ );
84
+
85
+ const vec3 = (x, y, z) => ({x, y, z});
86
+
87
+ const rotateX = (point, angle) => {
88
+ const cosine = Math.cos(angle);
89
+ const sine = Math.sin(angle);
90
+ return {
91
+ x: point.x,
92
+ y: point.y * cosine - point.z * sine,
93
+ z: point.y * sine + point.z * cosine
94
+ };
95
+ };
96
+
97
+ const rotateY = (point, angle) => {
98
+ const cosine = Math.cos(angle);
99
+ const sine = Math.sin(angle);
100
+ return {
101
+ x: point.x * cosine + point.z * sine,
102
+ y: point.y,
103
+ z: -point.x * sine + point.z * cosine
104
+ };
105
+ };
106
+
107
+ const transformPoint = (point, options = {}) => {
108
+ let transformed = point;
109
+
110
+ if (options.rotateX) {
111
+ transformed = rotateX(transformed, options.rotateX);
112
+ }
113
+
114
+ if (options.rotateY) {
115
+ transformed = rotateY(transformed, options.rotateY);
116
+ }
117
+
118
+ return {
119
+ x: transformed.x + (options.translateX ?? 0),
120
+ y: transformed.y + (options.translateY ?? 0),
121
+ z: transformed.z + (options.translateZ ?? 0)
122
+ };
123
+ };
124
+
125
+ const pushSegment = (segments, start, end, tint = null) => {
126
+ segments.push({start, end, tint});
127
+ };
128
+
129
+ const appendTransformedSegments = (target, source, transform, tint = null) => {
130
+ for (const segment of source) {
131
+ pushSegment(
132
+ target,
133
+ transformPoint(segment.start, transform),
134
+ transformPoint(segment.end, transform),
135
+ tint ?? segment.tint ?? null
136
+ );
137
+ }
138
+ };
139
+
140
+ const createCuboidSegments = (width, height, depth, tint = null) => {
141
+ const x = width / 2;
142
+ const y = height / 2;
143
+ const z = depth / 2;
144
+ const points = [
145
+ vec3(-x, -y, -z),
146
+ vec3(x, -y, -z),
147
+ vec3(x, y, -z),
148
+ vec3(-x, y, -z),
149
+ vec3(-x, -y, z),
150
+ vec3(x, -y, z),
151
+ vec3(x, y, z),
152
+ vec3(-x, y, z)
153
+ ];
154
+ const edges = [
155
+ [0, 1],
156
+ [1, 2],
157
+ [2, 3],
158
+ [3, 0],
159
+ [4, 5],
160
+ [5, 6],
161
+ [6, 7],
162
+ [7, 4],
163
+ [0, 4],
164
+ [1, 5],
165
+ [2, 6],
166
+ [3, 7]
167
+ ];
168
+
169
+ return edges.map(([start, end]) => ({
170
+ start: points[start],
171
+ end: points[end],
172
+ tint
173
+ }));
174
+ };
175
+
176
+ const createFloorGridSegments = ({
177
+ width = 8,
178
+ depth = 24,
179
+ step = 2,
180
+ y = -2,
181
+ zStart = 0,
182
+ tint = null
183
+ } = {}) => {
184
+ const segments = [];
185
+ const halfWidth = width / 2;
186
+
187
+ for (let x = -halfWidth; x <= halfWidth + 0.001; x += step) {
188
+ pushSegment(segments, vec3(x, y, zStart), vec3(x, y, zStart + depth), tint);
189
+ }
190
+
191
+ for (let z = zStart; z <= zStart + depth + 0.001; z += step) {
192
+ pushSegment(segments, vec3(-halfWidth, y, z), vec3(halfWidth, y, z), tint);
193
+ }
194
+
195
+ return segments;
196
+ };
197
+
198
+ const projectPoint = (point, camera, width, height) => {
199
+ const relative = {
200
+ x: point.x - camera.x,
201
+ y: point.y - camera.y,
202
+ z: point.z - camera.z
203
+ };
204
+ const yawed = rotateY(relative, -(camera.yaw ?? 0));
205
+ const pitched = rotateX(yawed, -(camera.pitch ?? 0));
206
+
207
+ if (pitched.z < 0.4) {
208
+ return null;
209
+ }
210
+
211
+ const fov = camera.fov ?? 1.2;
212
+ const scale = fov / pitched.z;
213
+ return {
214
+ x: Math.round(width / 2 + pitched.x * scale * width * 0.5),
215
+ y: Math.round(height * 0.53 - pitched.y * scale * height * 0.75),
216
+ z: pitched.z
217
+ };
218
+ };
219
+
220
+ const plotProjectedLine = (grid, start, end, depth, tint = null) => {
221
+ const steps = Math.max(Math.abs(end.x - start.x), Math.abs(end.y - start.y), 1);
222
+ const deltaX = end.x - start.x;
223
+ const deltaY = end.y - start.y;
224
+ const angle = Math.atan2(deltaY, deltaX);
225
+ const diagonalDown =
226
+ Math.abs(angle - Math.PI / 4) < Math.PI / 8 || Math.abs(angle + (3 * Math.PI) / 4) < Math.PI / 8;
227
+ const diagonalUp =
228
+ Math.abs(angle + Math.PI / 4) < Math.PI / 8 || Math.abs(angle - (3 * Math.PI) / 4) < Math.PI / 8;
229
+ const horizontal = Math.abs(deltaX) >= Math.abs(deltaY) * 1.4;
230
+ const vertical = Math.abs(deltaY) >= Math.abs(deltaX) * 1.4;
231
+
232
+ for (let step = 0; step <= steps; step += 1) {
233
+ const x = Math.round(start.x + (deltaX * step) / steps);
234
+ const y = Math.round(start.y + (deltaY * step) / steps);
235
+ const cell = grid[y]?.[x];
236
+
237
+ if (!cell) {
238
+ continue;
239
+ }
240
+
241
+ if (horizontal) {
242
+ cell.h += 1;
243
+ }
244
+
245
+ if (vertical) {
246
+ cell.v += 1;
247
+ }
248
+
249
+ if (diagonalDown) {
250
+ cell.d2 += 1;
251
+ }
252
+
253
+ if (diagonalUp) {
254
+ cell.d1 += 1;
255
+ }
256
+
257
+ if (!horizontal && !vertical && !diagonalDown && !diagonalUp) {
258
+ if (Math.abs(deltaX) > Math.abs(deltaY)) {
259
+ cell.h += 1;
260
+ } else {
261
+ cell.v += 1;
262
+ }
263
+ }
264
+
265
+ cell.weight += 1;
266
+ cell.depthSum += depth;
267
+ cell.depthMin = Math.min(cell.depthMin, depth);
268
+
269
+ if (tint) {
270
+ cell.tint = tint;
271
+ }
272
+ }
273
+ };
274
+
275
+ const resolveGlyph = cell => {
276
+ const active = [cell.h > 0, cell.v > 0, cell.d1 > 0, cell.d2 > 0].filter(Boolean).length;
277
+
278
+ if (active === 0) {
279
+ return " ";
280
+ }
281
+
282
+ if (cell.d1 > 0 && cell.d2 > 0) {
283
+ return "╳";
284
+ }
285
+
286
+ if ((cell.h > 0 && cell.v > 0) || active > 2) {
287
+ return "┼";
288
+ }
289
+
290
+ if (cell.h > 0) {
291
+ return "─";
292
+ }
293
+
294
+ if (cell.v > 0) {
295
+ return "│";
296
+ }
297
+
298
+ if (cell.d1 > 0) {
299
+ return "╱";
300
+ }
301
+
302
+ return "╲";
303
+ };
304
+
305
+ const resolveCanvasSize = viewport => {
306
+ if (!viewport?.width || !viewport?.height) {
307
+ return {
308
+ width: DEFAULT_CANVAS_WIDTH,
309
+ height: DEFAULT_CANVAS_HEIGHT
310
+ };
311
+ }
312
+
313
+ return {
314
+ // Variant cells are rendered as two-character-wide glyphs, so fit them to
315
+ // the current terminal width before projection to avoid wrapping.
316
+ width: Math.max(1, Math.floor(viewport.width / 2)),
317
+ height: Math.max(1, Math.floor(viewport.height))
318
+ };
319
+ };
320
+
321
+ const renderScene = ({
322
+ frame,
323
+ tint,
324
+ accent,
325
+ background,
326
+ camera,
327
+ buildSegments,
328
+ lineContrast = 1
329
+ }, viewport) => {
330
+ const canvas = resolveCanvasSize(viewport);
331
+ const grid = createGrid(canvas.width, canvas.height);
332
+ const bgTop = hexToRgb(background[0]);
333
+ const bgBottom = hexToRgb(background[1]);
334
+ const segments = buildSegments(frame, canvas);
335
+
336
+ for (const segment of segments) {
337
+ const projectedStart = projectPoint(segment.start, camera, canvas.width, canvas.height);
338
+ const projectedEnd = projectPoint(segment.end, camera, canvas.width, canvas.height);
339
+
340
+ if (!projectedStart || !projectedEnd) {
341
+ continue;
342
+ }
343
+
344
+ const depth = (projectedStart.z + projectedEnd.z) / 2;
345
+ plotProjectedLine(grid, projectedStart, projectedEnd, depth, segment.tint ?? null);
346
+ }
347
+
348
+ const tintRgb = hexToRgb(tint);
349
+ const accentRgb = hexToRgb(accent);
350
+
351
+ return renderCanvas(canvas.height, canvas.width, (row, column) => {
352
+ const cell = grid[row][column];
353
+ const glyph = resolveGlyph(cell);
354
+ const verticalBlend = row / Math.max(1, canvas.height - 1);
355
+ const backgroundColor = mixRgb(bgTop, bgBottom, verticalBlend);
356
+
357
+ if (glyph === " ") {
358
+ return blankCell(rgbToHex(backgroundColor));
359
+ }
360
+
361
+ const averageDepth = cell.depthSum / Math.max(1, cell.weight);
362
+ const near = clamp(1 - (averageDepth - 1) / 18, 0, 1);
363
+ const baseTint = cell.tint ? hexToRgb(cell.tint) : tintRgb;
364
+ const color = mixRgb(baseTint, accentRgb, near * 0.55);
365
+ const finalColor = mixRgb(
366
+ backgroundColor,
367
+ mixRgb(hexToRgb("#253242"), color, clamp(0.35 + near * 0.75, 0, 1)),
368
+ lineContrast
369
+ );
370
+
371
+ return makeCell(
372
+ glyph.repeat(2),
373
+ rgbToHex(finalColor),
374
+ rgbToHex(backgroundColor),
375
+ near < 0.25,
376
+ cell.weight > 1 || near > 0.75
377
+ );
378
+ });
379
+ };
380
+
381
+ const ghostWaveSegments = (frame, canvas) => {
382
+ const segments = [];
383
+ const time = frame * 0.05;
384
+ const fieldWidth = Math.max(18, canvas.width * 0.375);
385
+ const depth = Math.max(28, canvas.height * 1.2);
386
+ const xStep = fieldWidth / Math.max(14, Math.floor(canvas.width / 4));
387
+ const zStep = depth / Math.max(16, Math.floor(canvas.height / 1.6));
388
+ const waveHeight = (x, z) =>
389
+ Math.sin(x * 0.42 + time * 1.3) * 0.85 +
390
+ Math.cos(z * 0.28 - time * 1.1) * 0.7 +
391
+ Math.sin((x + z) * 0.18 + time * 0.7) * 0.45;
392
+
393
+ for (let z = 3; z <= depth + 0.001; z += zStep) {
394
+ let previous = null;
395
+ for (let x = -fieldWidth / 2; x <= fieldWidth / 2 + 0.001; x += xStep) {
396
+ const point = vec3(x, waveHeight(x, z), z);
397
+ if (previous) {
398
+ pushSegment(segments, previous, point, "#2a3946");
399
+ }
400
+ previous = point;
401
+ }
402
+ }
403
+
404
+ for (let x = -fieldWidth / 2; x <= fieldWidth / 2 + 0.001; x += xStep * 2) {
405
+ let previous = null;
406
+ for (let z = 3; z <= depth + 0.001; z += zStep) {
407
+ const point = vec3(x, waveHeight(x, z), z);
408
+ if (previous) {
409
+ pushSegment(segments, previous, point, "#334754");
410
+ }
411
+ previous = point;
412
+ }
413
+ }
414
+
415
+ return segments;
416
+ };
417
+
418
+ const ghostBoxDriftSegments = (frame, canvas) => {
419
+ const segments = [];
420
+ const time = frame * 0.04;
421
+ const floorWidth = Math.max(18, canvas.width * 0.32);
422
+ const depth = Math.max(28, canvas.height * 1.15);
423
+ const sweepWidth = floorWidth * 0.45;
424
+ const baseSize = Math.max(2.4, floorWidth * 0.14);
425
+ const boxes = [
426
+ {size: [baseSize * 0.9, 2.2, baseSize * 0.9], z: depth * 0.24, lane: 0, tint: "#2c3946"},
427
+ {size: [baseSize * 1.15, 2.8, baseSize], z: depth * 0.36, lane: floorWidth * 0.08, tint: "#31404d"},
428
+ {size: [baseSize * 0.78, 1.9, baseSize * 0.78], z: depth * 0.47, lane: -floorWidth * 0.07, tint: "#2a3541"},
429
+ {size: [baseSize * 1.35, 3.1, baseSize * 1.2], z: depth * 0.62, lane: floorWidth * 0.04, tint: "#364754"},
430
+ {size: [baseSize, 2.4, baseSize], z: depth * 0.78, lane: -floorWidth * 0.09, tint: "#2f3c49"}
431
+ ];
432
+
433
+ appendTransformedSegments(
434
+ segments,
435
+ createFloorGridSegments({
436
+ width: floorWidth,
437
+ depth,
438
+ step: Math.max(1.8, floorWidth / 10),
439
+ y: -2.8,
440
+ zStart: 3,
441
+ tint: "#16202a"
442
+ }),
443
+ {},
444
+ "#16202a"
445
+ );
446
+
447
+ for (const box of boxes) {
448
+ const sweep = mod(time * (0.9 + box.z * 0.015) + box.z * 0.12, 2) - 1;
449
+ const x = sweep * sweepWidth + box.lane;
450
+ const bob = Math.sin(time * 1.7 + box.z * 0.3) * 0.28;
451
+
452
+ appendTransformedSegments(
453
+ segments,
454
+ createCuboidSegments(box.size[0], box.size[1], box.size[2], box.tint),
455
+ {
456
+ rotateY: time * 0.45 + box.z * 0.05,
457
+ rotateX: 0.08 + Math.sin(time + box.z * 0.2) * 0.05,
458
+ translateX: x,
459
+ translateY: -1.1 + bob,
460
+ translateZ: box.z
461
+ },
462
+ box.tint
463
+ );
464
+ }
465
+
466
+ return segments;
467
+ };
468
+
469
+ export const ghostVectorVariants = {
470
+ "vector3d-ghost-wave": {
471
+ title: "Vector3D Ghost Wave",
472
+ blurb: "A barely-visible full-frame wire wave drifts under a low-contrast camera.",
473
+ speed: 66,
474
+ painter: (frame, viewport) =>
475
+ renderScene(
476
+ {
477
+ frame,
478
+ tint: "#334654",
479
+ accent: "#526878",
480
+ background: ["#010204", "#070d14"],
481
+ camera: {x: 0, y: 1.2, z: 0, yaw: Math.sin(frame * 0.015) * 0.08, pitch: 0.28, fov: 1.26},
482
+ buildSegments: ghostWaveSegments,
483
+ lineContrast: 0.22
484
+ },
485
+ viewport
486
+ )
487
+ },
488
+ "vector3d-ghost-box-drift": {
489
+ title: "Vector3D Ghost Box Drift",
490
+ blurb: "Barely-visible wire cuboids slide left to right across a dark 3D plane.",
491
+ speed: 64,
492
+ painter: (frame, viewport) =>
493
+ renderScene(
494
+ {
495
+ frame,
496
+ tint: "#2f3b48",
497
+ accent: "#4b5f70",
498
+ background: ["#010204", "#060c13"],
499
+ camera: {x: 0, y: 0.55, z: 0, yaw: Math.sin(frame * 0.012) * 0.05, pitch: 0.18, fov: 1.24},
500
+ buildSegments: ghostBoxDriftSegments,
501
+ lineContrast: 0.18
502
+ },
503
+ viewport
504
+ )
505
+ }
506
+ };
package/src/icon.js CHANGED
@@ -91,5 +91,8 @@ export const VARIANT_ORDER = [
91
91
  "quantum-lag",
92
92
  "signal-bloom",
93
93
  "ghost-shell",
94
- "core-breach"
94
+ "core-breach",
95
+ "startup-grid-icon-compact-light-inverted",
96
+ "vector3d-ghost-wave",
97
+ "vector3d-ghost-box-drift"
95
98
  ];
package/src/index.d.ts CHANGED
@@ -5,6 +5,17 @@ export const LOADING_VARIANTS: readonly string[]
5
5
  export function LoadingAnimation(props?: {
6
6
  width?: number
7
7
  height?: number
8
+ scale?: number
9
+ }): ReactNode
10
+
11
+ export function StartupGridIconCompactLightInverted(props?: {
12
+ frame?: number
13
+ initialFrame?: number
14
+ speed?: number
15
+ autoplay?: boolean
16
+ scale?: number
17
+ width?: number
18
+ height?: number
8
19
  }): ReactNode
9
20
 
10
21
  export function AnimatedVariant(props: {
@@ -13,9 +24,13 @@ export function AnimatedVariant(props: {
13
24
  initialFrame?: number
14
25
  speed?: number
15
26
  autoplay?: boolean
27
+ scale?: number
28
+ width?: number
29
+ height?: number
16
30
  }): ReactNode
17
31
 
18
- export function AnimationGrid(props: { grid: unknown[][] }): ReactNode
32
+ export function AnimationGrid(props: { grid: unknown[][]; scale?: number }): ReactNode
33
+ export function scaleGrid(grid: unknown[][], scale?: number): unknown[][]
19
34
 
20
35
  export const animationIds: readonly string[]
21
36
 
package/src/index.js CHANGED
@@ -1,3 +1,9 @@
1
- export { AnimatedVariant, AnimationGrid, animationIds } from './components.js'
1
+ export {
2
+ AnimatedVariant,
3
+ AnimationGrid,
4
+ animationIds,
5
+ scaleGrid,
6
+ StartupGridIconCompactLightInverted,
7
+ } from './components.js'
2
8
  export { LoadingAnimation, LOADING_VARIANTS } from './loading-animation.js'
3
9
  export { getVariant, variantNames, getAllVariants } from './variants.js'
@@ -18,15 +18,16 @@ export const LOADING_VARIANTS = [
18
18
 
19
19
  const LOGO_WIDTH = 16
20
20
  const LOGO_HEIGHT = 8
21
+ const DEFAULT_LOGO_SCALE = 2
21
22
  const POSITION_TICK_MS = 80
22
23
 
23
24
  function clamp(value, min, max) {
24
25
  return Math.min(max, Math.max(min, value))
25
26
  }
26
27
 
27
- function createInitialMotion(width, height) {
28
- const maxX = Math.max(0, width - LOGO_WIDTH)
29
- const maxY = Math.max(0, height - LOGO_HEIGHT)
28
+ function createInitialMotion(width, height, scaledLogoWidth, scaledLogoHeight) {
29
+ const maxX = Math.max(0, width - scaledLogoWidth)
30
+ const maxY = Math.max(0, height - scaledLogoHeight)
30
31
 
31
32
  return {
32
33
  x: Math.floor(maxX / 2),
@@ -43,21 +44,25 @@ function createInitialMotion(width, height) {
43
44
  export function LoadingAnimation({
44
45
  width = 48,
45
46
  height = 16,
47
+ scale = DEFAULT_LOGO_SCALE,
46
48
  } = {}) {
47
49
  const variantId = useMemo(
48
50
  () => LOADING_VARIANTS[Math.floor(Math.random() * LOADING_VARIANTS.length)],
49
51
  []
50
52
  )
51
- const boundedWidth = Math.max(LOGO_WIDTH, Math.floor(width))
52
- const boundedHeight = Math.max(LOGO_HEIGHT, Math.floor(height))
53
+ const normalizedScale = Number.isInteger(scale) && scale > 0 ? scale : DEFAULT_LOGO_SCALE
54
+ const scaledLogoWidth = LOGO_WIDTH * normalizedScale
55
+ const scaledLogoHeight = LOGO_HEIGHT * normalizedScale
56
+ const boundedWidth = Math.max(scaledLogoWidth, Math.floor(width))
57
+ const boundedHeight = Math.max(scaledLogoHeight, Math.floor(height))
53
58
  const [motion, setMotion] = useState(() =>
54
- createInitialMotion(boundedWidth, boundedHeight)
59
+ createInitialMotion(boundedWidth, boundedHeight, scaledLogoWidth, scaledLogoHeight)
55
60
  )
56
61
 
57
62
  useEffect(() => {
58
63
  setMotion((current) => {
59
- const maxX = Math.max(0, boundedWidth - LOGO_WIDTH)
60
- const maxY = Math.max(0, boundedHeight - LOGO_HEIGHT)
64
+ const maxX = Math.max(0, boundedWidth - scaledLogoWidth)
65
+ const maxY = Math.max(0, boundedHeight - scaledLogoHeight)
61
66
 
62
67
  return {
63
68
  x: clamp(current.x, 0, maxX),
@@ -66,13 +71,13 @@ export function LoadingAnimation({
66
71
  dy: maxY > 0 ? current.dy || 1 : 0,
67
72
  }
68
73
  })
69
- }, [boundedHeight, boundedWidth])
74
+ }, [boundedHeight, boundedWidth, scaledLogoHeight, scaledLogoWidth])
70
75
 
71
76
  useEffect(() => {
72
77
  const timer = globalThis.setInterval(() => {
73
78
  setMotion((current) => {
74
- const maxX = Math.max(0, boundedWidth - LOGO_WIDTH)
75
- const maxY = Math.max(0, boundedHeight - LOGO_HEIGHT)
79
+ const maxX = Math.max(0, boundedWidth - scaledLogoWidth)
80
+ const maxY = Math.max(0, boundedHeight - scaledLogoHeight)
76
81
  let nextX = current.x + current.dx
77
82
  let nextY = current.y + current.dy
78
83
  let nextDx = current.dx
@@ -98,7 +103,7 @@ export function LoadingAnimation({
98
103
  }, POSITION_TICK_MS)
99
104
 
100
105
  return () => globalThis.clearInterval(timer)
101
- }, [boundedHeight, boundedWidth])
106
+ }, [boundedHeight, boundedWidth, scaledLogoHeight, scaledLogoWidth])
102
107
 
103
108
  return React.createElement(
104
109
  Box,
@@ -117,6 +122,7 @@ export function LoadingAnimation({
117
122
  React.createElement(AnimatedVariant, {
118
123
  variantId,
119
124
  autoplay: true,
125
+ scale: normalizedScale,
120
126
  })
121
127
  )
122
128
  )
package/src/variants.js CHANGED
@@ -4,9 +4,18 @@ import {
4
4
  VARIANT_ORDER
5
5
  } from "./icon.js";
6
6
  import {runnerSceneVariants} from "./runner-scenes.js";
7
+ import {ghostVectorVariants} from "./ghost-vector-scenes.js";
7
8
 
8
9
  const ACTIVE_GLYPHS = ["██", "▓▓", "▒▒", "##", "[]", "<>"];
9
10
  const VOID_GLYPHS = [" ", "..", "░░", "::"];
11
+ const VOID_COLOR = "#6d78b8";
12
+ const VOID_PULSE_COLOR = "#7a86c8";
13
+ const VOID_SCANLINE_COLOR = "#88a0c7";
14
+ const VOID_GLITCH_COLOR = "#8d98d8";
15
+ const VOID_SIGNAL_COLOR = "#8b89cc";
16
+ const VOID_GHOST_COLOR = "#6e73c4";
17
+ const VOID_BARRIER_COLOR = "#c96c6c";
18
+ const VOID_SPARK_COLOR = "#d79a54";
10
19
 
11
20
  const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
12
21
 
@@ -27,10 +36,10 @@ const makeCell = (text, color, dimColor = false, bold = false) => ({
27
36
  bold
28
37
  });
29
38
 
30
- const baseVoid = () => makeCell("..", "#1b2238", true, false);
39
+ const baseVoid = () => makeCell("..", VOID_COLOR, true, false);
31
40
 
32
41
  const hueBand = (frame, shift = 0) => {
33
- const palette = ["#6cf2ff", "#7af0b2", "#b6ff6c", "#00ffa7", "#7fdbff"];
42
+ const palette = ["#4cf0ff", "#ff4fd8", "#ffd166", "#6a7cff", "#ff9f1c"];
34
43
  return palette[mod(frame + shift, palette.length)];
35
44
  };
36
45
 
@@ -57,24 +66,47 @@ const renderCanvas = (height, width, painter) => {
57
66
  return rows;
58
67
  };
59
68
 
69
+ const STARTUP_ICON_ACTIVE_COLOR = "#000000";
70
+ const STARTUP_ICON_INACTIVE_COLOR = "#c8c8c8";
71
+ const STARTUP_ICON_CELLS = [
72
+ [0, 0, 0, 0, 0, 0, 0, 0],
73
+ [0, 0, 0, 0, 0, 0, 0, 0],
74
+ [0, 0, 0, 1, 0, 1, 1, 0],
75
+ [0, 0, 0, 1, 1, 0, 0, 1],
76
+ [0, 0, 0, 1, 0, 0, 0, 0],
77
+ [0, 0, 0, 1, 0, 0, 0, 0],
78
+ [0, 0, 0, 1, 0, 0, 0, 0]
79
+ ];
80
+
81
+ const buildStartupGridRows = ({
82
+ glyph = "▒▒",
83
+ activeColor = STARTUP_ICON_ACTIVE_COLOR,
84
+ inactiveColor = STARTUP_ICON_INACTIVE_COLOR
85
+ } = {}) =>
86
+ STARTUP_ICON_CELLS.map(row =>
87
+ row.map(cell =>
88
+ makeCell(glyph, cell ? activeColor : inactiveColor, false, false)
89
+ )
90
+ );
91
+
60
92
  const variants = {
61
93
  "neon-pulse": {
62
94
  title: "Neon Pulse",
63
95
  blurb: "Heartbeat glow with alternating cyan and acid-green charge.",
64
- speed: 90,
96
+ speed: 165,
65
97
  painter: frame =>
66
98
  renderGrid((row, column) => {
67
99
  const pulse = Math.sin((frame + row + column) / 2);
68
100
  if (!isActive(row, column)) {
69
101
  return pulse > 0.75
70
- ? makeCell("░░", "#123047", true, false)
102
+ ? makeCell("░░", VOID_PULSE_COLOR, true, false)
71
103
  : baseVoid();
72
104
  }
73
105
 
74
106
  const bright = pulse > 0.3;
75
107
  return makeCell(
76
108
  bright ? "██" : "▓▓",
77
- bright ? hueBand(frame, row) : "#2ae6ff",
109
+ bright ? hueBand(frame, row) : "#4cf0ff",
78
110
  false,
79
111
  bright
80
112
  );
@@ -83,7 +115,7 @@ const variants = {
83
115
  "scanline-sweep": {
84
116
  title: "Scanline Sweep",
85
117
  blurb: "A terminal scanner sweeps top to bottom and overcharges intersections.",
86
- speed: 75,
118
+ speed: 150,
87
119
  painter: frame =>
88
120
  renderGrid((row, column) => {
89
121
  const sweepRow = mod(frame, GRID_SIZE);
@@ -91,25 +123,25 @@ const variants = {
91
123
 
92
124
  if (!isActive(row, column)) {
93
125
  return delta === 0
94
- ? makeCell("::", "#24495a", true, false)
126
+ ? makeCell("::", VOID_SCANLINE_COLOR, true, false)
95
127
  : baseVoid();
96
128
  }
97
129
 
98
130
  if (delta === 0) {
99
- return makeCell("██", "#d2fff7", false, true);
131
+ return makeCell("██", "#fff1a8", false, true);
100
132
  }
101
133
 
102
134
  if (delta === 1) {
103
135
  return makeCell("▓▓", "#58ffd1", false, false);
104
136
  }
105
137
 
106
- return makeCell("▒▒", "#00c8a2", false, false);
138
+ return makeCell("▒▒", "#58c8ff", false, false);
107
139
  })
108
140
  },
109
141
  "glitch-shift": {
110
142
  title: "Glitch Shift",
111
143
  blurb: "Short digital slips fracture the mark before snapping it back.",
112
- speed: 85,
144
+ speed: 155,
113
145
  painter: frame =>
114
146
  renderGrid((row, column) => {
115
147
  const shiftedColumn =
@@ -118,13 +150,13 @@ const variants = {
118
150
 
119
151
  if (!on) {
120
152
  const glitch = mod(frame + row * 3 + column, 11) === 0;
121
- return glitch ? makeCell("[]", "#29385a", true, false) : baseVoid();
153
+ return glitch ? makeCell("[]", VOID_GLITCH_COLOR, true, false) : baseVoid();
122
154
  }
123
155
 
124
156
  const unstable = mod(frame + row + column, 5) === 0;
125
157
  return makeCell(
126
158
  unstable ? "<>" : activeGlyph(frame),
127
- unstable ? "#ff5fd2" : "#74f9ff",
159
+ unstable ? "#ff4fd8" : "#76f6ff",
128
160
  false,
129
161
  unstable
130
162
  );
@@ -133,7 +165,7 @@ const variants = {
133
165
  "matrix-drip": {
134
166
  title: "Matrix Drip",
135
167
  blurb: "Green code rain condenses into the icon and then drains out.",
136
- speed: 95,
168
+ speed: 175,
137
169
  painter: frame =>
138
170
  renderGrid((row, column) => {
139
171
  const dripHead = mod(frame + column * 2, GRID_SIZE + 4) - 2;
@@ -145,20 +177,20 @@ const variants = {
145
177
  }
146
178
 
147
179
  if (active && row <= dripHead) {
148
- return makeCell("██", row === dripHead ? "#d8ff8a" : "#58ff6a", false, row === dripHead);
180
+ return makeCell("██", row === dripHead ? "#fff08a" : "#5cffd7", false, row === dripHead);
149
181
  }
150
182
 
151
183
  if (trail) {
152
- return makeCell("¦¦", "#2f7a37", true, false);
184
+ return makeCell("¦¦", "#6a7cff", true, false);
153
185
  }
154
186
 
155
- return makeCell("▓▓", "#35d05d", false, false);
187
+ return makeCell("▓▓", "#46e889", false, false);
156
188
  })
157
189
  },
158
190
  "packet-trace": {
159
191
  title: "Packet Trace",
160
192
  blurb: "A bright packet runs the shape path like a traced network route.",
161
- speed: 80,
193
+ speed: 150,
162
194
  painter: frame => {
163
195
  const path = [
164
196
  [7, 3],
@@ -183,7 +215,7 @@ const variants = {
183
215
  );
184
216
 
185
217
  if (pathIndex === -1) {
186
- return makeCell("▒▒", "#1697a6", false, false);
218
+ return makeCell("▒▒", "#3d92ff", false, false);
187
219
  }
188
220
 
189
221
  const distance = mod(head - pathIndex, path.length);
@@ -193,35 +225,35 @@ const variants = {
193
225
  }
194
226
 
195
227
  if (distance <= 2) {
196
- return makeCell("██", "#6fffe9", false, false);
228
+ return makeCell("██", "#ffd166", false, false);
197
229
  }
198
230
 
199
- return makeCell("▓▓", "#198f91", false, false);
231
+ return makeCell("▓▓", "#36b8ff", false, false);
200
232
  });
201
233
  }
202
234
  },
203
235
  "firewall-lock": {
204
236
  title: "Firewall Lock",
205
237
  blurb: "Red alert shutters clamp down, then clear to reveal the glyph.",
206
- speed: 100,
238
+ speed: 180,
207
239
  painter: frame =>
208
240
  renderGrid((row, column) => {
209
241
  const barrier = Math.abs(column - 3.5) <= (mod(frame, 8) < 4 ? 0.5 : 2.5);
210
242
  const active = isActive(row, column);
211
243
 
212
244
  if (!active) {
213
- return barrier ? makeCell("##", "#5a1e2b", true, false) : baseVoid();
245
+ return barrier ? makeCell("##", VOID_BARRIER_COLOR, true, false) : baseVoid();
214
246
  }
215
247
 
216
248
  return barrier
217
- ? makeCell("██", "#ff5a6b", false, true)
218
- : makeCell("▓▓", "#ffb347", false, false);
249
+ ? makeCell("██", "#ff5aa5", false, true)
250
+ : makeCell("▓▓", "#ffd166", false, false);
219
251
  })
220
252
  },
221
253
  "quantum-lag": {
222
254
  title: "Quantum Lag",
223
255
  blurb: "Multiple temporal echoes flicker around the icon before collapsing.",
224
- speed: 70,
256
+ speed: 145,
225
257
  painter: frame =>
226
258
  renderGrid((row, column) => {
227
259
  const active = isActive(row, column);
@@ -234,16 +266,16 @@ const variants = {
234
266
 
235
267
  if (active) {
236
268
  const collapsed = mod(frame + row, 6) < 3;
237
- return makeCell(collapsed ? "██" : "▓▓", collapsed ? "#9cf7ff" : "#6c63ff", false, collapsed);
269
+ return makeCell(collapsed ? "██" : "▓▓", collapsed ? "#9ff8ff" : "#7f6dff", false, collapsed);
238
270
  }
239
271
 
240
- return makeCell("::", frame % 2 === 0 ? "#3b5bfd" : "#2e9cca", true, false);
272
+ return makeCell("::", frame % 2 === 0 ? "#6a7cff" : "#44bfff", true, false);
241
273
  })
242
274
  },
243
275
  "signal-bloom": {
244
276
  title: "Signal Bloom",
245
277
  blurb: "Concentric blooms radiate outward from the icon's elbow joint.",
246
- speed: 90,
278
+ speed: 165,
247
279
  painter: frame => {
248
280
  const bloomCenter = [4, 3];
249
281
  const radius = mod(frame, 6);
@@ -253,26 +285,26 @@ const variants = {
253
285
 
254
286
  if (!isActive(row, column)) {
255
287
  return distance === radius
256
- ? makeCell("::", "#234f68", true, false)
288
+ ? makeCell("::", VOID_SIGNAL_COLOR, true, false)
257
289
  : baseVoid();
258
290
  }
259
291
 
260
292
  if (distance === radius) {
261
- return makeCell("██", "#ffffff", false, true);
293
+ return makeCell("██", "#fff1a8", false, true);
262
294
  }
263
295
 
264
296
  if (distance < radius) {
265
297
  return makeCell("▓▓", "#7afcff", false, false);
266
298
  }
267
299
 
268
- return makeCell("▒▒", "#0ed6b5", false, false);
300
+ return makeCell("▒▒", "#43c6ff", false, false);
269
301
  });
270
302
  }
271
303
  },
272
304
  "ghost-shell": {
273
305
  title: "Ghost Shell",
274
306
  blurb: "A stealth pass leaves dim shell copies hanging in the grid.",
275
- speed: 85,
307
+ speed: 155,
276
308
  painter: frame =>
277
309
  renderGrid((row, column) => {
278
310
  const active = isActive(row, column);
@@ -280,43 +312,55 @@ const variants = {
280
312
 
281
313
  if (active) {
282
314
  const hidden = mod(frame + row + column, 7) === 0;
283
- return makeCell(hidden ? "[]" : "██", hidden ? "#c7b7ff" : "#91f3ff", false, !hidden);
315
+ return makeCell(hidden ? "[]" : "██", hidden ? "#ff8fe2" : "#95f7ff", false, !hidden);
284
316
  }
285
317
 
286
318
  if (shell && mod(frame, 3) === 0) {
287
- return makeCell("..", "#385a9c", true, false);
319
+ return makeCell("..", "#6a7cff", true, false);
288
320
  }
289
321
 
290
322
  return voidGlyph(frame).trim()
291
- ? makeCell(voidGlyph(frame), "#162034", true, false)
323
+ ? makeCell(voidGlyph(frame), VOID_GHOST_COLOR, true, false)
292
324
  : baseVoid();
293
325
  })
294
326
  },
295
327
  "core-breach": {
296
328
  title: "Core Breach",
297
329
  blurb: "The shape overheats from within, shifting from cyan to amber to white.",
298
- speed: 65,
330
+ speed: 140,
299
331
  painter: frame =>
300
332
  renderGrid((row, column) => {
301
333
  if (!isActive(row, column)) {
302
334
  const sparks = mod(frame + row * column + column, 13) === 0;
303
- return sparks ? makeCell("°°", "#7a3620", true, false) : baseVoid();
335
+ return sparks ? makeCell("°°", VOID_SPARK_COLOR, true, false) : baseVoid();
304
336
  }
305
337
 
306
338
  const phase = mod(frame + row + column, 9);
307
339
 
308
340
  if (phase <= 2) {
309
- return makeCell("▒▒", "#26d0ff", false, false);
341
+ return makeCell("▒▒", "#4fbfff", false, false);
310
342
  }
311
343
 
312
344
  if (phase <= 5) {
313
- return makeCell("▓▓", "#ff8c42", false, true);
345
+ return makeCell("▓▓", "#ff9f1c", false, true);
314
346
  }
315
347
 
316
348
  return makeCell("██", "#fff4d6", false, true);
317
349
  })
318
350
  },
319
- ...runnerSceneVariants
351
+ "startup-grid-icon-compact-light-inverted": {
352
+ title: "Startup Grid Icon Compact Light Inverted",
353
+ blurb: "Compact square startup grid icon using lighter shaded blocks with inverted active and inactive tones.",
354
+ speed: 1000,
355
+ painter: () =>
356
+ buildStartupGridRows({
357
+ glyph: "▒▒",
358
+ activeColor: STARTUP_ICON_INACTIVE_COLOR,
359
+ inactiveColor: STARTUP_ICON_ACTIVE_COLOR
360
+ })
361
+ },
362
+ ...runnerSceneVariants,
363
+ ...ghostVectorVariants
320
364
  };
321
365
 
322
366
  export const variantNames = VARIANT_ORDER;