2
0

Contour.h 987 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <vector>
  3. #include "types.h"
  4. #include "EdgeHolder.h"
  5. namespace msdfgen {
  6. /// A single closed contour of a shape.
  7. class Contour {
  8. public:
  9. /// The sequence of edges that make up the contour.
  10. std::vector<EdgeHolder> edges;
  11. /// Adds an edge to the contour.
  12. void addEdge(const EdgeHolder &edge);
  13. #ifdef MSDFGEN_USE_CPP11
  14. void addEdge(EdgeHolder &&edge);
  15. #endif
  16. /// Creates a new edge in the contour and returns its reference.
  17. EdgeHolder &addEdge();
  18. /// Adjusts the bounding box to fit the contour.
  19. void bound(real &l, real &b, real &r, real &t) const;
  20. /// Adjusts the bounding box to fit the contour border's mitered corners.
  21. void boundMiters(real &l, real &b, real &r, real &t, real border, real miterLimit, int polarity) const;
  22. /// Computes the winding of the contour. Returns 1 if positive, -1 if negative.
  23. int winding() const;
  24. /// Reverses the sequence of edges on the contour.
  25. void reverse();
  26. };
  27. }