1 | |
2 | #pragma once |
3 | |
4 | #include "Vector2.h" |
5 | |
6 | namespace msdfgen { |
7 | |
8 | /// A transformation from shape coordinates to pixel coordinates. |
9 | class Projection { |
10 | |
11 | public: |
12 | Projection(); |
13 | Projection(const Vector2 &scale, const Vector2 &translate); |
14 | /// Converts the shape coordinate to pixel coordinate. |
15 | Point2 project(const Point2 &coord) const; |
16 | /// Converts the pixel coordinate to shape coordinate. |
17 | Point2 unproject(const Point2 &coord) const; |
18 | /// Converts the vector to pixel coordinate space. |
19 | Vector2 projectVector(const Vector2 &vector) const; |
20 | /// Converts the vector from pixel coordinate space. |
21 | Vector2 unprojectVector(const Vector2 &vector) const; |
22 | /// Converts the X-coordinate from shape to pixel coordinate space. |
23 | double projectX(double x) const; |
24 | /// Converts the Y-coordinate from shape to pixel coordinate space. |
25 | double projectY(double y) const; |
26 | /// Converts the X-coordinate from pixel to shape coordinate space. |
27 | double unprojectX(double x) const; |
28 | /// Converts the Y-coordinate from pixel to shape coordinate space. |
29 | double unprojectY(double y) const; |
30 | |
31 | private: |
32 | Vector2 scale; |
33 | Vector2 translate; |
34 | |
35 | }; |
36 | |
37 | } |
38 | |