mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
AK: Add FixedPoint::clamp
This commit is contained in:
parent
7b3b743f88
commit
961e263129
Notes:
sideshowbarker
2024-07-16 23:44:31 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/961e263129 Pull-request: https://github.com/SerenityOS/serenity/pull/17391 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/frhun
1 changed files with 9 additions and 0 deletions
|
@ -95,6 +95,15 @@ public:
|
|||
return create_raw(m_value & radix_mask);
|
||||
}
|
||||
|
||||
constexpr This clamp(This minimum, This maximum) const
|
||||
{
|
||||
if (*this < minimum)
|
||||
return minimum;
|
||||
if (*this > maximum)
|
||||
return maximum;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr This round() const
|
||||
{
|
||||
return This { static_cast<Underlying>(*this) };
|
||||
|
|
Loading…
Add table
Reference in a new issue