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 QtAnimation class, but can be used on its own.

To calculate the speed of the interpolation, the easing curve provides the function valueForStep(), where the step 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 step = 0.0; step < 1.0; step+=0.1)
     qWarning() << "Effective progress" << step << " is
                << easing.valueForStep(step);

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

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

 QtAnimation animation;
 animation.setStartValue(0);
 animation.setEndValue(1000);
 animation.setDuration(1000);
 animation.setEasing(QtEasingCurve(QtEasingCurve::InOutQuad));

Member Type Documentation

enum QtEasingCurve::Type

The type of easing curve.

ConstantValueDescription
QtEasingCurve::Linear0Easing equation function for a simple linear tweening, with no easing.
QtEasingCurve::InQuad1Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
QtEasingCurve::OutQuad2Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
QtEasingCurve::InOutQuad3Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInQuad4Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InCubic5Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
QtEasingCurve::OutCubic6Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
QtEasingCurve::InOutCubic7Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInCubic8Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InQuart9Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
QtEasingCurve::OutQuart10Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
QtEasingCurve::InOutQuart11Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInQuart12Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InQuint13Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
QtEasingCurve::OutQuint14Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
QtEasingCurve::InOutQuint15Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInQuint16Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InSine17Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
QtEasingCurve::OutSine18Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
QtEasingCurve::InOutSine19Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInSine20Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InExpo21Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
QtEasingCurve::OutExpo22Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
QtEasingCurve::InOutExpo23Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInExpo24Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InCirc25Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
QtEasingCurve::OutCirc26Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
QtEasingCurve::InOutCirc27Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInCirc28Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InElastic29Easing 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.

ConstantValueDescription
QtEasingCurve::OutElastic30Easing 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.

ConstantValueDescription
QtEasingCurve::InOutElastic31Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInElastic32Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::InBack33Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
QtEasingCurve::OutBack34Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
QtEasingCurve::InOutBack35Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInBack36Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
QtEasingCurve::OutBounce38Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
QtEasingCurve::InBounce37Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
QtEasingCurve::InOutBounce39Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
QtEasingCurve::OutInBounce40Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.


Member Function Documentation

QtEasingCurve::QtEasingCurve ( Type type = Linear )

Constructs an easing curve of the given type.

QtEasingCurve::QtEasingCurve ( Type type, qreal amplitude, qreal period )

Constructs an easing curve of the given type, with the given amplitude and period. You only have to use this constructor if type is one of QtEasingCurve::InElastic, QtEasingCurve::OutElastic, QtEasingCurve::InBounce or QtEasingCurve::OutBounce.

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 if type() is one of QtEasingCurve::InElastic, QtEasingCurve::OutElastic, QtEasingCurve::InBounce or QtEasingCurve::OutBounce.

See also setAmplitude().

qreal QtEasingCurve::period () const

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

See also setPeriod().

void QtEasingCurve::setAmplitude ( qreal amplitude )

Sets the amplitude to amplitude.

See also amplitude().

void QtEasingCurve::setPeriod ( qreal period )

Sets the period to period.

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::valueForStep ( qreal step ) const

Return the effective progress for the easing curve at step. While step 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

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

Copy other.

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

Compare this easing curve with other.


Copyright © 2008 Nokia Trademarks
Qt Solutions