OpenTTD Source: src/core/geometry_type.hpp Source File

OpenTTD Source 12.2

geometry_type.hpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef GEOMETRY_TYPE_HPP
11 #define GEOMETRY_TYPE_HPP
12
13 #if defined(__APPLE__)
14 /* Mac OS X already has both Rect and Point declared */
15 # define Rect OTTD_Rect
16 # define Point OTTD_Point
17 #endif /* __APPLE__ */
18
19
21 struct Point {
22 int x;
23 int y;
24 };
25
27 struct Dimension {
28 uint width;
29 uint height;
30
31 Dimension(uint w = 0, uint h = 0) : width(w), height(h) {};
32
33 bool operator< (const Dimension &other) const
34 {
35 int x = (*this).width - other.width;
36 if (x != 0) return x < 0;
37 return (*this).height < other.height;
38 }
39
40 bool operator== (const Dimension &other) const
41 {
42 return (*this).width == other.width && (*this).height == other.height;
43 }
44 };
45
47 struct Rect {
48 int left;
49 int top;
50 int right;
51 int bottom;
52 };
53
58 struct PointDimension {
59 int x;
60 int y;
61 int width;
62 int height;
63 };
64
65 #endif /* GEOMETRY_TYPE_HPP */
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
PointDimension
Specification of a rectangle with an absolute top-left coordinate and a (relative) width/height.
Definition: geometry_type.hpp:58
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47