eazing/easing/polynomial/
quartic.rs1use crate::easing::Curve;
10
11#[derive(Debug)]
22pub struct InQuartic;
23
24impl Curve for InQuartic {
25 #[inline]
26 fn y(&self, p: f32) -> f32 {
27 p * p * p * p
28 }
29}
30
31#[test]
32fn test_in_quartic() {
33 let p = InQuartic.y(1.0);
34
35 assert_eq!(p, 1.0);
36}
37
38#[derive(Debug)]
49pub struct OutQuartic;
50
51impl Curve for OutQuartic {
52 #[inline]
53 fn y(&self, p: f32) -> f32 {
54 let m = p - 1.0;
55
56 1.0 - m * m * m * m
57 }
58}
59
60#[test]
61fn test_out_quartic() {
62 let p = OutQuartic.y(1.0);
63
64 assert_eq!(p, 1.0);
65}
66
67#[derive(Debug)]
78pub struct InOutQuartic;
79
80impl Curve for InOutQuartic {
81 #[inline]
82 fn y(&self, p: f32) -> f32 {
83 let m = p - 1.0;
84 let t = p * 2.0;
85
86 if t < 1.0 {
87 return p * t * t * t;
88 }
89
90 1.0 - m * m * m * m * 8.0
91 }
92}
93
94#[test]
95fn test_in_out_quartic() {
96 let p = InOutQuartic.y(1.0);
97
98 assert_eq!(p, 1.0);
99}