Added position and size helper methods to Rect2 and Rect2i.

This commit is contained in:
Relintai 2022-02-04 12:54:28 +01:00
parent 53b9236c5f
commit e28007085c
4 changed files with 23 additions and 3 deletions

View File

@ -110,6 +110,13 @@ void Rect2::expand_to(const Vector2 &p_vector) {
h = end.y - begin.y;
}
Vector2 Rect2::position() const {
return Vector2(x, y);
}
Vector2 Rect2::size() const {
return Vector2(w, h);
}
Rect2 &Rect2::operator+=(const Rect2 &b) {
x += b.x;
y += b.y;

View File

@ -18,6 +18,9 @@ public:
void expand_to(const Vector2 &p_vector);
Vector2 position() const;
Vector2 size() const;
Rect2 &operator+=(const Rect2 &b);
Rect2 &operator-=(const Rect2 &b);

View File

@ -110,6 +110,13 @@ void Rect2i::expand_to(const Vector2i &p_vector) {
h = end.y - begin.y;
}
Vector2i Rect2i::position() const {
return Vector2i(x, y);
}
Vector2i Rect2i::size() const {
return Vector2i(w, h);
}
Rect2i &Rect2i::operator+=(const Rect2i &b) {
x += b.x;
y += b.y;

View File

@ -18,6 +18,9 @@ public:
void expand_to(const Vector2i &p_vector);
Vector2i position() const;
Vector2i size() const;
Rect2i &operator+=(const Rect2i &b);
Rect2i &operator-=(const Rect2i &b);