updated codes of Gradient, added comments, upgrade function name.
This commit is contained in:
parent
b0d404bb11
commit
11000ebc22
@ -8,12 +8,12 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
template<typename P,typename T> struct GradientStop
|
template<typename P,typename T> struct GradientStop
|
||||||
{
|
{
|
||||||
P pos;
|
P pos; ///<进度数据
|
||||||
T data;
|
T data; ///<数据
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渐变类
|
* 数据渐变类模板
|
||||||
*/
|
*/
|
||||||
template<typename P,typename T> class Gradient
|
template<typename P,typename T> class Gradient
|
||||||
{
|
{
|
||||||
@ -44,6 +44,9 @@ namespace hgl
|
|||||||
dirty=true;
|
dirty=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加一个渐变点
|
||||||
|
*/
|
||||||
void Add(const P &pos,const T &data)
|
void Add(const P &pos,const T &data)
|
||||||
{
|
{
|
||||||
GS gs;
|
GS gs;
|
||||||
@ -61,11 +64,14 @@ namespace hgl
|
|||||||
dirty=true;
|
dirty=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool GetLowest(P &pos)const
|
/**
|
||||||
|
* 取得最低渐变进度
|
||||||
|
*/
|
||||||
|
const bool GetLowestPosition(P &pos)const
|
||||||
{
|
{
|
||||||
GS gs;
|
GS gs;
|
||||||
|
|
||||||
if(stop_list.First(gs))
|
if(stop_list.GetFirst(gs))
|
||||||
{
|
{
|
||||||
pos=gs.pos;
|
pos=gs.pos;
|
||||||
return(true);
|
return(true);
|
||||||
@ -74,11 +80,14 @@ namespace hgl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool GetHighest(P &pos)const
|
/**
|
||||||
|
* 取得最高渐变进度
|
||||||
|
*/
|
||||||
|
const bool GetHighestPosition(P &pos)const
|
||||||
{
|
{
|
||||||
GS gs;
|
GS gs;
|
||||||
|
|
||||||
if(stop_list.Last(gs))
|
if(stop_list.GetLast(gs))
|
||||||
{
|
{
|
||||||
pos=gs.pos;
|
pos=gs.pos;
|
||||||
return(true);
|
return(true);
|
||||||
@ -87,11 +96,48 @@ namespace hgl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得最低渐变结果
|
||||||
|
*/
|
||||||
|
const bool GetLowestData(T &data)const
|
||||||
|
{
|
||||||
|
GS gs;
|
||||||
|
|
||||||
|
if(stop_list.GetFirst(gs))
|
||||||
|
{
|
||||||
|
data=gs.data;
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得最高渐变结果
|
||||||
|
*/
|
||||||
|
const bool GetHighestData(T &data)const
|
||||||
|
{
|
||||||
|
GS gs;
|
||||||
|
|
||||||
|
if(stop_list.GetLast(gs))
|
||||||
|
{
|
||||||
|
data=gs.data;
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void Get(T &reuslt,const T &start,const T &end,const float &pos)
|
virtual void Get(T &reuslt,const T &start,const T &end,const float &pos)
|
||||||
{
|
{
|
||||||
result=start+(end-start)*pos;
|
result=start+(end-start)*pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得指定进度下的渐变结果
|
||||||
|
* @param pos 进度
|
||||||
|
* @param result 结果
|
||||||
|
*/
|
||||||
const void Get(T &result,const P &pos)
|
const void Get(T &result,const P &pos)
|
||||||
{
|
{
|
||||||
const uint count=stop_list.GetCount();
|
const uint count=stop_list.GetCount();
|
||||||
@ -141,4 +187,18 @@ namespace hgl
|
|||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
template<> void name::Get(T &result,const T &start,const T &end,const float &pos)
|
template<> void name::Get(T &result,const T &start,const T &end,const float &pos)
|
||||||
|
|
||||||
|
/*
|
||||||
|
HGL_GRADIENT_DEFINE(GradientColor3f,float,Lum)
|
||||||
|
{
|
||||||
|
result=start+(end-start)*pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGL_GRADIENT_DEFINE(GradientColor3u8,uint,Color3b)
|
||||||
|
{
|
||||||
|
result.r=start.r+float(end.r-start.r)*pos;
|
||||||
|
result.g=start.g+float(end.g-start.g)*pos;
|
||||||
|
result.b=start.b+float(end.b-start.b)*pos;
|
||||||
|
}
|
||||||
|
*/
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user