MCPcopy Create free account
hub / github.com/RobLoach/raylib-cpp / Rectangle

Class Rectangle

include/Rectangle.hpp:12–157  ·  view source on GitHub ↗

* Rectangle type */

Source from the content-addressed store, hash-verified

10 * Rectangle type
11 */
12class Rectangle : public ::Rectangle {
13public:
14 constexpr Rectangle(const ::Rectangle& rect) : ::Rectangle{rect.x, rect.y, rect.width, rect.height} {}
15
16 constexpr Rectangle(float x = 0, float y = 0, float width = 0, float height = 0) : ::Rectangle{x, y, width, height} {}
17
18 constexpr Rectangle(::Vector2 position, ::Vector2 size) : ::Rectangle{position.x, position.y, size.x, size.y} {}
19 constexpr Rectangle(::Vector2 size) : ::Rectangle{0, 0, size.x, size.y} {}
20 constexpr Rectangle(::Vector4 rect) : ::Rectangle{rect.x, rect.y, rect.z, rect.w} {}
21
22 GETTERSETTER(float, X, x)
23 GETTERSETTER(float, Y, y)
24 GETTERSETTER(float, Width, width)
25 GETTERSETTER(float, Height, height)
26
27 Rectangle& operator=(const ::Rectangle& rect) {
28 set(rect);
29 return *this;
30 }
31
32 constexpr ::Vector4 ToVector4() const { return {x, y, width, height}; }
33
34 constexpr explicit operator ::Vector4() const { return {x, y, width, height}; }
35
36 [[nodiscard]] std::string ToString() const { return TextFormat("Rectangle(%fx%f, %fx%f)", x, y, width, height); }
37
38 operator std::string() const { return ToString(); }
39
40 /**
41 * Draw a color-filled rectangle
42 */
43 static void Draw(int posX, int posY, int width, int height, ::Color color) {
44 ::DrawRectangle(posX, posY, width, height, color);
45 }
46
47 static void Draw(::Vector2 position, ::Vector2 size, ::Color color) {
48 ::DrawRectangleV(position, size, color);
49 }
50
51 void Draw(::Color color) const { ::DrawRectangleRec(*this, color); }
52
53 void Draw(::Vector2 origin, float rotation, ::Color color) const {
54 ::DrawRectanglePro(*this, origin, rotation, color);
55 }
56
57 void DrawGradientV(::Color color1, ::Color color2) const {
58 ::DrawRectangleGradientV(
59 static_cast<int>(x),
60 static_cast<int>(y),
61 static_cast<int>(width),
62 static_cast<int>(height),
63 color1,
64 color2);
65 }
66
67 void DrawGradientH(::Color color1, ::Color color2) const {
68 ::DrawRectangleGradientH(
69 static_cast<int>(x),

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 1

SetPositionFunction · 0.85

Tested by

no test coverage detected