1#ifndef RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
2#define RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
5#include "./raylib-cpp-utils.hpp"
6#include "./Vector2.hpp"
7#include "./Vector4.hpp"
8#include "./RadiansDegrees.hpp"
16 Rectangle(const ::Rectangle& rect) : ::Rectangle{rect.x, rect.y, rect.width, rect.height} {}
18 Rectangle(
float x,
float y,
float width,
float height) : ::Rectangle{x, y, width, height} {}
19 Rectangle(
float x,
float y,
float width) : ::Rectangle{x, y, width, 0} {}
20 Rectangle(
float x,
float y) : ::Rectangle{x, y, 0, 0} {}
21 Rectangle(
float x) : ::Rectangle{x, 0, 0, 0} {}
24 Rectangle(::Vector2 position, ::Vector2 size)
25 : ::Rectangle{position.x, position.y, size.x, size.y} {}
26 Rectangle(::Vector2 size) : ::Rectangle{0, 0, size.x, size.y} {}
27 Rectangle(::Vector4 rect) : ::Rectangle{rect.x, rect.y, rect.z, rect.w} {}
29 GETTERSETTER(
float, X, x)
30 GETTERSETTER(
float, Y, y)
31 GETTERSETTER(
float, Width, width)
32 GETTERSETTER(
float, Height, height)
40 return {x, y, width, height};
43 operator Vector4()
const {
44 return {x, y, width, height};
50 void Draw(::Color color)
const {
51 ::DrawRectangleRec(*
this, color);
54 void Draw(::Vector2 origin,
Degree rotation, ::Color color)
const {
55 ::DrawRectanglePro(*
this, origin, rotation, color);
58 void DrawGradientV(::Color color1, ::Color color2)
const {
59 ::DrawRectangleGradientV(
static_cast<int>(x),
static_cast<int>(y),
static_cast<int>(width),
60 static_cast<int>(height), color1, color2);
63 void DrawGradientH(::Color color1, ::Color color2)
const {
64 ::DrawRectangleGradientH(
static_cast<int>(x),
static_cast<int>(y),
static_cast<int>(width),
65 static_cast<int>(height), color1, color2);
68 void DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4)
const {
69 ::DrawRectangleGradientEx(*
this, col1, col2, col3, col4);
72 void DrawLines(::Color color)
const {
73 ::DrawRectangleLines(
static_cast<int>(x),
static_cast<int>(y),
static_cast<int>(width),
74 static_cast<int>(height), color);
77 void DrawLines(::Color color,
float lineThick)
const {
78 ::DrawRectangleLinesEx(*
this, lineThick, color);
81 void DrawRounded(
float roundness,
int segments, ::Color color)
const {
82 ::DrawRectangleRounded(*
this, roundness, segments, color);
85 void DrawRoundedLines(
float roundness,
int segments, ::Color color)
const {
86 #if RAYLIB_VERSION_MAJOR == 5 && RAYLIB_VERSION_MINOR == 0
87 ::DrawRectangleRoundedLines(*
this, roundness, segments, 1.0f, color);
89 ::DrawRectangleRoundedLines(*
this, roundness, segments, color);
93 void DrawRoundedLines(
float roundness,
int segments,
94 float lineThick, ::Color color)
const {
95 #if RAYLIB_VERSION_MAJOR == 5 && RAYLIB_VERSION_MINOR == 0
96 ::DrawRectangleRoundedLines(*
this, roundness, segments, lineThick, color);
98 DrawRectangleRoundedLinesEx(*
this, roundness, segments, lineThick, color);
106 return ::CheckCollisionRecs(*
this, rec2);
113 return ::GetCollisionRec(*
this, rec2);
120 return ::CheckCollisionPointRec(point, *
this);
127 return ::CheckCollisionCircleRec(center, radius, *
this);
131 return {width, height};
134 Rectangle& SetSize(
float newWidth,
float newHeight) {
140 Rectangle& SetSize(const ::Vector2& size) {
141 return SetSize(size.x, size.y);
144 Rectangle& SetShapesTexture(const ::Texture2D& texture) {
145 ::SetShapesTexture(texture, *
this);
149 Vector2 GetPosition()
const {
153 Rectangle& SetPosition(
float newX,
float newY) {
159 Rectangle& SetPosition(const ::Vector2& position) {
160 return SetPosition(position.x, position.y);
164 void set(const ::Rectangle& rect) {
168 height = rect.height;
Degree type (allows automatic worry free conversion between radians and degrees)
Rectangle GetCollision(::Rectangle rec2) const
Get collision rectangle for two rectangles collision.
bool CheckCollision(::Rectangle rec2) const
Check collision between two rectangles.
void Draw(::Color color) const
Draw a color-filled rectangle.
bool CheckCollision(::Vector2 center, float radius) const
Check collision between circle and rectangle.
bool CheckCollision(::Vector2 point) const
Check if point is inside rectangle.