2021-11-13 11:51:43 +01:00
|
|
|
#ifndef RECT2_H
|
|
|
|
#define RECT2_H
|
|
|
|
|
2021-11-16 03:06:58 +01:00
|
|
|
#include "vector2.h"
|
|
|
|
|
2021-11-13 11:51:43 +01:00
|
|
|
class Rect2 {
|
|
|
|
public:
|
|
|
|
float get_area() const;
|
|
|
|
bool intersects(const Rect2 &b) const;
|
|
|
|
bool intersects_include_borders(const Rect2 &b) const;
|
|
|
|
bool encloses(const Rect2 &b) const;
|
|
|
|
bool has_no_area() const;
|
|
|
|
bool has_point(const float px, const float py) const;
|
|
|
|
bool is_equal_approx(const Rect2 &b) const;
|
|
|
|
|
|
|
|
void grow(const float by);
|
|
|
|
void shrink(const float by);
|
|
|
|
|
2021-11-16 03:06:58 +01:00
|
|
|
void expand_to(const Vector2 &p_vector);
|
|
|
|
|
2022-02-04 12:54:28 +01:00
|
|
|
Vector2 position() const;
|
|
|
|
Vector2 size() const;
|
|
|
|
|
2021-11-13 11:51:43 +01:00
|
|
|
Rect2 &operator+=(const Rect2 &b);
|
|
|
|
Rect2 &operator-=(const Rect2 &b);
|
|
|
|
|
|
|
|
friend Rect2 operator+(Rect2 lhs, const Rect2 &rhs);
|
|
|
|
friend Rect2 operator-(Rect2 lhs, const Rect2 &rhs);
|
|
|
|
|
|
|
|
friend bool operator==(const Rect2 &a, const Rect2 &b);
|
|
|
|
friend bool operator!=(const Rect2 &a, const Rect2 &b);
|
|
|
|
|
|
|
|
Rect2();
|
|
|
|
Rect2(const Rect2 &b);
|
|
|
|
Rect2(const float rx, const float ry);
|
|
|
|
Rect2(const float rx, const float ry, const float rw, const float rh);
|
2022-02-04 11:30:01 +01:00
|
|
|
Rect2(const Vector2 &position, const Vector2 &size);
|
2021-11-13 11:51:43 +01:00
|
|
|
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float w;
|
|
|
|
float h;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|