diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-12-14 20:20:17 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-12-14 20:20:17 +0800 |
| commit | abc02cfae45c86519a795da6d14d8c85d57ae6f5 (patch) | |
| tree | 5552ada0bb3e4b2931d3b978f813b7c4a1bfa029 /include/cru/platform/GraphicsBase.h | |
| parent | c0c0106cf47fdff397756913b8646541f3bb9928 (diff) | |
| download | cru-abc02cfae45c86519a795da6d14d8c85d57ae6f5.tar.gz cru-abc02cfae45c86519a795da6d14d8c85d57ae6f5.tar.bz2 cru-abc02cfae45c86519a795da6d14d8c85d57ae6f5.zip | |
Add some rect unit tests.
Diffstat (limited to 'include/cru/platform/GraphicsBase.h')
| -rw-r--r-- | include/cru/platform/GraphicsBase.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h index 14c5d926..78a1c1a6 100644 --- a/include/cru/platform/GraphicsBase.h +++ b/include/cru/platform/GraphicsBase.h @@ -113,10 +113,6 @@ struct Thickness final { void SetAll(const float value) { left = top = right = bottom = value; } - constexpr float Validate() const { - return left >= 0.0 && top >= 0.0 && right >= 0.0 && bottom >= 0.0; - } - constexpr bool operator==(const Thickness& other) const = default; float left; @@ -139,6 +135,20 @@ constexpr Thickness operator+(const Thickness& left, const Thickness& right) { left.right + right.right, left.bottom + right.bottom}; } +constexpr Thickness operator*(const Thickness& thickness, float scale) { + return {thickness.left * scale, thickness.top * scale, + thickness.right * scale, thickness.bottom * scale}; +} + +constexpr Thickness operator*(float scale, const Thickness& thickness) { + return operator*(thickness, scale); +} + +constexpr Thickness operator/(const Thickness& thickness, float scale) { + return {thickness.left / scale, thickness.top / scale, + thickness.right / scale, thickness.bottom / scale}; +} + struct Rect final { constexpr Rect() = default; constexpr Rect(const float left, const float top, const float width, |
