/*
* This file is part of libgim.
*
* libgim is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* libgim is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see .
*
* Copyright 2010 Danny Robson
*/
#include "region.hpp"
#include "enable_if.hpp"
#include "debug.hpp"
#include
using namespace util;
/*
* Rect
*/
template
extent::extent (const T _width, const T _height):
width (_width),
height (_height)
{ ; }
template
T
extent::area (void) const
{ return width * height; }
template
bool
extent::empty (void) const
{ return almost_equal (area(), 0); }
template
bool
extent::operator ==(const extent& rhs) const {
return almost_equal (width, rhs.width) &&
almost_equal (height, rhs.height);
}
template
void
extent::sanity (void) const
{ check (width >= 0 && height >= 0); }
namespace util {
template <>
void
extent::sanity (void) const
{ return; }
}
template struct extent;
template struct extent;
/*
* Region
*/
template
_region::_region (T _x, T _y, T _width, T _height):
x (_x),
y (_y),
width (_width),
height (_height)
{ ; }
template
T
_region::area (void) const
{ return width * height; }
template
bool
_region::empty (void) const
{ return area () == 0; }
template
bool
_region::operator ==(const _region& rhs) const
{ return x == rhs.x &&
y == rhs.y &&
width == rhs.width &&
height == rhs.height; }
template
void _region::sanity (void) const
{ check (width >= 0 && height >= 0); }