diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-11-22 21:24:18 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-11-22 21:24:18 +0800 |
| commit | 8f8b7dfd056dfa23dd1989d3f3dfd3d5d91d0168 (patch) | |
| tree | 435917530667bd4532c9bb70826c5796ca1ffa6a /include/cru/platform/GraphicsBase.h | |
| parent | 7ce185d5a3fcfad8c8f746f95f3d50a8829faac4 (diff) | |
| download | cru-8f8b7dfd056dfa23dd1989d3f3dfd3d5d91d0168.tar.gz cru-8f8b7dfd056dfa23dd1989d3f3dfd3d5d91d0168.tar.bz2 cru-8f8b7dfd056dfa23dd1989d3f3dfd3d5d91d0168.zip | |
Clean measure requirement codes.
Diffstat (limited to 'include/cru/platform/GraphicsBase.h')
| -rw-r--r-- | include/cru/platform/GraphicsBase.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h index 43c36494..89d3df77 100644 --- a/include/cru/platform/GraphicsBase.h +++ b/include/cru/platform/GraphicsBase.h @@ -56,6 +56,16 @@ struct Size final { std::numeric_limits<float>::max()}; } + constexpr Size Min(const Size& other) const { + return {std::min(width, other.width), std::min(height, other.height)}; + } + + constexpr Size Max(const Size& other) const { + return {std::max(width, other.width), std::max(height, other.height)}; + } + + constexpr Size AtLeast0() const { return Max(kZero); } + std::string ToString() const { return std::format("Size(width: {}, height: {})", width, height); } @@ -93,6 +103,10 @@ struct Thickness final { constexpr float GetVerticalTotal() const { return top + bottom; } + constexpr Size GetTotalSize() const { + return {GetHorizontalTotal(), GetVerticalTotal()}; + } + void SetLeftRight(const float value) { left = right = value; } void SetTopBottom(const float value) { top = bottom = value; } |
