Imported more code from the old engine.
[peakengine.git] / engine / include / support / dimension2d.h
blob977685c2658cc2ef130926607ee5e3027a69b5d8
1 // Copyright (C) 2002-2007 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
5 #ifndef __IRR_DIMENSION2D_H_INCLUDED__
6 #define __IRR_DIMENSION2D_H_INCLUDED__
8 #include "irrTypes.h"
10 namespace irr
12 namespace core
15 //! Specifies a 2 dimensional size.
16 template <class T>
17 class dimension2d
19 public:
20 dimension2d() : Width(0), Height(0) {}
22 dimension2d(const T& width, const T& height)
23 : Width(width), Height(height) {}
25 bool operator == (const dimension2d<T>& other) const
27 return Width == other.Width && Height == other.Height;
30 bool operator != (const dimension2d<T>& other) const
32 return ! (*this == other);
35 dimension2d<T>& set(const T& width, const T& height)
37 Width = width;
38 Height = height;
39 return *this;
42 dimension2d<T>& operator/=(const T& scale)
44 Width /= scale;
45 Height /= scale;
46 return *this;
49 dimension2d<T> operator/(const T& scale) const
51 return dimension2d<T>(Width/scale, Height/scale);
54 dimension2d<T>& operator*=(const T& scale)
56 Width *= scale;
57 Height *= scale;
58 return *this;
61 dimension2d<T> operator*(const T& scale) const
63 return dimension2d<T>(Width*scale, Height*scale);
66 T Width, Height;
69 //! Typedef for a f32 dimension.
70 typedef dimension2d<f32> dimension2df;
71 //! Typedef for an integer dimension.
72 typedef dimension2d<s32> dimension2di;
74 } // end namespace core
75 } // end namespace irr
77 #endif