Home

QtEasingCurve Class Reference
[QtCore module]

The QtEasingCurve class provides easing curves for controlling animation. More...

 #include <QtEasingCurve>

Public Types

Public Functions


Detailed Description

The QtEasingCurve class provides easing curves for controlling animation.

Easing curves describe a function that controls how the speed of the interpolation between 0 and 1 should be. Easing curves allow transitions from one value to another to appear more natural than a simple constant speed would allow. The QtEasingCurve class is usually used in conjunction with the QAnimation class, but can be used on its own.

To calculate the speed of the interpolation, the easing curve provides the function valueForProgress(), where the progress argument specifies the progress of the interpolation: 0 is the start value of the interpolation, 1 is the end value of the interpolation. The returned value is the effective progress of the interpolation. If the returned value is the same as the input value for all input values the easing curve is a linear curve. This is the default behaviour.

For example,

 QtEasingCurve easing(QtEasingCurve::InOutQuad);

 for(qreal t = 0.0; t < 1.0; t+=0.1)
     qWarning() << "Effective progress" << t << " is
                << easing.valueForProgress(t);

will print the effective progress of the interpolation between 0 and 1.

When using a QAnimation, the easing curve will be used to control the progress of the interpolation between startValue and endValue:

 QAnimation animation;
 animation.setStartValue(0);
 animation.setEndValue(1000);
 animation.setDuration(1000);
 animation.setEasingCurve(QtEasingCurve::InOutQuad);

Member Type Documentation

typedef QtEasingCurve::EasingFunction

This is a typedef for a pointer to a function with the following signature:

 qreal myEasingFunction(qreal progress);

enum QtEasingCurve::Type

The type of easing curve.

ConstantValueDescription
QtEasingCurve::Linear0
Easing equation function for a simple linear tweening, with no easing.
QtEasingCurve::InQuad1
Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
QtEasingCurve::OutQuad2
Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
QtEasingCurve::InOutQuad3
Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInQuad4
Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InCubic5
Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
QtEasingCurve::OutCubic6
Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
QtEasingCurve::InOutCubic7
Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInCubic8
Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InQuart9
Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
QtEasingCurve::OutQuart10
Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
QtEasingCurve::InOutQuart11
Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInQuart12
Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InQuint13
Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
QtEasingCurve::OutQuint14
Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
QtEasingCurve::InOutQuint15
Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInQuint16
Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InSine17
Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
QtEasingCurve::OutSine18
Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
QtEasingCurve::InOutSine19
Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInSine20
Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InExpo21
Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
QtEasingCurve::OutExpo22
Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
QtEasingCurve::InOutExpo23
Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInExpo24
Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InCirc25
Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
QtEasingCurve::OutCirc26
Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
QtEasingCurve::InOutCirc27
Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInCirc28
Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InElastic29
Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. The peak amplitude can be set with the amplitude parameter, and the period of decay by the period parameter.
QtEasingCurve::OutElastic30
Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity. The peak amplitude can be set with the amplitude parameter, and the period of decay by the period parameter.
QtEasingCurve::InOutElastic31
Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInElastic32
Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InBack33
Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
QtEasingCurve::OutBack34
Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
QtEasingCurve::InOutBack35
Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInBack36
Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InBounce37
Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
QtEasingCurve::OutBounce38
Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
QtEasingCurve::InOutBounce39
Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInBounce40
Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::Custom45This is returned if the user have specified a custom curve type with setCustomType(). Note that you cannot call setType() with this value, but type() can return it.


Member Function Documentation

QtEasingCurve::QtEasingCurve ( Type type = Linear )

Constructs an easing curve of the given type.

QtEasingCurve::QtEasingCurve ( const QtEasingCurve & other )

Construct a copy of other.

QtEasingCurve::~QtEasingCurve ()

Destructor.

qreal QtEasingCurve::amplitude () const

Returns the amplitude. This is not applicable for all curve types. It is only applicable for bounce and elastic curves (curves of type() QtEasingCurve::InBounce, QtEasingCurve::OutBounce, QtEasingCurve::InOutBounce, QtEasingCurve::OutInBounce, QtEasingCurve::InElastic, QtEasingCurve::OutElastic, QtEasingCurve::InOutElastic or QtEasingCurve::OutInElastic).

See also setAmplitude().

EasingFunction QtEasingCurve::customType () const

Returns the function pointer to the custom easing curve. If type() does not return QtEasingCurve::Custom, this function will return 0.

See also setCustomType().

qreal QtEasingCurve::overshoot () const

Returns the overshoot. This is not applicable for all curve types. It is only applicable if type() is QtEasingCurve::InBack, QtEasingCurve::OutBack, QtEasingCurve::InOutBack or QtEasingCurve::OutInBack.

See also setOvershoot().

qreal QtEasingCurve::period () const

Returns the period. This is not applicable for all curve types. It is only applicable if type() is QtEasingCurve::InElastic, QtEasingCurve::OutElastic, QtEasingCurve::InOutElastic or QtEasingCurve::OutInElastic.

See also setPeriod().

void QtEasingCurve::setAmplitude ( qreal amplitude )

Sets the amplitude to amplitude.

This will set the amplitude of the bounce or the amplitude of the elastic "spring" effect. The higher the number, the higher the amplitude.

See also amplitude().

void QtEasingCurve::setCustomType ( EasingFunction func )

Sets a custom easing curve that is defined by the user in the function func. The signature of the function is qreal myEasingFunction(qreal progress), where progress and the return value is considered to be normalized between 0 and 1. (In some cases the return value can be outside that range) After calling this function type() will return QtEasingCurve::Custom. func cannot be zero.

See also customType() and valueForProgress().

void QtEasingCurve::setOvershoot ( qreal overshoot )

Sets the overshoot to overshoot.

0 produces no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent.

See also overshoot().

void QtEasingCurve::setPeriod ( qreal period )

Sets the period to period. Setting a small period value will give a high frequency of the curve. A large period will give it a small frequency.

See also period().

void QtEasingCurve::setType ( Type type )

Sets the type of the easing curve to type.

See also type().

Type QtEasingCurve::type () const

Returns the type of the easing curve.

See also setType().

qreal QtEasingCurve::valueForProgress ( qreal progress ) const

Return the effective progress for the easing curve at progress. While progress must be between 0 and 1, the returned effective progress can be outside those bounds. For instance, QtEasingCurve::InBack will return negative values in the beginning of the function.

bool QtEasingCurve::operator!= ( const QtEasingCurve & other ) const

Compare this easing curve with other and returns true if they are not equal. It will also compare the properties of a curve.

See also operator==().

QtEasingCurve & QtEasingCurve::operator= ( const QtEasingCurve & other )

Copy other.

bool QtEasingCurve::operator== ( const QtEasingCurve & other ) const

Compare this easing curve with other and returns true if they are equal. It will also compare the properties of a curve.


Copyright © 2009 Nokia Trademarks
Qt Solutions