use shakmaty::Square;
pub fn ease(start: f64, end: f64, t: f64) -> f64 {
let t = t.max(0.0).min(1.0);
let ease = if t < 0.5 {
4.0 * t * t * t
} else {
(t - 1.0) * (2.0 * t - 2.0) * (2.0 * t - 2.0) + 1.0
};
start + (end - start) * ease
}
pub fn pos_to_square((x, y): (f64, f64)) -> Option<Square> {
let (x, y) = (x.floor(), y.floor());
if 0f64 <= x && x <= 7f64 && 0f64 <= y && y <= 7f64 {
Square::from_coords(x as i8, 7 - y as i8)
} else {
None
}
}
pub fn square_to_pos(square: Square) -> (f64, f64) {
(0.5 + f64::from(square.file()), 7.5 - f64::from(square.rank()))
}