SRect.cpp 468 B

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