Geometries.cpp 786 B

1234567891011121314151617181920212223242526272829303132
  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. Point::Point(const SDL_MouseMotionEvent & a)
  15. : x(a.x), y(a.y)
  16. {}
  17. Rect Rect::createCentered(int w, int h)
  18. {
  19. return Rect(screen->w / 2 - w / 2, screen->h / 2 - h / 2, w, h);
  20. }
  21. Rect Rect::around(const Rect & r, int width) /*creates rect around another */
  22. {
  23. return Rect(r.x - width, r.y - width, r.w + width * 2, r.h + width * 2);
  24. }
  25. Rect Rect::centerIn(const Rect & r)
  26. {
  27. return Rect(r.x + (r.w - w) / 2, r.y + (r.h - h) / 2, w, h);
  28. }