2021-12-29 15:59:18 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace kku
|
|
|
|
{
|
|
|
|
|
|
|
|
struct Point
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
|
2022-10-18 04:59:51 +02:00
|
|
|
constexpr inline explicit Point() noexcept : x(0.), y(0.) {}
|
2021-12-29 15:59:18 +01:00
|
|
|
|
2022-10-18 04:59:51 +02:00
|
|
|
constexpr inline explicit Point(int x, int y) noexcept : x(x), y(y) {}
|
2021-12-29 15:59:18 +01:00
|
|
|
|
2022-10-18 04:59:51 +02:00
|
|
|
constexpr inline explicit Point(float x, float y) noexcept : x(x), y(y) {}
|
2021-12-29 15:59:18 +01:00
|
|
|
|
2022-10-18 04:59:51 +02:00
|
|
|
constexpr inline Point operator+(const Point &right) const noexcept
|
2021-12-29 15:59:18 +01:00
|
|
|
{
|
|
|
|
return Point{right.x + x, right.y + y};
|
|
|
|
}
|
|
|
|
|
2022-10-18 04:59:51 +02:00
|
|
|
constexpr inline Point operator-(const Point &right) const noexcept
|
2021-12-29 15:59:18 +01:00
|
|
|
{
|
|
|
|
return Point{right.x - x, right.y - y};
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void moveBy(float x, float y) noexcept
|
|
|
|
{
|
|
|
|
this->x += x;
|
|
|
|
this->y += y;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void scaleBy(float factor) noexcept
|
|
|
|
{
|
|
|
|
x *= factor;
|
|
|
|
y *= factor;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-10-18 04:59:51 +02:00
|
|
|
} // namespace kku
|