LibGfx: Add Size::aspect_ratio

This can compute the aspect ratio of the size.
It can use another type for these computations,
which is important for integer sizes.
This commit is contained in:
kleines Filmröllchen 2022-10-21 14:23:12 +02:00 committed by Andrew Kaster
parent 2be89597a8
commit 5b5b4f57fa
Notes: sideshowbarker 2024-07-17 07:48:42 +09:00

View file

@ -87,6 +87,12 @@ public:
return size;
}
[[nodiscard]] constexpr float aspect_ratio() const
{
VERIFY(height() != 0);
return static_cast<float>(width()) / static_cast<float>(height());
}
template<typename U>
[[nodiscard]] constexpr bool contains(Size<U> const& other) const
{