2017-07-13 10:26:03 +02:00
|
|
|
/*
|
|
|
|
* Geometries.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2011-12-22 16:05:19 +03:00
|
|
|
#include "StdInc.h"
|
|
|
|
#include "Geometries.h"
|
2013-04-04 17:58:54 +03:00
|
|
|
#include "../CMT.h"
|
2014-07-15 10:14:49 +03:00
|
|
|
#include <SDL_events.h>
|
|
|
|
|
|
|
|
Point::Point(const SDL_MouseMotionEvent &a)
|
|
|
|
:x(a.x),y(a.y)
|
|
|
|
{}
|
2011-12-22 16:05:19 +03:00
|
|
|
|
|
|
|
Rect Rect::createCentered( int w, int h )
|
|
|
|
{
|
|
|
|
return Rect(screen->w/2 - w/2, screen->h/2 - h/2, w, h);
|
|
|
|
}
|
|
|
|
|
2017-07-15 13:08:20 +02:00
|
|
|
Rect Rect::around(const Rect &r, int width) /*creates rect around another */
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
|
|
|
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);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|