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 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);
This is a typedef for a pointer to a function with the following signature:
qreal myEasingFunction(qreal progress);
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. |
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. |
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::InBounce | 37 | Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity. |
QtEasingCurve::OutBounce | 38 | Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating 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. |
QtEasingCurve::Custom | 45 | This 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. |
Constructs an easing curve of the given type.
Construct a copy of other.
Destructor.
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().
Returns the function pointer to the custom easing curve. If type() does not return QtEasingCurve::Custom, this function will return 0.
See also setCustomType().
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().
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().
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().
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().
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().
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().
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 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.
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==().
Copy other.
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 |