use crossterm::style::Color;
use super::GlintFrame;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(in crate::render::sidebar) enum GlintRow {
Flat,
Upper,
Lower,
}
pub(in crate::render::sidebar) fn working_glint_bg(
active: bool,
frame: GlintFrame,
column: usize,
width: usize,
_row: GlintRow,
) -> Color {
let (base, target) = if active { (48u8, 68u8) } else { (36u8, 50u8) };
if width < 6 {
return gray(if active { 56 } else { 42 });
}
let Some(progress) = frame.progress() else {
return gray(base);
};
let radius = (width as f32 / 3.75).clamp(2.75, 5.0);
let travel = width.saturating_sub(1) as f32 + radius * 2.0;
let center = -radius + progress * travel;
let distance = (column as f32 - center).abs();
let weight = smooth_band(distance, radius);
gray((f32::from(base) + f32::from(target - base) * weight).round() as u8)
}
fn smooth_band(distance: f32, radius: f32) -> f32 {
let linear = (1.0 - distance / radius).clamp(0.0, 1.0);
linear * linear * (3.0 - 2.0 * linear)
}
const fn gray(value: u8) -> Color {
Color::Rgb {
r: value,
g: value,
b: value,
}
}