Browse Source

Add Rect::shrink().

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
f6819bfe24
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      include/math.hpp

+ 8
- 3
include/math.hpp View File

@@ -413,15 +413,20 @@ struct Rect {
Rect zeroPos() const {
return Rect(Vec(), size);
}
/** Expands each corner.
Use a negative delta to shrink.
*/
/** Expands each corner. */
Rect grow(Vec delta) const {
Rect r;
r.pos = pos.minus(delta);
r.size = size.plus(delta.mult(2.f));
return r;
}
/** Contracts each corner. */
Rect shrink(Vec delta) const {
Rect r;
r.pos = pos.plus(delta);
r.size = size.minus(delta.mult(2.f));
return r;
}

// Method aliases
bool isContaining(Vec v) const {


Loading…
Cancel
Save