diff --git a/region.cpp b/region.cpp index 250ef4f1..000321b0 100644 --- a/region.cpp +++ b/region.cpp @@ -221,6 +221,34 @@ util::region::inset (T mag) return { x + mag, y + mag, w - 2 * mag, h - 2 * mag }; } + +//----------------------------------------------------------------------------- +template +util::region& +util::region::expand (T mag) +{ + x -= mag; + y -= mag; + w += mag * 2; + h += mag * 2; + + return *this; +} + + +//----------------------------------------------------------------------------- +template +util::region +util::region::expanded (T mag) const +{ + return { + x - mag, + y - mag, + w + mag * 2, + h + mag * 2, + }; +} + //----------------------------------------------------------------------------- template bool diff --git a/region.hpp b/region.hpp index 733fdfb9..890b76ad 100644 --- a/region.hpp +++ b/region.hpp @@ -64,6 +64,8 @@ namespace util { // Compute a region `mag` units into the region region inset (T mag); + region expanded (T mag) const; + region& expand (T mag); // Logical comparison operators bool operator ==(const region& rhs) const;