2
0

Geometries.cpp 546 B

1234567891011121314151617181920212223
  1. #include "StdInc.h"
  2. #include "Geometries.h"
  3. #include "../CMT.h"
  4. #include <SDL_events.h>
  5. Point::Point(const SDL_MouseMotionEvent &a)
  6. :x(a.x),y(a.y)
  7. {}
  8. Rect Rect::createCentered( int w, int h )
  9. {
  10. return Rect(screen->w/2 - w/2, screen->h/2 - h/2, w, h);
  11. }
  12. Rect Rect::around(const Rect &r, int width /*= 1*/) /*creates rect around another */
  13. {
  14. return Rect(r.x - width, r.y - width, r.w + width * 2, r.h + width * 2);
  15. }
  16. Rect Rect::centerIn(const Rect &r)
  17. {
  18. return Rect(r.x + (r.w - w) / 2, r.y + (r.h - h) / 2, w, h);
  19. }