Geometries.cpp 462 B

12345678910111213141516171819
  1. #include "StdInc.h"
  2. #include "Geometries.h"
  3. extern SDL_Surface * screen;
  4. Rect Rect::createCentered( int w, int h )
  5. {
  6. return Rect(screen->w/2 - w/2, screen->h/2 - h/2, w, h);
  7. }
  8. Rect Rect::around(const Rect &r, int width /*= 1*/) /*creates rect around another */
  9. {
  10. return Rect(r.x - width, r.y - width, r.w + width * 2, r.h + width * 2);
  11. }
  12. Rect Rect::centerIn(const Rect &r)
  13. {
  14. return Rect(r.x + (r.w - w) / 2, r.y + (r.h - h) / 2, w, h);
  15. }