simple_easing/circ.rs
1/// <https://easings.net/#easeInCirc>
2#[inline]
3#[must_use]
4pub fn circ_in(t: f32) -> f32 {
5 1.0 - t.mul_add(-t, 1.0).sqrt()
6}
7
8/// <https://easings.net/#easeOutCirc>
9#[inline]
10#[must_use]
11pub fn circ_out(t: f32) -> f32 {
12 (t - 1.0).mul_add(-(t - 1.0), 1.0).sqrt()
13}
14
15/// <https://easings.net/#easeInOutCirc>
16#[inline]
17#[must_use]
18pub fn circ_in_out(t: f32) -> f32 {
19 if t < 0.5 {
20 (1.0 - (2.0 * t).mul_add(-(2.0 * t), 1.0).sqrt()) / 2.0
21 } else {
22 f32::midpoint(
23 (-2.0f32)
24 .mul_add(t, 2.0)
25 .mul_add(-(-2.0f32).mul_add(t, 2.0), 1.0)
26 .sqrt(),
27 1.0,
28 )
29 }
30}