diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-01-04 15:01:25 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-04 17:48:28 +0000 |
commit | 8da0925d6d4696b050dc0862979beb391508f7ee (patch) | |
tree | e4b4a7ec07a60f33c2558796b5ecd248b8bf5327 /AK | |
parent | 10efbfb09e45a9f41250d9075c789082d69f83fe (diff) | |
download | serenity-8da0925d6d4696b050dc0862979beb391508f7ee.zip |
AK: Add `mix`
Diffstat (limited to 'AK')
-rw-r--r-- | AK/StdLibExtras.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 844996cacf..2fcb8565b9 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -92,6 +92,12 @@ constexpr T clamp(const T& value, const IdentityType<T>& min, const IdentityType } template<typename T, typename U> +constexpr T mix(T const& v1, T const& v2, U const& interpolation) +{ + return v1 + (v2 - v1) * interpolation; +} + +template<typename T, typename U> constexpr T ceil_div(T a, U b) { static_assert(sizeof(T) == sizeof(U)); @@ -167,6 +173,7 @@ using AK::exchange; using AK::is_constant_evaluated; using AK::max; using AK::min; +using AK::mix; using AK::RawPtr; using AK::swap; using AK::to_underlying; |