Merge pull request #8789 from Robyt3/Client-UI-Convenience

Add `CUIRect::TopLeft` and `Size` convenience functions
This commit is contained in:
Dennis Felsing 2024-08-22 22:43:59 +00:00 committed by GitHub
commit 0013615da1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -136,7 +136,24 @@ public:
void Draw(ColorRGBA Color, int Corners, float Rounding) const; void Draw(ColorRGBA Color, int Corners, float Rounding) const;
void Draw4(ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, int Corners, float Rounding) const; void Draw4(ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, int Corners, float Rounding) const;
vec2 Center() const { return vec2(x + w / 2.0f, y + h / 2.0f); } /**
* Returns the top-left position of *this* CUIRect as a vec2.
*
* @return Top-left position as vec2.
*/
vec2 TopLeft() const { return vec2(x, y); }
/**
* Returns the size of *this* CUIRect as a vec2.
*
* @return Size as vec2.
*/
vec2 Size() const { return vec2(w, h); }
/**
* Returns the center position of *this* CUIRect as a vec2.
*
* @return Center position as vec2.
*/
vec2 Center() const { return TopLeft() + Size() / 2.0f; }
}; };
#endif #endif