project-kyoku/include/core/area.h

38 lines
691 B
C++

#pragma once
#include <type_traits>
#include "core/point.h"
#include "core/vector.h"
namespace kku
{
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
}
};
}