LibWeb: Round integral values to the nearest integer when interpolating

Previously, color components were being incorrectly rounded when
interpolating.
This commit is contained in:
Tim Ledbetter 2025-07-29 18:48:32 +01:00 committed by Jelle Raaijmakers
parent 3c3f1f9fad
commit 3ae48776fd
Notes: github-actions[bot] 2025-07-30 08:53:04 +00:00
5 changed files with 63 additions and 63 deletions

View file

@ -42,7 +42,7 @@ static T interpolate_raw(T from, T to, float delta)
} else if constexpr (AK::Detail::IsIntegral<T>) {
auto from_float = static_cast<float>(from);
auto to_float = static_cast<float>(to);
auto unclamped_result = from_float + (to_float - from_float) * delta;
auto unclamped_result = roundf(from_float + (to_float - from_float) * delta);
return static_cast<AK::Detail::RemoveCVReference<T>>(clamp(unclamped_result, NumericLimits<T>::min(), NumericLimits<T>::max()));
}
return static_cast<AK::Detail::RemoveCVReference<T>>(from + (to - from) * delta);