project-kyoku/include/core/area.h

47 lines
875 B
C
Raw Normal View History

2021-12-29 09:59:18 -05:00
#pragma once
#include <type_traits>
#include "core/point.h"
#include "core/vector.h"
namespace kku
{
2022-05-07 23:43:12 -04:00
/// Area
///
/// Consists of 2 arithmetic
/// points that represent
/// a rectangle position
/// and 2 arithmetic
/// lengths by x and y
/// that represent
/// rectangle coverage area
2021-12-29 09:59:18 -05:00
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
}
};
}