src/math/sizef.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_MATH_SIZEF_HPP
00018 #define HEADER_SUPERTUX_MATH_SIZEF_HPP
00019 
00020 #include <iosfwd>
00021 
00022 class Size;
00023 
00024 class Sizef
00025 {
00026 public:
00027   Sizef() :
00028     width(0.0f),
00029     height(0.0f)
00030   {}
00031 
00032   Sizef(float width_, float height_) :
00033     width(width_), 
00034     height(height_) 
00035   {}
00036 
00037   Sizef(const Sizef& rhs) :
00038     width(rhs.width),
00039     height(rhs.height)
00040   {}
00041 
00042   Sizef(const Size& rhs);
00043 
00044   Sizef& operator*=(float factor)
00045   {
00046     width  *= factor;
00047     height *= factor;
00048     return *this;
00049   }
00050 
00051   Sizef& operator/=(float divisor)
00052   {
00053     width  /= divisor;
00054     height /= divisor;
00055     return *this;
00056   }
00057 
00058   Sizef& operator+=(const Sizef& rhs)
00059   { 
00060     width  += rhs.width; 
00061     height += rhs.height; 
00062     return *this; 
00063   }
00064 
00065   Sizef& operator-=(const Sizef& rhs)
00066   { 
00067     width  -= rhs.width; 
00068     height -= rhs.height; 
00069     return *this; 
00070   }
00071 
00072 public:
00073   float width;
00074   float height;
00075 };
00076 
00077 inline Sizef operator*(const Sizef& lhs, float factor)
00078 { 
00079   return Sizef(lhs.width  * factor, 
00080                lhs.height * factor); 
00081 }
00082 
00083 inline Sizef operator*(float factor, const Sizef& rhs)
00084 { 
00085   return Sizef(rhs.width  * factor, 
00086                rhs.height * factor); 
00087 }
00088 
00089 inline Sizef operator/(const Sizef& lhs, float divisor)
00090 { 
00091   return Sizef(lhs.width  / divisor, 
00092                lhs.height / divisor); 
00093 }
00094 
00095 inline Sizef operator+(const Sizef& lhs, const Sizef& rhs)
00096 { 
00097   return Sizef(lhs.width  + rhs.width, 
00098                lhs.height + rhs.height); 
00099 }
00100 
00101 inline Sizef operator-(const Sizef& lhs, const Sizef& rhs)
00102 {
00103   return Sizef(lhs.width  - rhs.width, 
00104                lhs.height - rhs.height); 
00105 }
00106 
00107 inline bool operator==(const Sizef& lhs, const Sizef& rhs)
00108 {
00109   return (lhs.width == rhs.width) && (rhs.height == rhs.height); 
00110 }
00111 
00112 inline bool operator!=(const Sizef& lhs, const Sizef& rhs)
00113 { 
00114   return (lhs.width != rhs.width) || (lhs.height != rhs.height); 
00115 }
00116 
00117 std::ostream& operator<<(std::ostream& s, const Sizef& size);
00118 
00119 #endif
00120 
00121 /* EOF */

Generated on Mon Jun 9 03:38:18 2014 for SuperTux by  doxygen 1.5.1