/* * Rect.h, 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 * */ #pragma once #include "Point.h" VCMI_LIB_NAMESPACE_BEGIN /// Rectangle class, which have a position and a size class Rect { public: int x; int y; int w; int h; Rect() { x = y = w = h = -1; } Rect(int X, int Y, int W, int H) { x = X; y = Y; w = W; h = H; } Rect(const Point & position, const Point & size) { x = position.x; y = position.y; w = size.x; h = size.y; } Rect(const Rect& r) = default; DLL_LINKAGE static Rect createCentered( const Point & around, const Point & size ); DLL_LINKAGE static Rect createCentered( const Rect & target, const Point & size ); DLL_LINKAGE static Rect createAround(const Rect &r, int borderWidth); bool isInside(int qx, int qy) const { if (qx > x && qxy && qy void serialize(Handler &h, const int version) { h & x; h & y; h & w; h & h; } }; VCMI_LIB_NAMESPACE_END