1 /* Copyright (C) 2021 Wildfire Games.
2 * This file is part of 0 A.D.
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
26 * Rectangle class used for screen rectangles. It's very similar to the MS
27 * CRect, but with FLOATS because it's meant to be used with OpenGL which
34 CRect(const CVector2D
& pos
);
35 CRect(const CSize2D
& size
);
36 CRect(const CVector2D
& upperleft
, const CVector2D
& bottomright
);
37 CRect(const CVector2D
& pos
, const CSize2D
& size
);
38 CRect(const float l
, const float t
, const float r
, const float b
);
41 CRect
& operator=(const CRect
& a
);
42 bool operator==(const CRect
& a
) const;
43 bool operator!=(const CRect
& a
) const;
44 CRect
operator-() const;
45 CRect
operator+() const;
47 CRect
operator+(const CRect
& a
) const;
48 CRect
operator+(const CVector2D
& a
) const;
49 CRect
operator+(const CSize2D
& a
) const;
50 CRect
operator-(const CRect
& a
) const;
51 CRect
operator-(const CVector2D
& a
) const;
52 CRect
operator-(const CSize2D
& a
) const;
54 void operator+=(const CRect
& a
);
55 void operator+=(const CVector2D
& a
);
56 void operator+=(const CSize2D
& a
);
57 void operator-=(const CRect
& a
);
58 void operator-=(const CVector2D
& a
);
59 void operator-=(const CSize2D
& a
);
62 * @return Width of Rectangle
64 float GetWidth() const;
67 * @return Height of Rectangle
69 float GetHeight() const;
74 CSize2D
GetSize() const;
77 * Get Position equivalent to top/left corner
79 CVector2D
TopLeft() const;
82 * Get Position equivalent to top/right corner
84 CVector2D
TopRight() const;
87 * Get Position equivalent to bottom/left corner
89 CVector2D
BottomLeft() const;
92 * Get Position equivalent to bottom/right corner
94 CVector2D
BottomRight() const;
97 * Get Position equivalent to the center of the rectangle
99 CVector2D
CenterPoint() const;
102 * Evalutates if point is within the rectangle
103 * @param point CVector2D representing point
104 * @return true if inside.
106 bool PointInside(const CVector2D
&point
) const;
108 CRect
Scale(float x
, float y
) const;
111 * Returning CVector2D representing each corner.
118 float left
, top
, right
, bottom
;
121 #endif // INCLUDED_RECT