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