pub struct SwitchAnimation {
pub duration_ms: f64,
pub easing: &'static str,
}
pub const TOGGLE: SwitchAnimation = SwitchAnimation {
duration_ms: 200.0,
easing: "ease-in-out",
};
#[inline]
pub fn thumb_position(progress: f64, track_width: f64, thumb_radius: f64) -> f64 {
let travel_distance = track_width - (thumb_radius * 2.0);
thumb_radius + (travel_distance * progress)
}
#[inline]
pub fn interpolate_track_color(
progress: f64,
color_off: (f64, f64, f64, f64),
color_on: (f64, f64, f64, f64),
) -> (f64, f64, f64, f64) {
(
color_off.0 + (color_on.0 - color_off.0) * progress,
color_off.1 + (color_on.1 - color_off.1) * progress,
color_off.2 + (color_on.2 - color_off.2) * progress,
color_off.3 + (color_on.3 - color_off.3) * progress,
)
}