diff options
Diffstat (limited to 'src/svg/qsvgtinydocument.cpp')
-rw-r--r-- | src/svg/qsvgtinydocument.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp index e2cefeb..21e9e9f 100644 --- a/src/svg/qsvgtinydocument.cpp +++ b/src/svg/qsvgtinydocument.cpp @@ -466,20 +466,19 @@ QMatrix QSvgTinyDocument::matrixForElement(const QString &id) const int QSvgTinyDocument::currentFrame() const { - double runningPercentage = qMin(m_time.elapsed()/double(m_animationDuration), 1.); + const qreal runningPercentage = qMin(qreal(m_time.elapsed()) / qreal(m_animationDuration), qreal(1.)); - int totalFrames = m_fps * m_animationDuration; + const int totalFrames = m_fps * m_animationDuration; return int(runningPercentage * totalFrames); } void QSvgTinyDocument::setCurrentFrame(int frame) { - int totalFrames = m_fps * m_animationDuration; - double framePercentage = frame/double(totalFrames); - double timeForFrame = m_animationDuration * framePercentage; //in S - timeForFrame *= 1000; //in ms - int timeToAdd = int(timeForFrame - m_time.elapsed()); + const int totalFrames = m_fps * m_animationDuration; + const qreal framePercentage = frame / totalFrames; + const qreal timeForFrame = m_animationDuration * framePercentage * 1000; //in ms + const int timeToAdd = int(timeForFrame - m_time.elapsed()); m_time = m_time.addMSecs(timeToAdd); } |