本文整理汇总了C++中QEasingCurve::valueForProgress方法的典型用法代码示例。如果您正苦于以下问题:C++ QEasingCurve::valueForProgress方法的具体用法?C++ QEasingCurve::valueForProgress怎么用?C++ QEasingCurve::valueForProgress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QEasingCurve
的用法示例。
在下文中一共展示了QEasingCurve::valueForProgress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createCurveIcons
void Window::createCurveIcons()
{
QPixmap pix(m_iconSize);
QPainter painter(&pix);
QLinearGradient gradient(0,0, 0, m_iconSize.height());
gradient.setColorAt(0.0, QColor(240, 240, 240));
gradient.setColorAt(1.0, QColor(224, 224, 224));
QBrush brush(gradient);
const QMetaObject &mo = QEasingCurve::staticMetaObject;
QMetaEnum metaEnum = mo.enumerator(mo.indexOfEnumerator("Type"));
// Skip QEasingCurve::Custom
for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) {
painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush);
QEasingCurve curve = createEasingCurve((QEasingCurve::Type) i);
painter.setPen(QColor(0, 0, 255, 64));
qreal xAxis = m_iconSize.height()/1.5;
qreal yAxis = m_iconSize.width()/3;
painter.drawLine(0, xAxis, m_iconSize.width(), xAxis);
painter.drawLine(yAxis, 0, yAxis, m_iconSize.height());
qreal curveScale = m_iconSize.height()/2;
painter.setPen(Qt::NoPen);
// start point
painter.setBrush(Qt::red);
QPoint start(yAxis, xAxis - curveScale * curve.valueForProgress(0));
painter.drawRect(start.x() - 1, start.y() - 1, 3, 3);
// end point
painter.setBrush(Qt::blue);
QPoint end(yAxis + curveScale, xAxis - curveScale * curve.valueForProgress(1));
painter.drawRect(end.x() - 1, end.y() - 1, 3, 3);
QPainterPath curvePath;
curvePath.moveTo(start);
for (qreal t = 0; t <= 1.0; t+=1.0/curveScale) {
QPoint to;
to.setX(yAxis + curveScale * t);
to.setY(xAxis - curveScale * curve.valueForProgress(t));
curvePath.lineTo(to);
}
painter.setRenderHint(QPainter::Antialiasing, true);
painter.strokePath(curvePath, QColor(32, 32, 32));
painter.setRenderHint(QPainter::Antialiasing, false);
QListWidgetItem *item = new QListWidgetItem;
item->setIcon(QIcon(pix));
item->setText(metaEnum.key(i));
m_ui.easingCurvePicker->addItem(item);
}
}
示例2: GenEasingCurveCode
QString GenEasingCurveCode(QEasingCurve easingCurve, QString strLabel)
{
QString str = strLabel + "\r\n";
for (int i = 0; i <= 1000; ++i)
{
str += QString("%1f, ").arg(easingCurve.valueForProgress((i * 1.0 / 1000)));
if (i % 10 == 0 && i != 0)
{
str += "\r\n";
}
}
str += "\r\n";
return str;
}
示例3: applyAnimation
slideShowEngine::AnimationState slideShowEngine::applyAnimation()
{
effect e;
QEasingCurve curve;
qreal currentValue;
Pixmap *item;
if(m_currentStep==EnterAnimation)
e=m_currentNode.enterEffect();
else
if(m_currentStep==DisplayAnimation)
e=m_currentNode.displayEffect();
else
if(m_currentStep==ExitAnimation)
e=m_currentNode.exitEffect();
int duration=e.duration();
//int elapsed=m_stepCurrentTime;
curve.setPeriod(duration);
qreal startVal=qreal(e.startValue());
qreal endVal=qreal(e.endValue());
curve.setType(e.easingCurve());
//qreal valore=qreal(m_stepCurrentTime*TIMER_ANIMATION);
qreal valore=qreal(m_stepCurrentTime);
//qreal valore=qreal(m_stepCurrentTime*10);
valore=valore/(qreal(duration));
//valore=valore/10;
//currentValue=curve.valueForProgress(valore);
currentValue=endVal+(1.0-curve.valueForProgress(valore))*(startVal-endVal);
item=m_PixmapList[m_currentSlideIndex];
if(e.effectType()=="pos")
item->setProperty(e.effectType().toLatin1(),QVariant(QPointF(currentValue,0)));
else
item->setProperty(e.effectType().toLatin1(),QVariant(currentValue));
//if(m_stepCurrentTime*TIMER_ANIMATION < e.duration()/**10*/)
if(m_stepCurrentTime < duration)
//if(m_stepCurrentTime*10 < e.duration()/**10*/)
return RunningAnimation;
else
return EndAnimation;
}
示例4: setCustomType
void tst_QEasingCurve::setCustomType()
{
QEasingCurve curve;
curve.setCustomType(&discreteEase);
QCOMPARE(curve.type(), QEasingCurve::Custom);
QCOMPARE(curve.valueForProgress(0.0), 0.0);
QCOMPARE(curve.valueForProgress(0.05), 0.0);
QCOMPARE(curve.valueForProgress(0.10), 0.1);
QCOMPARE(curve.valueForProgress(0.15), 0.1);
QCOMPARE(curve.valueForProgress(0.20), 0.2);
QCOMPARE(curve.valueForProgress(0.25), 0.2);
QCOMPARE(curve.valueForProgress(0.30), 0.3);
QCOMPARE(curve.valueForProgress(0.35), 0.3);
QCOMPARE(curve.valueForProgress(0.999999), 0.9);
curve.setType(QEasingCurve::Linear);
QCOMPARE(curve.type(), QEasingCurve::Linear);
QCOMPARE(curve.valueForProgress(0.0), 0.0);
QCOMPARE(curve.valueForProgress(0.1), 0.1);
QCOMPARE(curve.valueForProgress(0.5), 0.5);
QCOMPARE(curve.valueForProgress(0.99), 0.99);
}