Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1.  
  2. RectF::RectF(float in_left, float in_right, float in_top, float in_bottom)
  3. {
  4.     left = in_left;
  5.     right = in_right;
  6.     top = in_top;
  7.     bottom = in_bottom;
  8. }
  9.  
  10. RectF::RectF(const Vec2 & topLeft, const Vec2 & bottomRight)
  11. {
  12.     RectF(topLeft.x, bottomRight.x, topLeft.y, bottomRight.y);
  13. }
  14.  
  15. RectF::RectF(const Vec2 & topLeft, float width, float height)
  16. {
  17.     RectF(topLeft, topLeft + Vec2(width, height));
  18. }
  19.  
  20. bool RectF::IsOverlappingWith(const RectF & other_object)
  21. {
  22.     return right > other_object.left && left < other_object.right
  23.         && bottom > other_object.top && top < other_object.bottom;
  24. }
  25.  
  26. RectF RectF::FromCenter(const Vec2 & center, float halfWidth, float halfHeight)
  27. {
  28.     const Vec2 half(halfWidth, halfHeight);
  29.     return RectF(center - half, center + half);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement