region: add magnitude setter

This commit is contained in:
Danny Robson 2015-03-02 18:48:09 +11:00
parent eda97b844b
commit 3e2c70f251
2 changed files with 18 additions and 2 deletions

View File

@ -85,13 +85,25 @@ util::region<T>::diameter (void) const
//-----------------------------------------------------------------------------
template <typename T>
util::extent<typename util::region<T>::size_type>
typename util::region<T>::extent_t
util::region<T>::magnitude (void) const
{
return { w, h };
}
//-----------------------------------------------------------------------------
template <typename T>
typename util::region<T>::extent_t
util::region<T>::magnitude (extent_t e)
{
w = e.w;
h = e.h;
return magnitude ();
}
//-----------------------------------------------------------------------------
template <typename T>
void

View File

@ -39,6 +39,9 @@ namespace util {
static constexpr size_t elements = dimension * 2;
using value_type = T;
using extent_t = util::extent<size_type>;
using point_t = util::point<2,T>;
position_type x, y;
size_type w, h;
@ -50,7 +53,8 @@ namespace util {
size_type area (void) const;
size_type diameter (void) const;
util::extent<size_type> magnitude (void) const;
extent_t magnitude (void) const;
extent_t magnitude (extent_t);
void scale (T factor);