46 lines
810 B
C++
46 lines
810 B
C++
#pragma once
|
|
|
|
namespace kku
|
|
{
|
|
|
|
struct Point
|
|
{
|
|
float x;
|
|
float y;
|
|
|
|
constexpr inline explicit Point() noexcept :
|
|
x(0.), y(0.)
|
|
{}
|
|
|
|
constexpr inline explicit Point(int x, int y) noexcept :
|
|
x(x), y(y)
|
|
{}
|
|
|
|
constexpr inline explicit Point(float x, float y) noexcept :
|
|
x(x), y(y)
|
|
{}
|
|
|
|
constexpr inline Point operator+(const Point& right) const noexcept
|
|
{
|
|
return Point{right.x + x, right.y + y};
|
|
}
|
|
|
|
constexpr inline Point operator-(const Point& right) const noexcept
|
|
{
|
|
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;
|
|
}
|
|
};
|
|
|
|
} |