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
|
|
|
|
{
|
2022-10-17 22:59:51 -04:00
|
|
|
return kku::Point{
|
|
|
|
static_cast<float>(left),
|
|
|
|
static_cast<float>(top),
|
|
|
|
};
|
2021-12-29 09:59:18 -05:00
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
inline void moveBy(const kku::Vector2<T> &vector)
|
2021-12-29 09:59:18 -05:00
|
|
|
{
|
|
|
|
top += vector.second;
|
|
|
|
left += vector.first;
|
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
inline bool contains(const kku::Point &point) const
|
2021-12-29 09:59:18 -05:00
|
|
|
{
|
2022-10-17 22:59:51 -04:00
|
|
|
return point.x >= left; // debug it when on computer
|
2021-12-29 09:59:18 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
} // namespace kku
|