raylib-cpp
C++ object-oriented wrapper library for raylib.
Rectangle.hpp
1 #ifndef RAYLIB_CPP_RECTANGLE_HPP_
2 #define RAYLIB_CPP_RECTANGLE_HPP_
3 
4 #ifdef __cplusplus
5 extern "C"{
6 #endif
7 #include "raylib.h"
8 #ifdef __cplusplus
9 }
10 #endif
11 
12 #include "./raylib-cpp-utils.hpp"
13 #include "./Vector2.hpp"
14 
15 namespace raylib {
16  class Rectangle : public ::Rectangle {
17  public:
19  set(vec);
20  };
21  Rectangle(float X = 0, float Y = 0, float Width = 0, float Height = 0) {
22  x = X;
23  y = Y;
24  width = Width;
25  height = Height;
26  };
27 
28  inline void set(::Rectangle rect) {
29  x = rect.x;
30  y = rect.y;
31  width = rect.width;
32  height = rect.height;
33  }
34 
35  GETTERSETTER(float,X,x)
36  GETTERSETTER(float,Y,y)
37  GETTERSETTER(float,Width,width)
38  GETTERSETTER(float,Height,height)
39 
40  Rectangle& operator=(const ::Rectangle& rect) {
41  set(rect);
42  return *this;
43  }
44 
45  Rectangle& operator=(const Rectangle& rect) {
46  set(rect);
47  return *this;
48  }
49 
50  inline Rectangle& Draw(::Color color) {
51  ::DrawRectangle(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color);
52  return *this;
53  }
54  inline Rectangle& Draw(::Vector2 origin, float rotation, ::Color color) {
55  ::DrawRectanglePro(*this, origin, rotation, color);
56  return *this;
57  }
58 
59  inline Rectangle& DrawGradientV(::Color color1, ::Color color2){
60  ::DrawRectangleGradientV(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color1, color2);
61  return *this;
62  }
63 
64  inline Rectangle& DrawGradientH(::Color color1, ::Color color2) {
65  ::DrawRectangleGradientH(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color1, color2);
66  return *this;
67  }
68 
69  inline Rectangle& DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4) {
70  ::DrawRectangleGradientEx(*this, col1, col2, col3, col4);
71  return *this;
72  }
73 
74  inline Rectangle& DrawLines(::Color color){
75  ::DrawRectangleLines(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color);
76  return *this;
77  }
78  inline Rectangle& DrawLinesEx(int lineThick, ::Color color){
79  ::DrawRectangleLinesEx(*this, lineThick, color);
80  return *this;
81  }
82 
83  inline Rectangle& DrawRounded(float roundness, int segments, ::Color color){
84  ::DrawRectangleRounded(*this, roundness, segments, color);
85  return *this;
86  }
87 
88  inline Rectangle& DrawRoundedLines(float roundness, int segments, int lineThick, ::Color color) {
89  ::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color);
90  return *this;
91  }
92 
93  inline bool CheckCollision(::Rectangle rec2) {
94  return ::CheckCollisionRecs(*this, rec2);
95  }
96 
97  inline Rectangle GetCollision(::Rectangle rec2) {
98  return ::GetCollisionRec(*this, rec2);
99  }
100 
101  inline bool CheckCollision(::Vector2 point) {
102  return ::CheckCollisionPointRec(point, *this);
103  }
104  };
105 }
106 
107 #endif
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
raylib::Rectangle::CheckCollision
bool CheckCollision(::Rectangle rec2)
Definition: Rectangle.hpp:93
raylib::Rectangle::CheckCollision
bool CheckCollision(::Vector2 point)
Definition: Rectangle.hpp:101
raylib::Rectangle::DrawRounded
Rectangle & DrawRounded(float roundness, int segments, ::Color color)
Definition: Rectangle.hpp:83
raylib::Rectangle::set
void set(::Rectangle rect)
Definition: Rectangle.hpp:28
raylib::Rectangle::DrawGradientH
Rectangle & DrawGradientH(::Color color1, ::Color color2)
Definition: Rectangle.hpp:64
raylib::Rectangle::Draw
Rectangle & Draw(::Vector2 origin, float rotation, ::Color color)
Definition: Rectangle.hpp:54
raylib::Rectangle::DrawLinesEx
Rectangle & DrawLinesEx(int lineThick, ::Color color)
Definition: Rectangle.hpp:78
raylib::Rectangle::DrawGradientV
Rectangle & DrawGradientV(::Color color1, ::Color color2)
Definition: Rectangle.hpp:59
raylib::Rectangle::DrawLines
Rectangle & DrawLines(::Color color)
Definition: Rectangle.hpp:74
raylib::Rectangle
Definition: Rectangle.hpp:16
raylib::Vector2
Definition: Vector2.hpp:22
raylib::Rectangle::Rectangle
Rectangle(float X=0, float Y=0, float Width=0, float Height=0)
Definition: Rectangle.hpp:21
raylib::Rectangle::Rectangle
Rectangle(::Rectangle vec)
Definition: Rectangle.hpp:18
raylib::Color
Definition: Color.hpp:18
raylib::Rectangle::DrawGradient
Rectangle & DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4)
Definition: Rectangle.hpp:69
raylib::Rectangle::Draw
Rectangle & Draw(::Color color)
Definition: Rectangle.hpp:50
raylib::Rectangle::GetCollision
Rectangle GetCollision(::Rectangle rec2)
Definition: Rectangle.hpp:97
raylib::Rectangle::DrawRoundedLines
Rectangle & DrawRoundedLines(float roundness, int segments, int lineThick, ::Color color)
Definition: Rectangle.hpp:88
raylib::Rectangle::operator=
Rectangle & operator=(const Rectangle &rect)
Definition: Rectangle.hpp:45