![]() |
Home |
The QtEasingCurve class provides easing curves for controlling animation. More...
#include <QtEasingCurve>
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));
The type of easing curve.
Constant | Value | Description |
---|---|---|
QtEasingCurve::Linear | 0 | Easing equation function for a simple linear tweening, with no easing. |
QtEasingCurve::InQuad | 1 | Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity. |
QtEasingCurve::OutQuad | 2 | Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity. |
QtEasingCurve::InOutQuad | 3 | Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration. |
QtEasingCurve::OutInQuad | 4 | Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration. |
QtEasingCurve::InCubic | 5 | Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity. |
QtEasingCurve::OutCubic | 6 | Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity. |
QtEasingCurve::InOutCubic | 7 | Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration. |
QtEasingCurve::OutInCubic | 8 | Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration. |
QtEasingCurve::InQuart | 9 | Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity. |
QtEasingCurve::OutQuart | 10 | Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity. |
QtEasingCurve::InOutQuart | 11 | Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration. |
QtEasingCurve::OutInQuart | 12 | Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration. |
QtEasingCurve::InQuint | 13 | Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity. |
QtEasingCurve::OutQuint | 14 | Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity. |
QtEasingCurve::InOutQuint | 15 | Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration. |
QtEasingCurve::OutInQuint | 16 | Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration. |
QtEasingCurve::InSine | 17 | Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity. |
QtEasingCurve::OutSine | 18 | Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity. |
QtEasingCurve::InOutSine | 19 | Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration. |
QtEasingCurve::OutInSine | 20 | Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration. |
QtEasingCurve::InExpo | 21 | Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity. |
QtEasingCurve::OutExpo | 22 | Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity. |
QtEasingCurve::InOutExpo | 23 | Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration. |
QtEasingCurve::OutInExpo | 24 | Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration. |
QtEasingCurve::InCirc | 25 | Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity. |
QtEasingCurve::OutCirc | 26 | Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity. |
QtEasingCurve::InOutCirc | 27 | Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration. |
QtEasingCurve::OutInCirc | 28 | Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration. |
QtEasingCurve::InElastic | 29 | 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.
Constant | Value | Description |
---|---|---|
QtEasingCurve::OutElastic | 30 | 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.
Constant | Value | Description |
---|---|---|
QtEasingCurve::InOutElastic | 31 | Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration. |
QtEasingCurve::OutInElastic | 32 | Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration. |
QtEasingCurve::InBack | 33 | Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. |
QtEasingCurve::OutBack | 34 | Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity. |
QtEasingCurve::InOutBack | 35 | 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::OutInBack | 36 | 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::OutBounce | 38 | Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity. |
QtEasingCurve::InBounce | 37 | Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity. |
QtEasingCurve::InOutBounce | 39 | Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration. |
QtEasingCurve::OutInBounce | 40 | Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration. |
Constructs an easing curve of the given type.
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.
Construct a copy of other.
Destructor.
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().
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().
Sets the amplitude to amplitude.
See also amplitude().
Sets the period to period.
See also period().
Sets the type of the easing curve to type.
See also type().
Returns the type of the easing curve.
See also setType().
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.
Copy other.
Compare this easing curve with other.
Copyright © 2008 Nokia | Trademarks | Qt Solutions |