Qt中关于QEasingCurve的问题
void MagnifierFilter::init(int _w,int _h,int _factor,qreal curve)
{
if(m_width == _w && m_height == _h && m_factor == _factor && m_curve == curve)
return;
if(m_matrixX)
delete m_matrixX;
if(m_matrixY)
delete m_matrixY;
m_width = _w;m_height = _h;
int *dataX = (int*)malloc(m_width * m_height * sizeof(int));
int *dataY = (int*)malloc(m_width * m_height * sizeof(int));
m_easingCurve = QEasingCurve(QEasingCurve::OutInQuad);
int valuex,valuey;
qreal s1,s2,l1,l2;
l1 = 0.2;
l2 = 0.8;
qreal prog,prog1,prog2;
s1 = m_easingCurve.valueForProgress(l1);
s2 = m_easingCurve.valueForProgress(l2);
qreal s = (s2 - s1)/(l2 - l1);
for(int h = 0;h < m_height;h++){
int pos = h * m_width;
prog = qreal(h+1)/(qreal)m_height;
if(prog < l1 || prog > l2){
prog1 = m_easingCurve.valueForProgress(prog);
valuey = m_height * prog1;
}else{
prog1 = (s) * (prog - l1) + s1 ;
valuey = m_height * prog1;
}
for(int w = 0;w < m_width;w++){
prog = qreal(w+1)/(qreal)m_width;
if(prog < l1 || prog > l2){
prog2 = m_easingCurve.valueForProgress(prog);
valuex = m_width * prog2;
}else{
prog2 = (s) * (prog - l1) + s1;
valuex = m_width * prog2;
}
dataX[pos + w] = valuex;
dataY[pos + w] = valuey;
}
}
m_matrixX = new WsMatrix(_w,_h,dataX);
m_matrixY = new WsMatrix(_w,_h,dataY);
}