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  GETTERSETTER(float,X,x)
29  GETTERSETTER(float,Y,y)
30  GETTERSETTER(float,Width,width)
31  GETTERSETTER(float,Height,height)
32 
33  Rectangle& operator=(const ::Rectangle& rect) {
34  set(rect);
35  return *this;
36  }
37 
38  Rectangle& operator=(const Rectangle& rect) {
39  set(rect);
40  return *this;
41  }
42 
43  inline Rectangle& Draw(::Color color) {
44  ::DrawRectangle(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color);
45  return *this;
46  }
47  inline Rectangle& Draw(::Vector2 origin, float rotation, ::Color color) {
48  ::DrawRectanglePro(*this, origin, rotation, color);
49  return *this;
50  }
51 
52  inline Rectangle& DrawGradientV(::Color color1, ::Color color2){
53  ::DrawRectangleGradientV(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color1, color2);
54  return *this;
55  }
56 
57  inline Rectangle& DrawGradientH(::Color color1, ::Color color2) {
58  ::DrawRectangleGradientH(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color1, color2);
59  return *this;
60  }
61 
62  inline Rectangle& DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4) {
63  ::DrawRectangleGradientEx(*this, col1, col2, col3, col4);
64  return *this;
65  }
66 
67  inline Rectangle& DrawLines(::Color color){
68  ::DrawRectangleLines(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color);
69  return *this;
70  }
71  inline Rectangle& DrawLinesEx(int lineThick, ::Color color){
72  ::DrawRectangleLinesEx(*this, lineThick, color);
73  return *this;
74  }
75 
76  inline Rectangle& DrawRounded(float roundness, int segments, ::Color color){
77  ::DrawRectangleRounded(*this, roundness, segments, color);
78  return *this;
79  }
80 
81  inline Rectangle& DrawRoundedLines(float roundness, int segments, int lineThick, ::Color color) {
82  ::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color);
83  return *this;
84  }
85 
86  inline bool CheckCollision(::Rectangle rec2) const {
87  return ::CheckCollisionRecs(*this, rec2);
88  }
89 
90  inline Rectangle GetCollision(::Rectangle rec2) const {
91  return ::GetCollisionRec(*this, rec2);
92  }
93 
94  inline bool CheckCollision(::Vector2 point) const {
95  return ::CheckCollisionPointRec(point, *this);
96  }
97 
98  protected:
99  inline void set(::Rectangle rect) {
100  x = rect.x;
101  y = rect.y;
102  width = rect.width;
103  height = rect.height;
104  }
105  };
106 }
107 
108 #endif
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
raylib::Rectangle::DrawRounded
Rectangle & DrawRounded(float roundness, int segments, ::Color color)
Definition: Rectangle.hpp:76
raylib::Rectangle::set
void set(::Rectangle rect)
Definition: Rectangle.hpp:99
raylib::Rectangle::DrawGradientH
Rectangle & DrawGradientH(::Color color1, ::Color color2)
Definition: Rectangle.hpp:57
raylib::Rectangle::Draw
Rectangle & Draw(::Vector2 origin, float rotation, ::Color color)
Definition: Rectangle.hpp:47
raylib::Rectangle::DrawLinesEx
Rectangle & DrawLinesEx(int lineThick, ::Color color)
Definition: Rectangle.hpp:71
raylib::Rectangle::DrawGradientV
Rectangle & DrawGradientV(::Color color1, ::Color color2)
Definition: Rectangle.hpp:52
raylib::Rectangle::DrawLines
Rectangle & DrawLines(::Color color)
Definition: Rectangle.hpp:67
raylib::Rectangle::CheckCollision
bool CheckCollision(::Vector2 point) const
Definition: Rectangle.hpp:94
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::GetCollision
Rectangle GetCollision(::Rectangle rec2) const
Definition: Rectangle.hpp:90
raylib::Rectangle::DrawGradient
Rectangle & DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4)
Definition: Rectangle.hpp:62
raylib::Rectangle::CheckCollision
bool CheckCollision(::Rectangle rec2) const
Definition: Rectangle.hpp:86
raylib::Rectangle::Draw
Rectangle & Draw(::Color color)
Definition: Rectangle.hpp:43
raylib::Rectangle::DrawRoundedLines
Rectangle & DrawRoundedLines(float roundness, int segments, int lineThick, ::Color color)
Definition: Rectangle.hpp:81
raylib::Rectangle::operator=
Rectangle & operator=(const Rectangle &rect)
Definition: Rectangle.hpp:38