Geometries.cpp 825 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Geometries.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "Geometries.h"
  12. #include "../CMT.h"
  13. #include <SDL_events.h>
  14. #include "../../lib/int3.h"
  15. Point::Point(const int3 &a)
  16. :x(a.x),y(a.y)
  17. {}
  18. Point::Point(const SDL_MouseMotionEvent &a)
  19. :x(a.x),y(a.y)
  20. {}
  21. Rect Rect::createCentered( int w, int h )
  22. {
  23. return Rect(screen->w/2 - w/2, screen->h/2 - h/2, w, h);
  24. }
  25. Rect Rect::around(const Rect &r, int width)
  26. {
  27. return Rect(r.x - width, r.y - width, r.w + width * 2, r.h + width * 2);
  28. }
  29. Rect Rect::centerIn(const Rect &r)
  30. {
  31. return Rect(r.x + (r.w - w) / 2, r.y + (r.h - h) / 2, w, h);
  32. }