use keyframe::{num_traits::Float, CanTween}; use smithay::utils::{Coordinate, Point, Rectangle, Size}; pub struct EasePoint(pub Point); pub struct EaseSize(pub Size); pub struct EaseRectangle(pub Rectangle); impl CanTween for EasePoint { fn ease(from: Self, to: Self, time: impl Float) -> Self { let x = N::from_f64(CanTween::ease(from.0.x.to_f64(), to.0.x.to_f64(), time).round()); let y = N::from_f64(CanTween::ease(from.0.y.to_f64(), to.0.y.to_f64(), time).round()); EasePoint((x, y).into()) } } impl CanTween for EaseSize { fn ease(from: Self, to: Self, time: impl Float) -> Self { let w = N::from_f64(CanTween::ease(from.0.w.to_f64(), to.0.w.to_f64(), time).round()); let h = N::from_f64(CanTween::ease(from.0.h.to_f64(), to.0.h.to_f64(), time).round()); EaseSize((w, h).into()) } } impl CanTween for EaseRectangle { fn ease(from: Self, to: Self, time: impl Float) -> Self { EaseRectangle(Rectangle::new( CanTween::ease(EasePoint(from.0.loc), EasePoint(to.0.loc), time).unwrap(), CanTween::ease(EaseSize(from.0.size), EaseSize(to.0.size), time).unwrap(), )) } } impl EasePoint { pub fn unwrap(self) -> Point { self.0 } } impl EaseSize { pub fn unwrap(self) -> Size { self.0 } } impl EaseRectangle { pub fn unwrap(self) -> Rectangle { self.0 } }