Added basic integer rectangle class
[supertux.git] / src / math / rect.hpp
1 //  SuperTux
2 //  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
3 //
4 //  This program 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 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program 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.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_SUPERTUX_MATH_RECT_HPP
18 #define HEADER_SUPERTUX_MATH_RECT_HPP
19
20 #include "math/size.hpp"
21
22 class Rect
23 {
24 public:
25   int left;
26   int right;
27   int top;
28   int bottom;
29
30 public:
31   Rect(int left_, int top_, int right_, int top_) :
32     left(left_),
33     top(top_),
34     right(right_),
35     top(top_)
36   {}
37
38   Rect(int left_, int top_, const Size& size) :
39     left(left_),
40     top(top_),
41     right(left_ + size.width),
42     bottom(bottom_ + size.width)
43   {}
44
45   int get_width()  const { return right - left; }
46   int get_height() const { return bottom - top; }
47
48 private:
49   Rect(const Rect&);
50   Rect& operator=(const Rect&);
51 };
52
53 #endif
54
55 /* EOF */