Geometries.cpp 727 B

1234567891011121314151617181920212223242526272829303132333435
  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 <SDL_rect.h>
  13. #include <SDL_events.h>
  14. Rect Geometry::fromSDL(const SDL_Rect & rect)
  15. {
  16. return Rect(Point(rect.x, rect.y), Point(rect.w, rect.h));
  17. }
  18. SDL_Rect Geometry::toSDL(const Rect & rect)
  19. {
  20. SDL_Rect result;
  21. result.x = rect.x;
  22. result.y = rect.y;
  23. result.w = rect.w;
  24. result.h = rect.h;
  25. return result;
  26. }
  27. Point Geometry::fromSDL(const SDL_MouseMotionEvent & motion)
  28. {
  29. return { motion.x, motion.y };
  30. }