2
0

Projection.h 1.2 KB

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