region: add point/extent constructor

This commit is contained in:
Danny Robson 2015-01-15 14:01:05 +11:00
parent d905d817c6
commit 0112d663ff
2 changed files with 15 additions and 2 deletions

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with libgim. If not, see <http://www.gnu.org/licenses/>. * along with libgim. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2010 Danny Robson <danny@nerdcruft.net> * Copyright 2010-2015 Danny Robson <danny@nerdcruft.net>
*/ */
@ -31,6 +31,17 @@
using namespace util; using namespace util;
//-----------------------------------------------------------------------------
template <typename T>
region<T>::region (util::point<2,T> _point,
util::extent<size_type> _size):
x (_point.x),
y (_point.y),
w (_size.w),
h (_size.h)
{ ; }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <typename T> template <typename T>
region<T>::region (T _x, T _y, size_type _w, size_type _h): region<T>::region (T _x, T _y, size_type _w, size_type _h):

View File

@ -14,13 +14,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with libgim. If not, see <http://www.gnu.org/licenses/>. * along with libgim. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2010 Danny Robson <danny@nerdcruft.net> * Copyright 2010-2015 Danny Robson <danny@nerdcruft.net>
*/ */
#ifndef __UTIL_REGION_HPP #ifndef __UTIL_REGION_HPP
#define __UTIL_REGION_HPP #define __UTIL_REGION_HPP
#include "extent.hpp"
#include "point.hpp" #include "point.hpp"
#include "types/traits.hpp" #include "types/traits.hpp"
@ -40,6 +41,7 @@ namespace util {
T x, y; T x, y;
size_type w, h; size_type w, h;
region (util::point<2,T>, util::extent<size_type>);
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;