Geometries.cpp 731 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. *
  3. * Geometries.cpp, part of VCMI engine
  4. *
  5. * Authors: listed in file AUTHORS in main folder
  6. *
  7. * License: GNU General Public License v2.0 or later
  8. * Full text of license available in license.txt file, in main folder
  9. *
  10. */
  11. #include "StdInc.h"
  12. #include "Geometries.h"
  13. #include <SDL_rect.h>
  14. #include <SDL_events.h>
  15. Rect Geometry::fromSDL(const SDL_Rect & rect)
  16. {
  17. return Rect(Point(rect.x, rect.y), Point(rect.w, rect.h));
  18. }
  19. SDL_Rect Geometry::toSDL(const Rect & rect)
  20. {
  21. SDL_Rect result;
  22. result.x = rect.x;
  23. result.y = rect.y;
  24. result.w = rect.w;
  25. result.h = rect.h;
  26. return result;
  27. }
  28. Point Geometry::fromSDL(const SDL_MouseMotionEvent & motion)
  29. {
  30. return { motion.x, motion.y };
  31. }