diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-11-27 18:08:18 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-11-27 18:08:18 +0800 |
| commit | b0be1fbc5b615141d6c2104624bd4b68dc52371f (patch) | |
| tree | a52fa33df6fb290a4e8ce9be155f7c643182917a /include/cru/platform/GraphicsBase.h | |
| parent | 97ca464fc9e9da4e20e3320559a6f4ac3203fe84 (diff) | |
| download | cru-b0be1fbc5b615141d6c2104624bd4b68dc52371f.tar.gz cru-b0be1fbc5b615141d6c2104624bd4b68dc52371f.tar.bz2 cru-b0be1fbc5b615141d6c2104624bd4b68dc52371f.zip | |
Impl sdl get/set client/window rect.
Diffstat (limited to 'include/cru/platform/GraphicsBase.h')
| -rw-r--r-- | include/cru/platform/GraphicsBase.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h index dccff4e1..81c44cb6 100644 --- a/include/cru/platform/GraphicsBase.h +++ b/include/cru/platform/GraphicsBase.h @@ -157,7 +157,8 @@ struct Rect final { constexpr static Rect FromVertices(const Point& lefttop, const Point& rightbottom) { - return Rect(lefttop.x, lefttop.y, rightbottom.x - lefttop.x, rightbottom.y - lefttop.y); + return Rect(lefttop.x, lefttop.y, rightbottom.x - lefttop.x, + rightbottom.y - lefttop.y); } constexpr static Rect FromCenter(const Point& center, const float width, @@ -215,6 +216,10 @@ struct Rect final { return result; } + constexpr Rect Scale(float scale) const { + return {left * scale, top * scale, width * scale, height * scale}; + } + constexpr bool IsPointInside(const Point& point) const { return point.x >= left && point.x < GetRight() && point.y >= top && point.y < GetBottom(); |
