mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
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:
parent
2be89597a8
commit
5b5b4f57fa
1 changed files with 6 additions and 0 deletions
|
@ -87,6 +87,12 @@ public:
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] constexpr float aspect_ratio() const
|
||||||
|
{
|
||||||
|
VERIFY(height() != 0);
|
||||||
|
return static_cast<float>(width()) / static_cast<float>(height());
|
||||||
|
}
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
[[nodiscard]] constexpr bool contains(Size<U> const& other) const
|
[[nodiscard]] constexpr bool contains(Size<U> const& other) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue