diff --git a/core/math/rect2.cpp b/core/math/rect2.cpp index 39cbfd2..268454c 100644 --- a/core/math/rect2.cpp +++ b/core/math/rect2.cpp @@ -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; diff --git a/core/math/rect2.h b/core/math/rect2.h index a19a889..31f0893 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -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); diff --git a/core/math/rect2i.cpp b/core/math/rect2i.cpp index c36f3d4..301a075 100644 --- a/core/math/rect2i.cpp +++ b/core/math/rect2i.cpp @@ -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; diff --git a/core/math/rect2i.h b/core/math/rect2i.h index 8a4172a..03fb0f6 100644 --- a/core/math/rect2i.h +++ b/core/math/rect2i.h @@ -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);