append return value in Color3f/4f::operator =
This commit is contained in:
parent
ac8565e338
commit
b5c66fe2cd
@ -58,10 +58,11 @@ namespace hgl
|
|||||||
void Grey(); ///<将当前色彩变成灰色
|
void Grey(); ///<将当前色彩变成灰色
|
||||||
|
|
||||||
//操作符重载
|
//操作符重载
|
||||||
void operator = (const float *v){r=*v++;g=*v++;b=*v;}
|
const Color3f &operator = (const float *v){r=*v++;g=*v++;b=*v;return *this;}
|
||||||
|
const Color3f &operator = (const Color3f &v){r=v.r;g=v.g;b=v.b;return *this;}
|
||||||
|
|
||||||
bool operator == (const Color3f &);
|
bool operator == (const Color3f &)const;
|
||||||
bool operator != (const Color3f &);
|
bool operator != (const Color3f &)const;
|
||||||
|
|
||||||
void operator += (const Color3f &v){r+=v.r;g+=v.g;b+=v.b;Clamp();}
|
void operator += (const Color3f &v){r+=v.r;g+=v.g;b+=v.b;Clamp();}
|
||||||
void operator -= (const Color3f &v){r-=v.r;g-=v.g;b-=v.b;Clamp();}
|
void operator -= (const Color3f &v){r-=v.r;g-=v.g;b-=v.b;Clamp();}
|
||||||
|
@ -68,12 +68,12 @@ namespace hgl
|
|||||||
void Grey(); ///<将当前色彩变成灰色
|
void Grey(); ///<将当前色彩变成灰色
|
||||||
|
|
||||||
//操作符重载
|
//操作符重载
|
||||||
void operator = (const float *v){r=*v++;g=*v++;b=*v++;a=*v;}
|
const Color4f &operator = (const float *v){r=*v++;g=*v++;b=*v++;a=*v;return *this;}
|
||||||
void operator = (const Color3f &v){r=v.r;g=v.g;b=v.b;a=1;}
|
const Color4f &operator = (const Color3f &v){r=v.r;g=v.g;b=v.b;a=1;;return *this;}
|
||||||
void operator = (const Color4f &v){r=v.r;g=v.g;b=v.b;a=v.a;}
|
const Color4f &operator = (const Color4f &v){r=v.r;g=v.g;b=v.b;a=v.a;;return *this;}
|
||||||
|
|
||||||
bool operator == (const Color4f &);
|
bool operator == (const Color4f &)const;
|
||||||
bool operator != (const Color4f &);
|
bool operator != (const Color4f &)const;
|
||||||
|
|
||||||
void operator += (const Color4f &v){r+=v.r;g+=v.g;b+=v.b;a+=v.a;Clamp();}
|
void operator += (const Color4f &v){r+=v.r;g+=v.g;b+=v.b;a+=v.a;Clamp();}
|
||||||
void operator -= (const Color4f &v){r-=v.r;g-=v.g;b-=v.b;a-=v.a;Clamp();}
|
void operator -= (const Color4f &v){r-=v.r;g-=v.g;b-=v.b;a-=v.a;Clamp();}
|
||||||
|
@ -14,5 +14,10 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
return (r*54+g*183+b*19)>>8;
|
return (r*54+g*183+b*19)>>8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T> constexpr T RGB2LumBT2020(const T &r,const T &g,const T &b)
|
||||||
|
{
|
||||||
|
return 0.2627f*r+0.6780f*g+0.0593f*b;
|
||||||
|
}
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#endif//HGL_COLOR_LUM_INCLUDE
|
#endif//HGL_COLOR_LUM_INCLUDE
|
||||||
|
@ -39,7 +39,7 @@ namespace hgl
|
|||||||
b=lum;
|
b=lum;
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool Color3f::operator == (const Color3f &v)
|
bool Color3f::operator == (const Color3f &v) const
|
||||||
{
|
{
|
||||||
if(r!=v.r)return(false);
|
if(r!=v.r)return(false);
|
||||||
if(g!=v.g)return(false);
|
if(g!=v.g)return(false);
|
||||||
@ -48,7 +48,7 @@ namespace hgl
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool Color3f::operator != (const Color3f &v)
|
bool Color3f::operator != (const Color3f &v) const
|
||||||
{
|
{
|
||||||
if(r!=v.r)return(true);
|
if(r!=v.r)return(true);
|
||||||
if(g!=v.g)return(true);
|
if(g!=v.g)return(true);
|
||||||
|
@ -40,7 +40,7 @@ namespace hgl
|
|||||||
b=lum;
|
b=lum;
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool Color4f::operator == (const Color4f &v)
|
bool Color4f::operator == (const Color4f &v) const
|
||||||
{
|
{
|
||||||
if(r!=v.r)return(false);
|
if(r!=v.r)return(false);
|
||||||
if(g!=v.g)return(false);
|
if(g!=v.g)return(false);
|
||||||
@ -50,7 +50,7 @@ namespace hgl
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool Color4f::operator != (const Color4f &v)
|
bool Color4f::operator != (const Color4f &v) const
|
||||||
{
|
{
|
||||||
if(r!=v.r)return(true);
|
if(r!=v.r)return(true);
|
||||||
if(g!=v.g)return(true);
|
if(g!=v.g)return(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user