summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-06-08 07:41:54 +0200
committerGitHub <noreply@github.com>2017-06-08 07:41:54 +0200
commitbee81d52148baf01cd15f9d79dba35bcffdc2fe6 (patch)
tree4fdb17a9e0daa576429452b15a74579c7fb9c53b /core/math
parent71c7dcab65e927c1ebc3c527b4a972612639d034 (diff)
parent66b308925c3174901fc59a23245c8a1d19143420 (diff)
Merge pull request #8981 from toger5/addedGrowFunction
implemented grow(left,top,right,bottom) function
Diffstat (limited to 'core/math')
-rw-r--r--core/math/math_2d.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index dc4850eeed..3369e2ec4f 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -329,6 +329,25 @@ struct Rect2 {
g.size.height += p_by * 2;
return g;
}
+ inline Rect2 grow_margin(Margin p_margin, real_t p_amount) const {
+ Rect2 g = *this;
+ g.grow_individual((MARGIN_LEFT == p_margin) ? p_amount : 0,
+ (MARGIN_TOP == p_margin) ? p_amount : 0,
+ (MARGIN_RIGHT == p_margin) ? p_amount : 0,
+ (MARGIN_BOTTOM == p_margin) ? p_amount : 0);
+ return g;
+ }
+
+ inline Rect2 grow_individual(real_t p_left, real_t p_top, real_t p_right, real_t p_bottom) const {
+
+ Rect2 g = *this;
+ g.pos.x -= p_left;
+ g.pos.y -= p_top;
+ g.size.width += p_left + p_right;
+ g.size.height += p_top + p_bottom;
+
+ return g;
+ }
inline Rect2 expand(const Vector2 &p_vector) const {