region: add inset method

This commit is contained in:
Danny Robson 2015-01-21 23:37:00 +11:00
parent de538d528b
commit 91ecc49d68
2 changed files with 14 additions and 0 deletions

View File

@ -210,6 +210,17 @@ util::region<T>::intersection (const util::region<T> &rhs) const
}
//-----------------------------------------------------------------------------
template <typename T>
util::region<T>
util::region<T>::inset (T mag)
{
CHECK_GE (w - x, 2 * mag);
CHECK_GE (h - y, 2 * mag);
return { x + mag, y + mag, w - 2 * mag, h - 2 * mag };
}
//-----------------------------------------------------------------------------
template <typename T>
bool

View File

@ -62,6 +62,9 @@ namespace util {
// Compute binary region combinations
region intersection (const region<T>&) const;
// Compute a region `mag` units into the region
region inset (T mag);
// Logical comparison operators
bool operator ==(const region<T>& rhs) const;
bool operator !=(const region<T>& rhs) const