1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! Easing functions for interpolation.
//!
//! An easing function maps a normalized time \(t \in [0,1]\) to an eased
//! ratio in \([0,1]\), allowing for custom animation curves.
use PI;
/// A function that maps \(t \in [0,1]\) to an eased ratio in \([0,1]\).
pub type EasingFn = fn ;
/// “No animation” (always jump to the end).
///
/// # Examples
///
/// ```rust
/// use interpolated::none;
/// assert_eq!(none(0.5), 1.0);
/// ```
/// Linear easing.
///
/// Maps \(t\) to \(t\) unchanged.
///
/// # Examples
///
/// ```rust
/// use interpolated::linear;
/// assert_eq!(linear(0.3), 0.3);
/// ```
/// Ease in/out exponential.
///
/// Accelerates until halfway, then decelerates for smooth transitions.
///
/// # Examples
///
/// ```rust
/// use interpolated::ease_in_out_expo;
/// let mid = ease_in_out_expo(0.5);
/// assert!(mid > 0.5);
/// ```
/// Ease out “back”.
///
/// Overshoots the target before settling.
///
/// # Examples
///
/// ```rust
/// use interpolated::ease_out_back;
/// let out = ease_out_back(0.8);
/// assert!(out > 0.8);
/// ```
/// Ease in “back”.
///
/// Starts by moving backwards before accelerating forward.
///
/// # Examples
///
/// ```rust
/// use interpolated::ease_in_back;
/// let into = ease_in_back(0.2);
/// assert!(into < 0.2);
/// ```
/// Ease out “elastic”.
///
/// Creates an elastic oscillation effect before settling.
///
/// # Examples
///
/// ```rust
/// use interpolated::ease_out_elastic;
/// let elastic = ease_out_elastic(0.75);
/// assert!(elastic > 0.75);
/// ```