1#ifndef RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
2#define RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
4#include "./Vector2.hpp"
5#include "./Vector4.hpp"
6#include "./RadiansDegrees.hpp"
14 Rectangle(const ::Rectangle& rect) : ::Rectangle{rect.x, rect.y, rect.width, rect.height} {}
16 Rectangle(
float x,
float y,
float width,
float height) : ::Rectangle{x, y, width, height} {}
17 Rectangle(
float x,
float y,
float width) : ::Rectangle{x, y, width, 0} {}
18 Rectangle(
float x,
float y) : ::Rectangle{x, y, 0, 0} {}
19 Rectangle(
float x) : ::Rectangle{x, 0, 0, 0} {}
22 Rectangle(::Vector2 position, ::Vector2 size) : ::Rectangle{position.x, position.y, size.x, size.y} {}
23 Rectangle(::Vector2 size) : ::Rectangle{0, 0, size.x, size.y} {}
24 Rectangle(::Vector4 rect) : ::Rectangle{rect.x, rect.y, rect.z, rect.w} {}
26 GETTERSETTER(
float, X, x)
27 GETTERSETTER(
float, Y, y)
28 GETTERSETTER(
float, Width, width)
29 GETTERSETTER(
float, Height, height)
37 return {x, y, width, height};
40 operator Vector4()
const {
41 return {x, y, width, height};
47 void Draw(::Color color)
const { ::DrawRectangleRec(*
this, color); }
49 void Draw(::Vector2 origin,
Degree rotation, ::Color color)
const {
50 ::DrawRectanglePro(*
this, origin, rotation, color);
53 void DrawGradientV(::Color color1, ::Color color2)
const {
54 ::DrawRectangleGradientV(
57 static_cast<int>(width),
58 static_cast<int>(height),
63 void DrawGradientH(::Color color1, ::Color color2)
const {
64 ::DrawRectangleGradientH(
67 static_cast<int>(width),
68 static_cast<int>(height),
73 void DrawGradient(::Color topLeft, ::Color bottomLeft, ::Color topRight, ::Color bottomRight)
const {
74 ::DrawRectangleGradientEx(*
this, topLeft, bottomLeft, topRight, bottomRight);
77 void DrawLines(::Color color)
const {
81 static_cast<int>(width),
82 static_cast<int>(height),
86 void DrawLines(::Color color,
float lineThick)
const { ::DrawRectangleLinesEx(*
this, lineThick, color); }
88 void DrawRounded(
float roundness,
int segments, ::Color color)
const {
89 ::DrawRectangleRounded(*
this, roundness, segments, color);
92 void DrawRoundedLines(
float roundness,
int segments, ::Color color)
const {
93 ::DrawRectangleRoundedLines(*
this, roundness, segments, color);
96 void DrawRoundedLines(
float roundness,
int segments,
float lineThick, ::Color color)
const {
97 DrawRectangleRoundedLinesEx(*
this, roundness, segments, lineThick, color);
103 [[nodiscard]]
bool CheckCollision(::Rectangle rec2)
const { return ::CheckCollisionRecs(*
this, rec2); }
109 return ::GetCollisionRec(*
this, rec2);
115 [[nodiscard]]
bool CheckCollision(::Vector2 point)
const { return ::CheckCollisionPointRec(point, *
this); }
121 return ::CheckCollisionCircleRec(center, radius, *
this);
124 [[nodiscard]]
Vector2 GetSize()
const {
return {width, height}; }
126 Rectangle& SetSize(
float newWidth,
float newHeight) {
132 Rectangle& SetSize(const ::Vector2& size) {
return SetSize(size.x, size.y); }
134 Rectangle& SetShapesTexture(const ::Texture2D& texture) {
135 ::SetShapesTexture(texture, *
this);
139 [[nodiscard]] Vector2 GetPosition()
const {
return {x, y}; }
141 Rectangle& SetPosition(
float newX,
float newY) {
147 Rectangle& SetPosition(const ::Vector2& position) {
return SetPosition(position.x, position.y); }
149 void set(const ::Rectangle& rect) {
153 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.
All raylib-cpp classes and functions appear in the raylib namespace.