added Size2.h

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 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
{
/**
*
*/
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;} ///<是否横的
const bool isPortrait()const{return width<height;} ///<是否竖的
void Swap()
{
T t=width;
width=height;
height=t;
}
Size2<T> Swapped(){return Size2<T>(height,width);} ///<获取一个横竖交换的尺寸
};//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