1 #ifndef RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
2 #define RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
4 #include "./raylib.hpp"
5 #include "./raylib-cpp-utils.hpp"
6 #include "./Vector2.hpp"
23 :
::Rectangle{position.x, position.y, size.x, size.y} {}
27 GETTERSETTER(
float, X, x)
28 GETTERSETTER(
float, Y, y)
29 GETTERSETTER(
float, Width, width)
30 GETTERSETTER(
float, Height, height)
37 inline ::Vector4 ToVector4() {
38 return {x, y, width, height};
41 operator ::Vector4()
const {
42 return {x, y, width, height};
49 ::DrawRectangleRec(*
this, color);
53 ::DrawRectanglePro(*
this, origin, rotation, color);
56 inline void DrawGradientV(::Color color1, ::Color color2)
const {
57 ::DrawRectangleGradientV(
static_cast<int>(x),
static_cast<int>(y),
static_cast<int>(width),
58 static_cast<int>(height), color1, color2);
61 inline void DrawGradientH(::Color color1, ::Color color2)
const {
62 ::DrawRectangleGradientH(
static_cast<int>(x),
static_cast<int>(y),
static_cast<int>(width),
63 static_cast<int>(height), color1, color2);
66 inline void DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4)
const {
67 ::DrawRectangleGradientEx(*
this, col1, col2, col3, col4);
70 inline void DrawLines(::Color color)
const {
71 ::DrawRectangleLines(
static_cast<int>(x),
static_cast<int>(y),
static_cast<int>(width),
72 static_cast<int>(height), color);
75 inline void DrawLines(::Color color,
float lineThick)
const {
76 ::DrawRectangleLinesEx(*
this, lineThick, color);
79 inline void DrawRounded(
float roundness,
int segments, ::Color color)
const {
80 ::DrawRectangleRounded(*
this, roundness, segments, color);
83 inline void DrawRoundedLines(
float roundness,
int segments,
84 float lineThick, ::Color color)
const {
85 ::DrawRectangleRoundedLines(*
this, roundness, segments, lineThick, color);
92 return ::CheckCollisionRecs(*
this, rec2);
99 return ::GetCollisionRec(*
this, rec2);
106 return ::CheckCollisionPointRec(point, *
this);
113 return ::CheckCollisionCircleRec(center, radius, *
this);
117 return {width, height};
120 inline Rectangle& SetSize(
float newWidth,
float newHeight) {
126 inline Rectangle& SetSize(const ::Vector2& size) {
127 return SetSize(size.x, size.y);
130 inline Rectangle& SetShapesTexture(const ::Texture2D& texture) {
131 ::SetShapesTexture(texture, *
this);
135 inline Vector2 GetPosition() {
139 inline Rectangle& SetPosition(
float newX,
float newY) {
145 inline Rectangle& SetPosition(const ::Vector2& position) {
146 return SetPosition(position.x, position.y);
150 void set(const ::Rectangle& rect) {
154 height = rect.height;
bool CheckCollision(::Rectangle rec2) const
Check collision between two rectangles.
inline ::Rectangle GetCollision(::Rectangle rec2) const
Get collision rectangle for two rectangles collision.
void Draw(::Color color) const
Draw a color-filled rectangle.
bool CheckCollision(::Vector2 center, float radius)
Check collision between circle and rectangle.
bool CheckCollision(::Vector2 point) const
Check if point is inside rectangle.
All raylib-cpp classes and functions appear in the raylib namespace.