Projection.h 1.1 KB

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