forked from NaiJi/project-kyoku
47 lines
875 B
C++
47 lines
875 B
C++
#pragma once
|
|
|
|
#include <type_traits>
|
|
|
|
#include "core/point.h"
|
|
#include "core/vector.h"
|
|
|
|
namespace kku
|
|
{
|
|
|
|
/// Area
|
|
///
|
|
/// Consists of 2 arithmetic
|
|
/// points that represent
|
|
/// a rectangle position
|
|
/// and 2 arithmetic
|
|
/// lengths by x and y
|
|
/// that represent
|
|
/// rectangle coverage area
|
|
template <typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
|
|
struct Area
|
|
{
|
|
T left = 0;
|
|
T top = 0;
|
|
T width = 0;
|
|
T height = 0;
|
|
|
|
inline kku::Point position() const noexcept
|
|
{
|
|
return kku::Point{static_cast<float>(left),
|
|
static_cast<float>(top) };
|
|
}
|
|
|
|
inline void moveBy(const kku::Vector2<T>& vector)
|
|
{
|
|
top += vector.second;
|
|
left += vector.first;
|
|
}
|
|
|
|
inline bool contains(const kku::Point& point) const
|
|
{
|
|
return point.x >= left ; // debug it when on computer
|
|
}
|
|
};
|
|
|
|
}
|