summaryrefslogtreecommitdiff
path: root/engine/src/Camera.cpp
blob: 60e8aa1f3a0438cf925582481612c9c3817b75cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <kurator/engine/Camera.h>

#include <raylib.h>

#include <kurator/engine/Point.h>


namespace kurator
{
namespace engine
{


static auto viewport() -> Point;


Point
Camera::to_world(const Point& screen) const
{
	return screen - viewport().scale(1.0 / (2.0 * scale)) + offset;
}


Point
Camera::to_screen(const Point& world) const
{
	return (world - offset).scale(scale) + viewport().scale(0.5);
}


Point
viewport()
{
	return {static_cast<double>(GetScreenWidth()), static_cast<double>(GetScreenHeight())};
}


}  // namespace engine
}  // namespace kurator