From 6b78788d049c90dab3aec01d7bb7193f3927dc75 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Sun, 21 Sep 2025 23:40:30 +0800 Subject: HALF WORK! --- include/cru/platform/GraphicsBase.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/cru/platform/GraphicsBase.h') diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h index b0f653ef..d9057beb 100644 --- a/include/cru/platform/GraphicsBase.h +++ b/include/cru/platform/GraphicsBase.h @@ -5,6 +5,7 @@ #include "cru/base/Range.h" #include "cru/base/String.h" +#include #include #include @@ -24,6 +25,11 @@ struct Point final { constexpr Point Negate() const { return Point(-x, -y); } + static constexpr float Distance(const Point& p1, const Point& p2) { + auto dx = p1.x - p2.x, dy = p1.y - p2.y; + return std::sqrt(dx * dx + dy * dy); + } + float x = 0; float y = 0; }; @@ -36,6 +42,10 @@ constexpr Point operator-(const Point& left, const Point& right) { return Point(left.x - right.x, left.y - right.y); } +constexpr Point operator/(const Point& point, float scale) { + return Point(point.x / scale, point.y / scale); +} + constexpr bool operator==(const Point& left, const Point& right) { return left.x == right.x && left.y == right.y; } -- cgit v1.2.3