5 AnimPoint::AnimPoint() { init(); }
7 void AnimPoint::operator=(const AnimPoint &other) { copy(other); }
9 void AnimPoint::operator=(const QPointF &other)
16 bool AnimPoint::operator==(const QPointF &other)
22 bool AnimPoint::operator==(AnimPoint other)
24 if (rx() != other.rx())
26 if (ry() != other.ry())
28 if (startPos != other.startPos)
30 if (destPos != other.destPos)
32 if (animated != other.animated)
38 void AnimPoint::init()
42 startPos = QPointF(0, 0);
43 destPos = QPointF(0, 0);
44 vector = QPointF(0, 0);
48 void AnimPoint::copy(AnimPoint other)
52 startPos = other.startPos;
53 destPos = other.destPos;
54 vector = other.vector;
55 animated = other.animated;
57 animTicks = other.animTicks;
60 void AnimPoint::setStart(const QPointF &p)
66 QPointF AnimPoint::getStart() { return startPos; }
68 void AnimPoint::setDest(const QPointF &p)
74 QPointF AnimPoint::getDest() { return destPos; }
76 void AnimPoint::setTicks(const uint &t) { animTicks = t; }
78 uint AnimPoint::getTicks() { return (uint)animTicks; }
80 void AnimPoint::setAnimated(bool b)
87 bool AnimPoint::isAnimated() { return animated; }
89 bool AnimPoint::animate()
95 vector = QPointF(0, 0);
102 // Some math to slow down the movement in the end
103 qreal f = 1 - n / (qreal)animTicks;
104 qreal ff = 1 - f * f * f;
105 setX(startPos.x() + vector.x() * ff);
106 setY(startPos.y() + vector.y() * ff);
111 void AnimPoint::stop()
118 void AnimPoint::initVector()
120 vector.setX(destPos.x() - startPos.x());
121 vector.setY(destPos.y() - startPos.y());