2 // Copyright (C) 2009 Ingo Ruhnke <grumbel@gmail.com>
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.
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.
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/>.
17 #ifndef HEADER_SUPERTUX_MATH_SIZE_HPP
18 #define HEADER_SUPERTUX_MATH_SIZE_HPP
32 Size(int width_, int height_) :
37 Size(const Size& rhs) :
42 explicit Size(const Sizef& rhs);
44 Size& operator*=(int factor)
51 Size& operator/=(int divisor)
58 Size& operator+=(const Size& rhs)
65 Size& operator-=(const Size& rhs)
77 inline Size operator*(const Size& lhs, int factor)
79 return Size(lhs.width * factor,
83 inline Size operator*(int factor, const Size& rhs)
85 return Size(rhs.width * factor,
89 inline Size operator/(const Size& lhs, int divisor)
91 return Size(lhs.width / divisor,
92 lhs.height / divisor);
95 inline Size operator+(const Size& lhs, const Size& rhs)
97 return Size(lhs.width + rhs.width,
98 lhs.height + rhs.height);
101 inline Size operator-(const Size& lhs, const Size& rhs)
103 return Size(lhs.width - rhs.width,
104 lhs.height - rhs.height);
107 inline bool operator==(const Size& lhs, const Size& rhs)
109 return (lhs.width == rhs.width) && (lhs.height == rhs.height);
112 inline bool operator!=(const Size& lhs, const Size& rhs)
114 return (lhs.width != rhs.width) || (lhs.height != rhs.height);
117 std::ostream& operator<<(std::ostream& s, const Size& size);