mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Added position and size helper methods to Rect2 and Rect2i.
This commit is contained in:
parent
53b9236c5f
commit
e28007085c
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -83,9 +83,9 @@ void Rect2i::shrink(const int by) {
|
||||
w -= by;
|
||||
}
|
||||
|
||||
//Taken from the Godot Engine (MIT License)
|
||||
//Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur.
|
||||
//Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md).
|
||||
// Taken from the Godot Engine (MIT License)
|
||||
// Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur.
|
||||
// Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md).
|
||||
void Rect2i::expand_to(const Vector2i &p_vector) {
|
||||
Vector2i begin = Vector2i(x, y);
|
||||
Vector2i end = Vector2i(x, y) + Vector2i(w, h);
|
||||
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user