mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Added abs helper method to Rect2 and Rect2i.
This commit is contained in:
parent
e34079ee46
commit
2c16563d97
@ -22,6 +22,8 @@ public:
|
|||||||
void expand_to(const Vector2 &p_vector);
|
void expand_to(const Vector2 &p_vector);
|
||||||
inline Rect2 clip(const Rect2 &p_rect) const;
|
inline Rect2 clip(const Rect2 &p_rect) const;
|
||||||
|
|
||||||
|
inline Rect2 abs() const;
|
||||||
|
|
||||||
Vector2 position() const;
|
Vector2 position() const;
|
||||||
Vector2 size() const;
|
Vector2 size() const;
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ public:
|
|||||||
// Taken from the Godot Engine (MIT License)
|
// Taken from the Godot Engine (MIT License)
|
||||||
// Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur.
|
// Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur.
|
||||||
// Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md).
|
// Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md).
|
||||||
inline Rect2 Rect2::clip(const Rect2 &p_rect) const { /// return a clipped rect
|
Rect2 Rect2::clip(const Rect2 &p_rect) const { /// return a clipped rect
|
||||||
Rect2 new_rect = p_rect;
|
Rect2 new_rect = p_rect;
|
||||||
|
|
||||||
if (!intersects(new_rect)) {
|
if (!intersects(new_rect)) {
|
||||||
@ -70,4 +72,8 @@ inline Rect2 Rect2::clip(const Rect2 &p_rect) const { /// return a clipped rect
|
|||||||
return new_rect;
|
return new_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect2 Rect2::abs() const {
|
||||||
|
return Rect2(x + MIN(w, 0), y + MIN(h, 0), ABS(w), ABS(h));
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -23,6 +23,8 @@ public:
|
|||||||
void expand_to(const Vector2i &p_vector);
|
void expand_to(const Vector2i &p_vector);
|
||||||
inline Rect2i clip(const Rect2i &p_rect) const;
|
inline Rect2i clip(const Rect2i &p_rect) const;
|
||||||
|
|
||||||
|
inline Rect2i abs() const;
|
||||||
|
|
||||||
Vector2i position() const;
|
Vector2i position() const;
|
||||||
Vector2i size() const;
|
Vector2i size() const;
|
||||||
|
|
||||||
@ -74,4 +76,8 @@ inline Rect2i Rect2i::clip(const Rect2i &p_rect) const { /// return a clipped re
|
|||||||
return new_rect;
|
return new_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect2i Rect2i::abs() const {
|
||||||
|
return Rect2i(x + MIN(w, 0), y + MIN(h, 0), ABS(w), ABS(h));
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user