33 template <
typename T> T
mix(
const T& a,
const T& b,
float f)
35 if constexpr (std::is_integral_v<T>) {
36 const auto lo =
static_cast<double>(std::numeric_limits<T>::lowest());
37 const auto hi =
static_cast<double>(std::numeric_limits<T>::max());
38 const double v =
static_cast<double>(a)
39 + ((
static_cast<double>(b) -
static_cast<double>(a)) *
static_cast<double>(f));
41 return std::numeric_limits<T>::lowest();
44 return std::numeric_limits<T>::max();
46 return static_cast<T
>(v);
48 return a + (b - a) * f;
107template <
typename T,
typename Func> T
ease(
const T& a,
const T& b,
float t, Func func)
109 static_assert(std::is_arithmetic_v<T>,
"T must be an arithmetic type");
110 static_assert(std::is_invocable_r_v<float, Func, float>,
111 "Func must be a callable that takes a float and returns a float");
113 return detail::mix(a, b, func(std::clamp(t, 0.0F, 1.0F)));
T mix(const T &a, const T &b, float f)
a + (b - a) * f. Integer types are worked in floating point, so a falling unsigned range does not wra...
float ease_out_cubic(float t)
float smoothstep(float t)
Soft at both ends, 3t^2 - 2t^3.
float ease_out_quad(float t)
float ease_in_out_expo(float t)
float ease_in_elastic(float t)
T ease(const T &a, const T &b, float t, Func func)
float ease_out_bounce(float t)
float ease_in_out_quad(float t)
float ease_out_back(float t)
float ease_in_out_cubic(float t)
float ease_in_back(float t)
float ease_out_sine(float t)
float ease_in_cubic(float t)
float ease_in_quad(float t)
float falloff(float t, asw::Falloff mode)
float ease_in_sine(float t)
float ease_in_out_sine(float t)
float ease_out_elastic(float t)
float ease_out_expo(float t)
float ease_in_expo(float t)
float ease_in_bounce(float t)
Falloff
How a gradient or light fades from its centre to its edge.
Types used throughout the ASW library.