Skip to main content

vibe/animation/families/
hud.rs

1//! HUD & UI Glassmorphism Animation Family (Glass reveals, Chromatic pulses, Focus halos).
2
3use crate::animation::curves::EasingCurve;
4use crate::animation::pga::Motor;
5use crate::animation::presets::AnimationSample;
6
7/// Evaluates the families family.
8pub fn eval(preset: &str, t: f64) -> AnimationSample {
9    match preset {
10        "glass_reveal" | "reveal" => {
11            let progress = (t * 1.2).clamp(0.0, 1.0);
12            let scale = EasingCurve::BackOut.eval(progress);
13            let blur = progress * 24.0;
14            let opacity = EasingCurve::CubicOut.eval(progress);
15            AnimationSample {
16                scalar: scale,
17                vector: [scale, scale, 1.0],
18                motor: Motor::from_translation(0.0, (1.0 - opacity) * -20.0, 0.0),
19                secondary: blur,
20                settled: progress >= 1.0,
21            }
22        }
23        "chromatic_pulse" | "pulse" => {
24            let cycle = (t * 2.5).sin();
25            let dispersion = (cycle * 0.5 + 0.5) * 4.0;
26            let glow = (cycle * 0.5 + 0.5) * 0.8 + 0.2;
27            AnimationSample {
28                scalar: glow,
29                vector: [glow, glow * 0.9, glow * 1.3],
30                motor: Motor::identity(),
31                secondary: dispersion,
32                settled: false,
33            }
34        }
35        "frosted_fade" => {
36            let p = (t * 0.8).clamp(0.0, 1.0);
37            let alpha = EasingCurve::SineInOut.eval(p);
38            let trans = 0.85 * alpha;
39            AnimationSample {
40                scalar: alpha,
41                vector: [trans, trans, trans],
42                motor: Motor::identity(),
43                secondary: 1.0 - alpha,
44                settled: p >= 1.0,
45            }
46        }
47        "focus_halo" => {
48            let r = 50.0 + (t * 3.0).sin() * 15.0;
49            let lum = 0.7 + (t * 3.0).cos() * 0.2;
50            AnimationSample {
51                scalar: r,
52                vector: [r, r, lum],
53                motor: Motor::identity(),
54                secondary: lum,
55                settled: false,
56            }
57        }
58        _ => AnimationSample::default(),
59    }
60}