CmRectF.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include "CmPrerequisitesUtil.h"
  3. namespace CamelotFramework
  4. {
  5. class CM_UTILITY_EXPORT RectF
  6. {
  7. public:
  8. RectF();
  9. RectF(float _x, float _y, float _width, float _height);
  10. float x, y, width, height;
  11. bool contains(const Vector2& point) const;
  12. bool overlaps(const RectF& other) const;
  13. void encapsulate(const RectF& other);
  14. void clip(const RectF& 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 RectF& rhs) const
  24. {
  25. return x == rhs.x && y == rhs.y && width == rhs.width && height == rhs.height;
  26. }
  27. inline bool operator!= (const RectF& rhs) const
  28. {
  29. return !(*this == rhs);
  30. }
  31. static const RectF EMPTY;
  32. };
  33. }