CmRect.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include "CmPrerequisitesUtil.h"
  3. namespace CamelotFramework
  4. {
  5. class CM_UTILITY_EXPORT Rect
  6. {
  7. public:
  8. Rect();
  9. Rect(int _x, int _y, int _width, int _height);
  10. int x, y, width, height;
  11. bool contains(const Int2& point) const;
  12. bool overlaps(const Rect& other) const;
  13. void encapsulate(const Rect& other);
  14. void clip(const Rect& clipRect);
  15. /**
  16. * @brief Transforms the bounds by the given matrix.
  17. * Resulting value is an axis aligned rectangle encompassing the transformed points.
  18. *
  19. * @note Since the resulting value is an AA rectangle of the original transformed rectangle, the bounds
  20. * will be larger than needed. Oriented rectangle would provide a much tighter fit.
  21. */
  22. void transform(const Matrix4& matrix);
  23. inline bool operator== (const Rect& rhs) const
  24. {
  25. return x == rhs.x && y == rhs.y && width == rhs.width && height == rhs.height;
  26. }
  27. inline bool operator!= (const Rect& rhs) const
  28. {
  29. return !(*this == rhs);
  30. }
  31. };
  32. }