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  ::DrawRectangleGradientH(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color1, color2);
61  return *this;
62  }
63  inline Rectangle& DrawGradientH(::Color color1, ::Color color2) {
64  ::DrawRectangleGradientH(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color1, color2);
65  return *this;
66  }
67  inline Rectangle& DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4) {
68  ::DrawRectangleGradientEx(*this, col1, col2, col3, col4);
69  return *this;
70  }
71  inline Rectangle& DrawLines(::Color color){
72  ::DrawRectangleLines(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color);
73  return *this;
74  }
75  inline Rectangle& DrawLinesEx(int lineThick, ::Color color){
76  ::DrawRectangleLinesEx(*this, lineThick, color);
77  return *this;
78  }
79  inline Rectangle& DrawRounded(float roundness, int segments, ::Color color){
80  ::DrawRectangleRounded(*this, roundness, segments, color);
81  return *this;
82  }
83  inline Rectangle& DrawRoundedLines(float roundness, int segments, int lineThick, ::Color color) {
84  ::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color);
85  return *this;
86  }
87 
88  inline bool CheckCollision(::Rectangle rec2) {
89  return ::CheckCollisionRecs(*this, rec2);
90  }
91  inline Rectangle GetCollision(::Rectangle rec2) {
92  return ::GetCollisionRec(*this, rec2);
93  }
94  inline bool CheckCollision(::Vector2 point) {
95  return ::CheckCollisionPointRec(point, *this);
96  }
97  };
98 }
99 
100 #endif
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
raylib::Rectangle::CheckCollision
bool CheckCollision(::Rectangle rec2)
Definition: Rectangle.hpp:88
raylib::Rectangle::CheckCollision
bool CheckCollision(::Vector2 point)
Definition: Rectangle.hpp:94
raylib::Rectangle::DrawRounded
Rectangle & DrawRounded(float roundness, int segments, ::Color color)
Definition: Rectangle.hpp:79
raylib::Rectangle::set
void set(::Rectangle rect)
Definition: Rectangle.hpp:28
raylib::Rectangle::DrawGradientH
Rectangle & DrawGradientH(::Color color1, ::Color color2)
Definition: Rectangle.hpp:63
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:75
raylib::Rectangle::DrawGradientV
Rectangle & DrawGradientV(::Color color1, ::Color color2)
Definition: Rectangle.hpp:59
raylib::Rectangle::DrawLines
Rectangle & DrawLines(::Color color)
Definition: Rectangle.hpp:71
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:67
raylib::Rectangle::Draw
Rectangle & Draw(::Color color)
Definition: Rectangle.hpp:50
raylib::Rectangle::GetCollision
Rectangle GetCollision(::Rectangle rec2)
Definition: Rectangle.hpp:91
raylib::Rectangle::DrawRoundedLines
Rectangle & DrawRoundedLines(float roundness, int segments, int lineThick, ::Color color)
Definition: Rectangle.hpp:83
raylib::Rectangle::operator=
Rectangle & operator=(const Rectangle &rect)
Definition: Rectangle.hpp:45