tween/tweens/
quint.rs

1declare_tween!(
2    /// An quintic tween in. Go [here](https://easings.net/#easeInQuint) for a visual demonstration.
3    pub struct QuintIn;
4
5    /// Creates a new [QuintInOut] Tweener.
6    pub fn quint_in;
7
8    /// Creates a new [QuintInOut] Tweener at the given time.
9    pub fn quint_in_at;
10
11    pub fn tween<Value: crate::TweenValue>(&mut self, value_delta: Value, percent: f32) -> Value {
12        value_delta.scale(percent * percent * percent * percent * percent)
13    }
14);
15
16declare_tween!(
17    /// An quintic tween out. Go [here](https://easings.net/#easeOutQuint) for a visual demonstration.
18    pub struct QuintOut;
19
20    /// Creates a new [QuintOut] Tweener.
21    pub fn quint_out;
22
23    /// Creates a new [QuintOut] Tweener at the given time.
24    pub fn quint_out_at;
25
26    pub fn tween<Value: crate::TweenValue>(&mut self, value_delta: Value, mut percent: f32) -> Value {
27        percent -= 1.0;
28        value_delta.scale(percent * percent * percent * percent * percent + 1.0)
29    }
30);
31
32declare_tween!(
33    /// An quintic tween in out. Go [here](https://easings.net/#easeInOutQuint) for a visual demonstration.
34    pub struct QuintInOut;
35
36    /// Creates a new [QuintInOut] Tweener.
37    pub fn quint_in_out;
38
39    /// Creates a new [QuintInOut] Tweener at the given time.
40    pub fn quint_in_out_at;
41
42    pub fn tween<Value: crate::TweenValue>(&mut self, value_delta: Value, mut percent: f32) -> Value {
43        percent *= 2.0;
44
45        let scalar = if percent < 1.0 {
46            percent * percent * percent * percent * percent
47        } else {
48            let p = percent - 2.0;
49            p * p * p * p * p + 2.0
50        };
51        value_delta.scale(scalar / 2.0)
52    }
53);
54
55test_tween!(Quint);