diff --git a/crates/comet_math/src/easings.rs b/crates/comet_math/src/easings.rs index 342c060..09e3ec6 100644 --- a/crates/comet_math/src/easings.rs +++ b/crates/comet_math/src/easings.rs @@ -1,15 +1,15 @@ -use num_traits::FloatConst; +use std::f32::consts::PI; pub fn ease_in_sine(x: f32) -> f32 { - 1.0 - ((x * f32::PI) / 2.0).cos() + 1.0 - ((x * PI) / 2.0).cos() } pub fn ease_out_sine(x: f32) -> f32 { - ((x * f32::PI) / 2.0).sin() + ((x * PI) / 2.0).sin() } pub fn ease_in_out_sine(x: f32) -> f32 { - -((f32::PI * x).cos() - 1.0) / 2.0 + -((PI * x).cos() - 1.0) / 2.0 } pub fn ease_in_quad(x: f32) -> f32 { @@ -103,17 +103,17 @@ pub fn ease_in_out_back(x: f32) -> f32 { } pub fn ease_in_elastic(x: f32) -> f32 { - let c4 = (2.0 * f32::PI) / 3.0; + let c4 = (2.0 * PI) / 3.0; if x == 0.0 { 0.0 } else if x == 1.0 { 1.0 } else { -2.0_f32.powf(10.0 * x - 10.0) * ((x * 10.0 - 10.75) * c4).sin() } } pub fn ease_out_elastic(x: f32) -> f32 { - let c4 = (2.0 * f32::PI) / 3.0; + let c4 = (2.0 * PI) / 3.0; if x == 0.0 { 0.0 } else if x == 1.0 { 1.0 } else { 2.0_f32.powf(-10.0 * x) * ((x * 10.0 - 0.75) * c4).sin() + 1.0 } } pub fn ease_in_out_elastic(x: f32) -> f32 { - let c5 = (2.0 * f32::PI) / 4.5; + let c5 = (2.0 * PI) / 4.5; if x == 0.0 { 0.0 } else if x == 1.0 { 1.0 } else if x < 0.5 { -(2.0_f32.powf(20.0 * x - 10.0) * ((20.0 * x - 11.125) * c5).sin()) / 2.0 } else { (2.0_f32.powf(-20.0 * x + 10.0) * ((20.0 * x - 11.125) * c5).sin()) / 2.0 + 1.0 } }