File: Geometries.cpp

package info (click to toggle)
vcmi 0.99%2Bdfsg-2
  • links: PTS, VCS
  • area: contrib
  • in suites: stretch
  • size: 10,264 kB
  • ctags: 16,826
  • sloc: cpp: 121,945; objc: 248; sh: 193; makefile: 28; python: 13; ansic: 9
file content (23 lines) | stat: -rw-r--r-- 546 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "StdInc.h"
#include "Geometries.h"
#include "../CMT.h"
#include <SDL_events.h>

Point::Point(const SDL_MouseMotionEvent &a)
	:x(a.x),y(a.y)
{}

Rect Rect::createCentered( int w, int h )
{
	return Rect(screen->w/2 - w/2, screen->h/2 - h/2, w, h);
}

Rect Rect::around(const Rect &r, int width /*= 1*/) /*creates rect around another */
{
	return Rect(r.x - width, r.y - width, r.w + width * 2, r.h + width * 2);
}

Rect Rect::centerIn(const Rect &r)
{
	return Rect(r.x + (r.w - w) / 2, r.y + (r.h - h) / 2, w, h);
}