region: add extent-only constructor
This commit is contained in:
parent
c29be43fd1
commit
84c957440b
19
region.cpp
19
region.cpp
@ -27,6 +27,13 @@
|
||||
#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>
|
||||
util::region<T>::region (point<2,T> _point,
|
||||
@ -42,10 +49,7 @@ util::region<T>::region (point<2,T> _point,
|
||||
template <typename T>
|
||||
util::region<T>::region (point<2,T> _a,
|
||||
point<2,T> _b):
|
||||
x (_a.x),
|
||||
y (_a.y),
|
||||
w (_b.x - _a.x),
|
||||
h (_b.y - _a.y)
|
||||
region (_a, _b - _a)
|
||||
{
|
||||
CHECK_GE (_b.x, _a.x);
|
||||
CHECK_GE (_b.y, _a.y);
|
||||
@ -57,10 +61,7 @@ util::region<T>::region (position_type _x,
|
||||
position_type _y,
|
||||
size_type _w,
|
||||
size_type _h):
|
||||
x (_x),
|
||||
y (_y),
|
||||
w (_w),
|
||||
h (_h)
|
||||
region (point<2,T> {_x, _y}, extent<T> {_w, _h})
|
||||
{ ; }
|
||||
|
||||
|
||||
@ -85,7 +86,7 @@ util::region<T>::diameter (void) const
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
util::extent<typename util::region<T>::size_type>
|
||||
util::region<T>::size (void) const
|
||||
util::region<T>::magnitude (void) const
|
||||
{
|
||||
return { w, h };
|
||||
}
|
||||
|
@ -43,13 +43,14 @@ namespace util {
|
||||
size_type w, h;
|
||||
|
||||
region () = default;
|
||||
region (util::extent<size_type>);
|
||||
region (util::point<2,T>, util::extent<size_type>);
|
||||
region (util::point<2,T>, util::point<2,T>);
|
||||
region (T _x, T _y, size_type _w, size_type _h);
|
||||
|
||||
size_type area (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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user