[Qt-interest] QTimeLine from 0 to 100, to -100 and back to 0 ?
Oliver Demetz
forenbeitraege at oliverdemetz.de
Fri Aug 21 12:35:27 CEST 2009
Yes, also cool. Thanks.
But without the 100:
return qSin(qreal(msec) * 2 * pi / d );
Thanks!
Sean Harmer schrieb:
> Hi,
>
> On Friday 21 Aug 2009 10:24:29 Oliver Demetz wrote:
>> Solved,
> Cool.
>
>> just in case someone is interested:
>>
>> class MyTimeLine : public QTimeLine
>> {
>> public:
>> MyTimeLine ( int duration = 1000, QObject * parent = 0 )
>>
>> : QTimeLine ( duration , parent ) {}
>>
>> qreal valueForTime(int msec) const
>> {
>> qreal d = (qreal) duration();
>>
>> if (msec < d/4)
>> {
>> return 4.0 * (qreal) msec / d;
>> }
>> else if(msec < 3*d/4)
>> {
>> return - 4*msec/d + 2;
>> }
>> else
>> {
>> return 4*msec/d - 4;
>> }
>> }
>> };
> You could also have used a sine function with the appropriate period and
> scaling. e.g.
>
> qreal valueForTime(int msec) const
> {
> qreal d = (qreal) duration();
> return 100 * sin( qreal(msec) * 2 * pi / d );
> }
>
> Sean
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list