1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +00:00

LibGfx: Implement Rect resizing around a fixed point

This commit is contained in:
Ben Wiederhake 2021-01-23 01:16:06 +01:00 committed by Andreas Kling
parent 6a552f0b93
commit e8997e1de9
2 changed files with 12 additions and 0 deletions

View file

@ -141,6 +141,16 @@ void Rect<T>::align_within(const Rect<T>& other, TextAlignment alignment)
}
}
template<typename T>
void Rect<T>::set_size_around(const Size<T>& new_size, const Point<T>& fixed_point)
{
const T new_x = fixed_point.x() - (T)(new_size.width() * ((float)(fixed_point.x() - x()) / width()));
const T new_y = fixed_point.y() - (T)(new_size.height() * ((float)(fixed_point.y() - y()) / height()));
set_location({ new_x, new_y });
set_size(new_size);
}
template<>
String IntRect::to_string() const
{