vibe/animation/families/
thermo.rs1use crate::animation::pga::Motor;
4use crate::animation::presets::AnimationSample;
5
6pub fn eval(preset: &str, t: f64) -> AnimationSample {
8 match preset {
9 "heat_diffuse" | "diffuse" => {
10 let diff_const = 0.5;
11 let temp = (-diff_const * t).exp();
12 let radius = (1.0 + t * 2.0).sqrt();
13 AnimationSample {
14 scalar: temp,
15 vector: [radius, radius, radius],
16 motor: Motor::identity(),
17 secondary: 1.0 - temp,
18 settled: temp < 0.01,
19 }
20 }
21 "crystallize" => {
22 let phase = (t * 0.8).clamp(0.0, 1.0);
23 let order_param = (phase * std::f64::consts::PI * 0.5).sin();
24 AnimationSample {
25 scalar: order_param,
26 vector: [order_param, order_param, order_param],
27 motor: Motor::identity(),
28 secondary: phase,
29 settled: phase >= 1.0,
30 }
31 }
32 "thermal_glow" => {
33 let temp_k = (300.0 + t * 1500.0).clamp(300.0, 6000.0);
34 let normalized_intensity = ((temp_k - 300.0) / 5700.0).powi(4);
35 AnimationSample {
36 scalar: normalized_intensity,
37 vector: [
38 normalized_intensity,
39 normalized_intensity * 0.6,
40 normalized_intensity * 0.2,
41 ],
42 motor: Motor::identity(),
43 secondary: temp_k,
44 settled: temp_k >= 6000.0,
45 }
46 }
47 "implode" => {
48 let p = (t * 1.5).clamp(0.0, 1.0);
49 let collapse = 1.0 - p.powi(4);
50 AnimationSample {
51 scalar: collapse,
52 vector: [collapse, collapse, collapse],
53 motor: Motor::identity(),
54 secondary: 1.0 - collapse,
55 settled: p >= 1.0,
56 }
57 }
58 _ => AnimationSample::default(),
59 }
60}