From fb1d3eda51cd9d89083130cf9932c7bde758756c Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 4 Feb 2023 01:04:03 +0100 Subject: Full grid is now drawn --- engine/include/kurator/engine/Camera.h | 3 +++ engine/src/Camera.cpp | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'engine') diff --git a/engine/include/kurator/engine/Camera.h b/engine/include/kurator/engine/Camera.h index 2eb192a..d5253df 100644 --- a/engine/include/kurator/engine/Camera.h +++ b/engine/include/kurator/engine/Camera.h @@ -15,6 +15,9 @@ struct Camera double scale = 1.0; Point to_world(const Point& screen) const; Point to_screen(const Point& world) const; + Point top_left() const; + Point center() const; + Point bottom_right() const; }; diff --git a/engine/src/Camera.cpp b/engine/src/Camera.cpp index 41cc5ab..4a95ad8 100644 --- a/engine/src/Camera.cpp +++ b/engine/src/Camera.cpp @@ -29,6 +29,27 @@ Camera::to_screen(const Point& world) const Point +Camera::top_left() const +{ + return to_world({0.0, 0.0}); +} + + +Point +Camera::center() const +{ + return to_world(viewport().scale(0.5)); +} + + +Point +Camera::bottom_right() const +{ + return to_world(viewport()); +} + + +Point viewport() { return {static_cast(GetScreenWidth()), static_cast(GetScreenHeight())}; -- cgit v1.1