Skip to content

Commit 88633cf

Browse files
committed
Add easeInOut
useful
1 parent e8f7719 commit 88633cf

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/include/sndx/math/easings.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ namespace sndx::math {
4545
return T(1.0) - func(T(1.0) - a);
4646
}
4747

48+
template <std::floating_point T, T(*Func)(T)> [[nodiscard]]
49+
constexpr auto easeInOut(T a) noexcept {
50+
if (a < T(0.5)) {
51+
return Func(a * T(2.0)) / T(2.0);
52+
}
53+
else {
54+
return (T(2.0) - Func((T(1.0) - a) * T(2.0))) / T(2.0);
55+
}
56+
}
57+
4858
template <std::floating_point T> [[nodiscard]]
4959
constexpr auto easeLinear(T a) noexcept {
5060
return a;

0 commit comments

Comments
 (0)