region: add extent-only constructor

This commit is contained in:
Danny Robson 2015-02-20 21:53:34 +11:00
parent c29be43fd1
commit 84c957440b
2 changed files with 12 additions and 10 deletions

View File

@ -27,6 +27,13 @@
#include <type_traits> #include <type_traits>
//-----------------------------------------------------------------------------
template <typename T>
util::region<T>::region (util::extent<size_type> _extent):
region (util::point<2,T>::ORIGIN, _extent)
{ ; }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <typename T> template <typename T>
util::region<T>::region (point<2,T> _point, util::region<T>::region (point<2,T> _point,
@ -42,10 +49,7 @@ util::region<T>::region (point<2,T> _point,
template <typename T> template <typename T>
util::region<T>::region (point<2,T> _a, util::region<T>::region (point<2,T> _a,
point<2,T> _b): point<2,T> _b):
x (_a.x), region (_a, _b - _a)
y (_a.y),
w (_b.x - _a.x),
h (_b.y - _a.y)
{ {
CHECK_GE (_b.x, _a.x); CHECK_GE (_b.x, _a.x);
CHECK_GE (_b.y, _a.y); CHECK_GE (_b.y, _a.y);
@ -57,10 +61,7 @@ util::region<T>::region (position_type _x,
position_type _y, position_type _y,
size_type _w, size_type _w,
size_type _h): size_type _h):
x (_x), region (point<2,T> {_x, _y}, extent<T> {_w, _h})
y (_y),
w (_w),
h (_h)
{ ; } { ; }
@ -85,7 +86,7 @@ util::region<T>::diameter (void) const
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <typename T> template <typename T>
util::extent<typename util::region<T>::size_type> util::extent<typename util::region<T>::size_type>
util::region<T>::size (void) const util::region<T>::magnitude (void) const
{ {
return { w, h }; return { w, h };
} }

View File

@ -43,13 +43,14 @@ namespace util {
size_type w, h; size_type w, h;
region () = default; region () = default;
region (util::extent<size_type>);
region (util::point<2,T>, util::extent<size_type>); region (util::point<2,T>, util::extent<size_type>);
region (util::point<2,T>, util::point<2,T>); region (util::point<2,T>, util::point<2,T>);
region (T _x, T _y, size_type _w, size_type _h); region (T _x, T _y, size_type _w, size_type _h);
size_type area (void) const; size_type area (void) const;
size_type diameter (void) const; size_type diameter (void) const;
util::extent<size_type> size (void) const; util::extent<size_type> magnitude (void) const;
void scale (T factor); void scale (T factor);