feat: enable clippy nursery and fix
This commit is contained in:
+4
-4
@@ -6,14 +6,14 @@ const C3: f32 = C1 + 1.0;
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn back_in(t: f32) -> f32 {
|
||||
C3 * t * t * t - C1 * t * t
|
||||
(C3 * t * t).mul_add(t, -(C1 * t * t))
|
||||
}
|
||||
|
||||
/// <https://easings.net/#easeOutBack>
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn back_out(t: f32) -> f32 {
|
||||
1.0 + C3 * (t - 1.0).powi(3) + C1 * (t - 1.0).powi(2)
|
||||
C1.mul_add((t - 1.0).powi(2), C3.mul_add((t - 1.0).powi(3), 1.0))
|
||||
}
|
||||
|
||||
/// <https://easings.net/#easeInOutBack>
|
||||
@@ -21,10 +21,10 @@ pub fn back_out(t: f32) -> f32 {
|
||||
#[must_use]
|
||||
pub fn back_in_out(t: f32) -> f32 {
|
||||
if t < 0.5 {
|
||||
((2.0 * t).powi(2) * ((C2 + 1.0) * 2.0 * t - C2)) / 2.0
|
||||
((2.0 * t).powi(2) * ((C2 + 1.0) * 2.0).mul_add(t, -C2)) / 2.0
|
||||
} else {
|
||||
f32::midpoint(
|
||||
(2.0 * t - 2.0).powi(2) * ((C2 + 1.0) * (t * 2.0 - 2.0) + C2),
|
||||
2.0f32.mul_add(t, -2.0).powi(2) * (C2 + 1.0).mul_add(t.mul_add(2.0, -2.0), C2),
|
||||
2.0,
|
||||
)
|
||||
}
|
||||
|
||||
+5
-5
@@ -14,11 +14,11 @@ pub fn bounce_out(t: f32) -> f32 {
|
||||
if t < 1.0 / D1 {
|
||||
N1 * t * t
|
||||
} else if t < 2.0 / D1 {
|
||||
N1 * (t - 1.5 / D1).powi(2) + 0.75
|
||||
N1.mul_add((t - 1.5 / D1).powi(2), 0.75)
|
||||
} else if t < 2.5 / D1 {
|
||||
N1 * (t - 2.25 / D1).powi(2) + 0.937_5
|
||||
N1.mul_add((t - 2.25 / D1).powi(2), 0.937_5)
|
||||
} else {
|
||||
N1 * (t - 2.625 / D1).powi(2) + 0.984_375
|
||||
N1.mul_add((t - 2.625 / D1).powi(2), 0.984_375)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ pub fn bounce_out(t: f32) -> f32 {
|
||||
#[must_use]
|
||||
pub fn bounce_in_out(t: f32) -> f32 {
|
||||
if t < 0.5 {
|
||||
(1.0 - bounce_out(1.0 - 2.0 * t)) / 2.0
|
||||
(1.0 - bounce_out(2.0f32.mul_add(-t, 1.0))) / 2.0
|
||||
} else {
|
||||
f32::midpoint(1.0, bounce_out(2.0 * t - 1.0))
|
||||
f32::midpoint(1.0, bounce_out(2.0f32.mul_add(t, -1.0)))
|
||||
}
|
||||
}
|
||||
|
||||
+10
-4
@@ -2,14 +2,14 @@
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn circ_in(t: f32) -> f32 {
|
||||
1.0 - (1.0 - t.powi(2)).sqrt()
|
||||
1.0 - t.mul_add(-t, 1.0).sqrt()
|
||||
}
|
||||
|
||||
/// <https://easings.net/#easeOutCirc>
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn circ_out(t: f32) -> f32 {
|
||||
(1.0 - (t - 1.0).powi(2)).sqrt()
|
||||
(t - 1.0).mul_add(-(t - 1.0), 1.0).sqrt()
|
||||
}
|
||||
|
||||
/// <https://easings.net/#easeInOutCirc>
|
||||
@@ -17,8 +17,14 @@ pub fn circ_out(t: f32) -> f32 {
|
||||
#[must_use]
|
||||
pub fn circ_in_out(t: f32) -> f32 {
|
||||
if t < 0.5 {
|
||||
(1.0 - (1.0 - (2.0 * t).powi(2)).sqrt()) / 2.0
|
||||
(1.0 - (2.0 * t).mul_add(-(2.0 * t), 1.0).sqrt()) / 2.0
|
||||
} else {
|
||||
f32::midpoint((1.0 - (-2.0 * t + 2.0).powi(2)).sqrt(), 1.0)
|
||||
f32::midpoint(
|
||||
(-2.0f32)
|
||||
.mul_add(t, 2.0)
|
||||
.mul_add(-(-2.0f32).mul_add(t, 2.0), 1.0)
|
||||
.sqrt(),
|
||||
1.0,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,6 +19,6 @@ pub fn cubic_in_out(t: f32) -> f32 {
|
||||
if t < 0.5 {
|
||||
4.0 * t * t * t
|
||||
} else {
|
||||
1.0 - (-2.0 * t + 2.0).powi(3) / 2.0
|
||||
1.0 - (-2.0f32).mul_add(t, 2.0).powi(3) / 2.0
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -12,7 +12,7 @@ pub fn elastic_in(t: f32) -> f32 {
|
||||
} else if 1.0 <= t {
|
||||
1.0
|
||||
} else {
|
||||
-2f32.powf(10.0 * t - 10.0) * ((t * 10.0 - 10.75) * C4).sin()
|
||||
-10.0f32.mul_add(t, -10.0).exp2() * (t.mul_add(10.0, -10.75) * C4).sin()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ pub fn elastic_out(t: f32) -> f32 {
|
||||
} else if 1.0 <= t {
|
||||
1.0
|
||||
} else {
|
||||
2f32.powf(-10.0 * t) * ((t * 10.0 - 0.75) * C4).sin() + 1.0
|
||||
(-10.0 * t)
|
||||
.exp2()
|
||||
.mul_add((t.mul_add(10.0, -0.75) * C4).sin(), 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +40,8 @@ pub fn elastic_in_out(t: f32) -> f32 {
|
||||
} else if 1.0 <= t {
|
||||
1.0
|
||||
} else if t < 0.5 {
|
||||
-(2f32.powf(20.0 * t - 10.0) * ((20.0 * t - 11.125) * C5).sin()) / 2.0
|
||||
-(20.0f32.mul_add(t, -10.0).exp2() * (20.0f32.mul_add(t, -11.125) * C5).sin()) / 2.0
|
||||
} else {
|
||||
(2f32.powf(-20.0 * t + 10.0) * ((20.0 * t - 11.125) * C5).sin()) / 2.0 + 1.0
|
||||
((-20.0f32).mul_add(t, 10.0).exp2() * (20.0f32.mul_add(t, -11.125) * C5).sin()) / 2.0 + 1.0
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@ pub fn expo_in(t: f32) -> f32 {
|
||||
if t <= 0.0 {
|
||||
0.0
|
||||
} else {
|
||||
2f32.powf(10.0 * t - 10.0)
|
||||
10.0f32.mul_add(t, -10.0).exp2()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ pub fn expo_out(t: f32) -> f32 {
|
||||
if 1.0 <= t {
|
||||
1.0
|
||||
} else {
|
||||
1.0 - 2f32.powf(-10.0 * t)
|
||||
1.0 - (-10.0 * t).exp2()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ pub fn expo_in_out(t: f32) -> f32 {
|
||||
} else if 1.0 <= t {
|
||||
1.0
|
||||
} else if t < 0.5 {
|
||||
2f32.powf(20.0 * t - 10.0) / 2.0
|
||||
20.0f32.mul_add(t, -10.0).exp2() / 2.0
|
||||
} else {
|
||||
(2.0 - 2f32.powf(-20.0 * t + 10.0)) / 2.0
|
||||
(2.0 - (-20.0f32).mul_add(t, 10.0).exp2()) / 2.0
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@
|
||||
//! assert_eq!(easing(1.0), 1.0);
|
||||
//! ```
|
||||
|
||||
#![warn(clippy::pedantic)]
|
||||
#![warn(clippy::pedantic, clippy::nursery)]
|
||||
#![allow(clippy::missing_const_for_fn)]
|
||||
|
||||
mod back;
|
||||
mod bounce;
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ pub fn quad_in(t: f32) -> f32 {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn quad_out(t: f32) -> f32 {
|
||||
1.0 - (1.0 - t).powi(2)
|
||||
(1.0 - t).mul_add(-(1.0 - t), 1.0)
|
||||
}
|
||||
|
||||
/// <https://easings.net/#easeInOutQuad>
|
||||
@@ -19,6 +19,6 @@ pub fn quad_in_out(t: f32) -> f32 {
|
||||
if t < 0.5 {
|
||||
2.0 * t * t
|
||||
} else {
|
||||
1.0 - (-2.0 * t + 2.0).powi(2) / 2.0
|
||||
1.0 - (-2.0f32).mul_add(t, 2.0).powi(2) / 2.0
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,6 +19,6 @@ pub fn quart_in_out(t: f32) -> f32 {
|
||||
if t < 0.5 {
|
||||
8.0 * t * t * t * t
|
||||
} else {
|
||||
1.0 - (-2.0 * t + 2.0).powi(4) / 2.0
|
||||
1.0 - (-2.0f32).mul_add(t, 2.0).powi(4) / 2.0
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,6 +19,6 @@ pub fn quint_in_out(t: f32) -> f32 {
|
||||
if t < 0.5 {
|
||||
16.0 * t * t * t * t * t
|
||||
} else {
|
||||
1.0 - (-2.0 * t + 2.0).powi(5) / 2.0
|
||||
1.0 - (-2.0f32).mul_add(t, 2.0).powi(5) / 2.0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user