rag
graphic 2d engine
Rectangle.h
1 #ifndef Rag_Rectangle_h
2 #define Rag_Rectangle_h
3 
4 #include <string>
5 #include <glm/glm.hpp>
6 
7 namespace rag
8 {
10  class Rectangle
11  {
12 
13  public:
14 
16  Rectangle(float x = 0, float y = 0, float width = 0, float height = 0);
17 
19  Rectangle rectUnion(const Rectangle& toUnion) const;
20 
22  Rectangle intersection(const Rectangle& toIntersect) const;
23 
25  bool intersects(const Rectangle& toIntersect) const;
26 
28  bool contains(float x, float y) const;
29 
31  bool contains(const glm::vec2& point) const;
32 
34  bool contains(const Rectangle& rect) const;
35 
36  bool operator==(const Rectangle &other) const;
37  bool operator!=(const Rectangle &other) const;
38 
40  std::string toString();
41 
42  float x, y, width, height;
43 
44  };
45 }
46 
47 #endif
Rectangle(float x=0, float y=0, float width=0, float height=0)
Constructor with coordinates and size.
Definition: Rectangle.cpp:8
Rectangle rectUnion(const Rectangle &toUnion) const
Returns the union of the current instance with another Rectangle.
Definition: Rectangle.cpp:16
Definition: Bitmap.h:8
Represents a Rectangle.
Definition: Rectangle.h:10
Rectangle intersection(const Rectangle &toIntersect) const
Returns the intersection of the current instance with another Rectangle.
Definition: Rectangle.cpp:31
bool contains(float x, float y) const
Checks if a point lies inside the Rectangle.
Definition: Rectangle.cpp:52
bool intersects(const Rectangle &toIntersect) const
Returns true if the instance intersects with the other Rectangle.
Definition: Rectangle.cpp:44
std::string toString()
String representation of the Rectangle.
Definition: Rectangle.cpp:70