region: add expansion methods
This commit is contained in:
parent
7934ae865b
commit
76b51e04b2
28
region.cpp
28
region.cpp
@ -221,6 +221,34 @@ util::region<T>::inset (T mag)
|
||||
return { x + mag, y + mag, w - 2 * mag, h - 2 * mag };
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
util::region<T>&
|
||||
util::region<T>::expand (T mag)
|
||||
{
|
||||
x -= mag;
|
||||
y -= mag;
|
||||
w += mag * 2;
|
||||
h += mag * 2;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
util::region<T>
|
||||
util::region<T>::expanded (T mag) const
|
||||
{
|
||||
return {
|
||||
x - mag,
|
||||
y - mag,
|
||||
w + mag * 2,
|
||||
h + mag * 2,
|
||||
};
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
bool
|
||||
|
@ -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<T>& rhs) const;
|
||||
|
Loading…
Reference in New Issue
Block a user