Compare commits
7 Commits
d6ebe272db
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
8518ea1bd1
|
|||
|
5c81f35250
|
|||
|
02ce2097fb
|
|||
|
36a2e0e9e2
|
|||
|
b4f5d73cbd
|
|||
|
303028dc10
|
|||
|
feb9f76053
|
@@ -1,3 +1,2 @@
|
|||||||
/target/
|
/target/
|
||||||
/Cargo.lock
|
/Cargo.lock
|
||||||
/flake.lock
|
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.0.2
|
||||||
|
|
||||||
|
* use rust edition 2024
|
||||||
|
* make all functions inlinable
|
||||||
|
* add `#[must_use]` to all functions
|
||||||
|
* enable clippy lints and fix
|
||||||
|
|
||||||
## 1.0.1
|
## 1.0.1
|
||||||
|
|
||||||
* repair `elastic_out` function
|
* repair `elastic_out` function
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "simple-easing"
|
name = "simple-easing"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
description = "Set of simple easing functions"
|
description = "Set of simple easing functions"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
repository = "https://gitlab.com/chpio/simple-easing"
|
repository = "https://gitlab.com/chpio/simple-easing"
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
description = "simple-easing";
|
|
||||||
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
|
||||||
let pkgs = import nixpkgs { inherit system; };
|
|
||||||
in {
|
|
||||||
devShell = pkgs.mkShell {
|
|
||||||
name = "simple-easing";
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
cargo
|
|
||||||
rustc
|
|
||||||
rustfmt
|
|
||||||
rust-analyzer
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
+13
-4
@@ -3,20 +3,29 @@ const C2: f32 = C1 * 1.525;
|
|||||||
const C3: f32 = C1 + 1.0;
|
const C3: f32 = C1 + 1.0;
|
||||||
|
|
||||||
/// <https://easings.net/#easeInBack>
|
/// <https://easings.net/#easeInBack>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn back_in(t: f32) -> f32 {
|
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>
|
/// <https://easings.net/#easeOutBack>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn back_out(t: f32) -> f32 {
|
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>
|
/// <https://easings.net/#easeInOutBack>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn back_in_out(t: f32) -> f32 {
|
pub fn back_in_out(t: f32) -> f32 {
|
||||||
if t < 0.5 {
|
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 {
|
} else {
|
||||||
((2.0 * t - 2.0).powi(2) * ((C2 + 1.0) * (t * 2.0 - 2.0) + C2) + 2.0) / 2.0
|
f32::midpoint(
|
||||||
|
2.0f32.mul_add(t, -2.0).powi(2) * (C2 + 1.0).mul_add(t.mul_add(2.0, -2.0), C2),
|
||||||
|
2.0,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-6
@@ -1,28 +1,34 @@
|
|||||||
/// <https://easings.net/#easeInBounce>
|
/// <https://easings.net/#easeInBounce>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn bounce_in(t: f32) -> f32 {
|
pub fn bounce_in(t: f32) -> f32 {
|
||||||
1.0 - bounce_out(1.0 - t)
|
1.0 - bounce_out(1.0 - t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeOutBounce>
|
/// <https://easings.net/#easeOutBounce>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn bounce_out(t: f32) -> f32 {
|
pub fn bounce_out(t: f32) -> f32 {
|
||||||
const N1: f32 = 7.5625;
|
const N1: f32 = 7.5625;
|
||||||
const D1: f32 = 2.75;
|
const D1: f32 = 2.75;
|
||||||
if t < 1.0 / D1 {
|
if t < 1.0 / D1 {
|
||||||
return N1 * t * t;
|
N1 * t * t
|
||||||
} else if t < 2.0 / D1 {
|
} else if t < 2.0 / D1 {
|
||||||
return 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 {
|
} else if t < 2.5 / D1 {
|
||||||
return N1 * (t - 2.25 / D1).powi(2) + 0.9375;
|
N1.mul_add((t - 2.25 / D1).powi(2), 0.937_5)
|
||||||
} else {
|
} else {
|
||||||
return N1 * (t - 2.625 / D1).powi(2) + 0.984375;
|
N1.mul_add((t - 2.625 / D1).powi(2), 0.984_375)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeInOutBounce>
|
/// <https://easings.net/#easeInOutBounce>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn bounce_in_out(t: f32) -> f32 {
|
pub fn bounce_in_out(t: f32) -> f32 {
|
||||||
if t < 0.5 {
|
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 {
|
} else {
|
||||||
(1.0 + bounce_out(2.0 * t - 1.0)) / 2.0
|
f32::midpoint(1.0, bounce_out(2.0f32.mul_add(t, -1.0)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-4
@@ -1,18 +1,30 @@
|
|||||||
/// <https://easings.net/#easeInCirc>
|
/// <https://easings.net/#easeInCirc>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn circ_in(t: f32) -> f32 {
|
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>
|
/// <https://easings.net/#easeOutCirc>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn circ_out(t: f32) -> f32 {
|
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>
|
/// <https://easings.net/#easeInOutCirc>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn circ_in_out(t: f32) -> f32 {
|
pub fn circ_in_out(t: f32) -> f32 {
|
||||||
if t < 0.5 {
|
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 {
|
} else {
|
||||||
((1.0 - (-2.0 * t + 2.0).powi(2)).sqrt() + 1.0) / 2.0
|
f32::midpoint(
|
||||||
|
(-2.0f32)
|
||||||
|
.mul_add(t, 2.0)
|
||||||
|
.mul_add(-(-2.0f32).mul_add(t, 2.0), 1.0)
|
||||||
|
.sqrt(),
|
||||||
|
1.0,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -1,18 +1,24 @@
|
|||||||
/// <https://easings.net/#easeInCubic>
|
/// <https://easings.net/#easeInCubic>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn cubic_in(t: f32) -> f32 {
|
pub fn cubic_in(t: f32) -> f32 {
|
||||||
t * t * t
|
t * t * t
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeOutCubic>
|
/// <https://easings.net/#easeOutCubic>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn cubic_out(t: f32) -> f32 {
|
pub fn cubic_out(t: f32) -> f32 {
|
||||||
1.0 - (1.0 - t).powi(3)
|
1.0 - (1.0 - t).powi(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeInOutCubic>
|
/// <https://easings.net/#easeInOutCubic>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn cubic_in_out(t: f32) -> f32 {
|
pub fn cubic_in_out(t: f32) -> f32 {
|
||||||
if t < 0.5 {
|
if t < 0.5 {
|
||||||
4.0 * t * t * t
|
4.0 * t * t * t
|
||||||
} else {
|
} 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-4
@@ -4,36 +4,44 @@ const C4: f32 = (2.0 * PI) / 3.0;
|
|||||||
const C5: f32 = (2.0 * PI) / 4.5;
|
const C5: f32 = (2.0 * PI) / 4.5;
|
||||||
|
|
||||||
/// <https://easings.net/#easeInElastic>
|
/// <https://easings.net/#easeInElastic>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn elastic_in(t: f32) -> f32 {
|
pub fn elastic_in(t: f32) -> f32 {
|
||||||
if t <= 0.0 {
|
if t <= 0.0 {
|
||||||
0.0
|
0.0
|
||||||
} else if 1.0 <= t {
|
} else if 1.0 <= t {
|
||||||
1.0
|
1.0
|
||||||
} else {
|
} 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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeOutElastic>
|
/// <https://easings.net/#easeOutElastic>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn elastic_out(t: f32) -> f32 {
|
pub fn elastic_out(t: f32) -> f32 {
|
||||||
if t <= 0.0 {
|
if t <= 0.0 {
|
||||||
0.0
|
0.0
|
||||||
} else if 1.0 <= t {
|
} else if 1.0 <= t {
|
||||||
1.0
|
1.0
|
||||||
} else {
|
} 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeInOutElastic>
|
/// <https://easings.net/#easeInOutElastic>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn elastic_in_out(t: f32) -> f32 {
|
pub fn elastic_in_out(t: f32) -> f32 {
|
||||||
if t <= 0.0 {
|
if t <= 0.0 {
|
||||||
0.0
|
0.0
|
||||||
} else if 1.0 <= t {
|
} else if 1.0 <= t {
|
||||||
1.0
|
1.0
|
||||||
} else if t < 0.5 {
|
} 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 {
|
} 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-4
@@ -1,30 +1,36 @@
|
|||||||
/// <https://easings.net/#easeInExpo>
|
/// <https://easings.net/#easeInExpo>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn expo_in(t: f32) -> f32 {
|
pub fn expo_in(t: f32) -> f32 {
|
||||||
if t <= 0.0 {
|
if t <= 0.0 {
|
||||||
0.0
|
0.0
|
||||||
} else {
|
} else {
|
||||||
2f32.powf(10.0 * t - 10.0)
|
10.0f32.mul_add(t, -10.0).exp2()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeOutExpo>
|
/// <https://easings.net/#easeOutExpo>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn expo_out(t: f32) -> f32 {
|
pub fn expo_out(t: f32) -> f32 {
|
||||||
if 1.0 <= t {
|
if 1.0 <= t {
|
||||||
1.0
|
1.0
|
||||||
} else {
|
} else {
|
||||||
1.0 - 2f32.powf(-10.0 * t)
|
1.0 - (-10.0 * t).exp2()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeInOutExpo>
|
/// <https://easings.net/#easeInOutExpo>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn expo_in_out(t: f32) -> f32 {
|
pub fn expo_in_out(t: f32) -> f32 {
|
||||||
if t <= 0.0 {
|
if t <= 0.0 {
|
||||||
0.0
|
0.0
|
||||||
} else if 1.0 <= t {
|
} else if 1.0 <= t {
|
||||||
1.0
|
1.0
|
||||||
} else if t < 0.5 {
|
} 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 {
|
} else {
|
||||||
(2.0 - 2f32.powf(-20.0 * t + 10.0)) / 2.0
|
(2.0 - (-20.0f32).mul_add(t, 10.0).exp2()) / 2.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
//! assert_eq!(easing(1.0), 1.0);
|
//! assert_eq!(easing(1.0), 1.0);
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
#![warn(clippy::pedantic, clippy::nursery)]
|
||||||
|
#![allow(clippy::missing_const_for_fn)]
|
||||||
|
|
||||||
mod back;
|
mod back;
|
||||||
mod bounce;
|
mod bounce;
|
||||||
mod circ;
|
mod circ;
|
||||||
@@ -42,11 +45,15 @@ pub use quart::*;
|
|||||||
pub use quint::*;
|
pub use quint::*;
|
||||||
pub use sine::*;
|
pub use sine::*;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn linear(t: f32) -> f32 {
|
pub fn linear(t: f32) -> f32 {
|
||||||
t
|
t
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A linear easing that goes from `1.0` to `0.0`.
|
/// A linear easing that goes from `1.0` to `0.0`.
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn reverse(t: f32) -> f32 {
|
pub fn reverse(t: f32) -> f32 {
|
||||||
1.0 - t
|
1.0 - t
|
||||||
}
|
}
|
||||||
@@ -61,6 +68,8 @@ pub fn reverse(t: f32) -> f32 {
|
|||||||
/// let descending = cubic_in(roundtrip(0.75));
|
/// let descending = cubic_in(roundtrip(0.75));
|
||||||
/// assert!((ascending - descending).abs() < 0.001);
|
/// assert!((ascending - descending).abs() < 0.001);
|
||||||
/// ```
|
/// ```
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn roundtrip(t: f32) -> f32 {
|
pub fn roundtrip(t: f32) -> f32 {
|
||||||
if t < 0.5 { t * 2.0 } else { (1.0 - t) * 2.0 }
|
if t < 0.5 { t * 2.0 } else { (1.0 - t) * 2.0 }
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-2
@@ -1,18 +1,24 @@
|
|||||||
/// <https://easings.net/#easeInQuad>
|
/// <https://easings.net/#easeInQuad>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn quad_in(t: f32) -> f32 {
|
pub fn quad_in(t: f32) -> f32 {
|
||||||
t * t
|
t * t
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeOutQuad>
|
/// <https://easings.net/#easeOutQuad>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn quad_out(t: f32) -> f32 {
|
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>
|
/// <https://easings.net/#easeInOutQuad>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn quad_in_out(t: f32) -> f32 {
|
pub fn quad_in_out(t: f32) -> f32 {
|
||||||
if t < 0.5 {
|
if t < 0.5 {
|
||||||
2.0 * t * t
|
2.0 * t * t
|
||||||
} else {
|
} 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -1,18 +1,24 @@
|
|||||||
/// <https://easings.net/#easeInQuart>
|
/// <https://easings.net/#easeInQuart>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn quart_in(t: f32) -> f32 {
|
pub fn quart_in(t: f32) -> f32 {
|
||||||
t * t * t * t
|
t * t * t * t
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeOutQuart>
|
/// <https://easings.net/#easeOutQuart>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn quart_out(t: f32) -> f32 {
|
pub fn quart_out(t: f32) -> f32 {
|
||||||
1.0 - (1.0 - t).powi(4)
|
1.0 - (1.0 - t).powi(4)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeInOutQuart>
|
/// <https://easings.net/#easeInOutQuart>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn quart_in_out(t: f32) -> f32 {
|
pub fn quart_in_out(t: f32) -> f32 {
|
||||||
if t < 0.5 {
|
if t < 0.5 {
|
||||||
8.0 * t * t * t * t
|
8.0 * t * t * t * t
|
||||||
} else {
|
} 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -1,18 +1,24 @@
|
|||||||
/// <https://easings.net/#easeInQuint>
|
/// <https://easings.net/#easeInQuint>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn quint_in(t: f32) -> f32 {
|
pub fn quint_in(t: f32) -> f32 {
|
||||||
t * t * t * t
|
t * t * t * t
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeOutQuint>
|
/// <https://easings.net/#easeOutQuint>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn quint_out(t: f32) -> f32 {
|
pub fn quint_out(t: f32) -> f32 {
|
||||||
1.0 - (1.0 - t).powi(5)
|
1.0 - (1.0 - t).powi(5)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeInOutQuint>
|
/// <https://easings.net/#easeInOutQuint>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn quint_in_out(t: f32) -> f32 {
|
pub fn quint_in_out(t: f32) -> f32 {
|
||||||
if t < 0.5 {
|
if t < 0.5 {
|
||||||
16.0 * t * t * t * t * t
|
16.0 * t * t * t * t * t
|
||||||
} else {
|
} 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
use ::std::f32::consts::PI;
|
use ::std::f32::consts::PI;
|
||||||
|
|
||||||
/// <https://easings.net/#easeInSine>
|
/// <https://easings.net/#easeInSine>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn sine_in(t: f32) -> f32 {
|
pub fn sine_in(t: f32) -> f32 {
|
||||||
1.0 - (t * PI / 2.0).cos()
|
1.0 - (t * PI / 2.0).cos()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeOutSine>
|
/// <https://easings.net/#easeOutSine>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn sine_out(t: f32) -> f32 {
|
pub fn sine_out(t: f32) -> f32 {
|
||||||
(t * PI / 2.0).sin()
|
(t * PI / 2.0).sin()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://easings.net/#easeInOutSine>
|
/// <https://easings.net/#easeInOutSine>
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn sine_in_out(t: f32) -> f32 {
|
pub fn sine_in_out(t: f32) -> f32 {
|
||||||
-((PI * t).cos() - 1.0) / 2.0
|
-((PI * t).cos() - 1.0) / 2.0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user