mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +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
Notes:
sideshowbarker
2024-07-17 07:48:42 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/5b5b4f57fa Pull-request: https://github.com/SerenityOS/serenity/pull/15718 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/davidot ✅ Reviewed-by: https://github.com/idispatch ✅
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue