funutd/
ease.rs

1//! Easing functions.
2use super::math::*;
3extern crate alloc;
4use alloc::string::String;
5
6#[derive(Debug, Clone)]
7pub enum Ease {
8    Id,
9    Smooth3,
10    Smooth5,
11    Smooth7,
12    Smooth9,
13    Sqrt,
14    Squared,
15    Cubed,
16    UpArc,
17    DownArc,
18}
19
20impl Ease {
21    pub fn at(&self, x: f32) -> f32 {
22        match self {
23            Ease::Id => x,
24            Ease::Smooth3 => smooth3(x),
25            Ease::Smooth5 => smooth5(x),
26            Ease::Smooth7 => smooth7(x),
27            Ease::Smooth9 => smooth9(x),
28            Ease::Sqrt => sqrt(x),
29            Ease::Squared => squared(x),
30            Ease::Cubed => cubed(x),
31            Ease::UpArc => uparc(x),
32            Ease::DownArc => downarc(x),
33        }
34    }
35    pub fn get_code(&self) -> String {
36        format!("Ease::{:?}", self)
37    }
38}