Shape.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include <vector>
  3. #include "Contour.h"
  4. #include "Scanline.h"
  5. namespace msdfgen {
  6. /// Vector shape representation.
  7. class Shape {
  8. public:
  9. /// The list of contours the shape consists of.
  10. std::vector<Contour> contours;
  11. /// Specifies whether the shape uses bottom-to-top (false) or top-to-bottom (true) Y coordinates.
  12. bool inverseYAxis;
  13. Shape();
  14. /// Adds a contour.
  15. void addContour(const Contour &contour);
  16. #ifdef MSDFGEN_USE_CPP11
  17. void addContour(Contour &&contour);
  18. #endif
  19. /// Adds a blank contour and returns its reference.
  20. Contour & addContour();
  21. /// Normalizes the shape geometry for distance field generation.
  22. void normalize();
  23. /// Performs basic checks to determine if the object represents a valid shape.
  24. bool validate() const;
  25. /// Adjusts the bounding box to fit the shape.
  26. void bounds(double &l, double &b, double &r, double &t) const;
  27. /// Outputs the scanline that intersects the shape at y.
  28. void scanline(Scanline &line, double y) const;
  29. };
  30. }