mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
LibGfx: Refactor Point.constrain to use AK
This commit is contained in:
parent
cc829ed9d2
commit
c88756078a
1 changed files with 2 additions and 11 deletions
|
@ -15,17 +15,8 @@ namespace Gfx {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Point<T>::constrain(Rect<T> const& rect)
|
void Point<T>::constrain(Rect<T> const& rect)
|
||||||
{
|
{
|
||||||
if (x() < rect.left()) {
|
m_x = AK::clamp<T>(x(), rect.left(), rect.right());
|
||||||
set_x(rect.left());
|
m_y = AK::clamp<T>(y(), rect.top(), rect.bottom());
|
||||||
} else if (x() > rect.right()) {
|
|
||||||
set_x(rect.right());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y() < rect.top()) {
|
|
||||||
set_y(rect.top());
|
|
||||||
} else if (y() > rect.bottom()) {
|
|
||||||
set_y(rect.bottom());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue