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