added Size2.h

This commit is contained in:
2023-06-07 20:35:58 +08:00
parent 72fcbb18ab
commit 08da6dac6a

46
inc/hgl/type/Size2.h Normal file
View File

@@ -0,0 +1,46 @@
#pragma once
#include<hgl/type/DataType.h>
namespace hgl
{
/**
* <20>ߴ<EFBFBD>ģ<EFBFBD><C4A3>
*/
template<typename T> struct Size2
{
T width,height;
public:
Size2()
{
width=height=0;
}
Size2(const T &w,const T &h)
{
width=w;
height=h;
}
const bool isLandscape()const{return width>height;} ///<<3C>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
const bool isPortrait()const{return width<height;} ///<<3C>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
void Swap()
{
T t=width;
width=height;
height=t;
}
Size2<T> Swapped(){return Size2<T>(height,width);} ///<<3C><>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ijߴ<C4B3>
};//template<typename T> struct Size2
using Size2i =Size2<int>;
using Size2ui =Size2<uint>;
using Size2s =Size2<int16>;
using Size2us =Size2<uint16>;
using Size2f =Size2<float>;
using Size2d =Size2<double>;
}//namespace hgl