![]() |
CopperSpice API
2.0.0
|
The QEasingCurve class provides easing curves for controlling animation. More...
Public Typedefs | |
| using | EasingFunction = qreal (*)(qreal progress) |
Public Types | |
| enum | Type |
Public Methods | |
| QEasingCurve (const QEasingCurve &other) | |
| QEasingCurve (QEasingCurve &&other) | |
| QEasingCurve (Type type=Type::Linear) | |
| ~QEasingCurve () | |
| qreal | amplitude () const |
| EasingFunction | customType () const |
| bool | operator!= (const QEasingCurve &other) const |
| QEasingCurve & | operator= (const QEasingCurve &other) |
| QEasingCurve & | operator= (QEasingCurve &&other) |
| bool | operator== (const QEasingCurve &other) const |
| qreal | overshoot () const |
| qreal | period () const |
| void | setAmplitude (qreal amplitude) |
| void | setCustomType (EasingFunction func) |
| void | setOvershoot (qreal overshoot) |
| void | setPeriod (qreal period) |
| void | setType (Type type) |
| void | swap (QEasingCurve &other) |
| Type | type () const |
| qreal | valueForProgress (qreal progress) const |
Friends | |
| QDataStream & | operator<< (QDataStream &stream, const QEasingCurve &easing) |
Related Functions | |
These are not member functions | |
| QDataStream & | operator>> (QDataStream &stream, const QEasingCurve &easing) |
The QEasingCurve class provides easing curves for controlling animation.
An easing curve is a function which controls the position of an object in an animation. The purpose is to make the transitions smoother so the motion looks more realistic. This class is normally used in combination with QVariantAnimation and QPropertyAnimation.
The primary method in this class is valueForProgress() which calculates the position of an object being animated. A floating point number between the values of 0 and 1 must be passed to this method. This value represents a point in time. This method should be called repeatedly with the passed value incrementing.
The following example shows how to use a QPropertyAnimation with a QEasingCurve to control the progress of the animation.
The ability to set an amplitude, overshoot, or period depends on the QEasingCurve type. Amplitude access is available to curves which behave as springs such as elastic and bounce curves. Changing the amplitude changes the height of the curve. Period access is only available to elastic curves and setting a higher period slows the rate of bounce. Only curves that have "boomerang" behaviors such as the InBack, OutBack, InOutBack, and OutInBack have overshoot settings. These curves will extend beyond the end points and return to the end point, acting similar to a boomerang.
| enum QEasingCurve::Type |
The type of easing curve.
| Constant | Value | Description |
|---|---|---|
QEasingCurve::Linear | 0 | Easing curve for a linear (t) function: velocity is constant. |
QEasingCurve::InQuad | 1 | Easing curve for a quadratic (t^2) function: accelerating from zero velocity. |
QEasingCurve::OutQuad | 2 | Easing curve for a quadratic (t^2) function: decelerating to zero velocity. |
QEasingCurve::InOutQuad | 3 | Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration. |
QEasingCurve::OutInQuad | 4 | Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration. |
QEasingCurve::InCubic | 5 | Easing curve for a cubic (t^3) function: accelerating from zero velocity. |
QEasingCurve::OutCubic | 6 | Easing curve for a cubic (t^3) function: decelerating to zero velocity. |
QEasingCurve::InOutCubic | 7 | Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration. |
QEasingCurve::OutInCubic | 8 | Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration. |
QEasingCurve::InQuart | 9 | Easing curve for a quartic (t^4) function: accelerating from zero velocity. |
QEasingCurve::OutQuart | 10 | Easing curve for a quartic (t^4) function: decelerating to zero velocity. |
QEasingCurve::InOutQuart | 11 | Easing curve for a quartic (t^4) function: acceleration until halfway, then deceleration. |
QEasingCurve::OutInQuart | 12 | Easing curve for a quartic (t^4) function: deceleration until halfway, then acceleration. |
QEasingCurve::InQuint | 13 | Easing curve for a quintic (t^5) easing in: accelerating from zero velocity. |
QEasingCurve::OutQuint | 14 | Easing curve for a quintic (t^5) function: decelerating to zero velocity. |
QEasingCurve::InOutQuint | 15 | Easing curve for a quintic (t^5) function: acceleration until halfway, then deceleration. |
QEasingCurve::OutInQuint | 16 | Easing curve for a quintic (t^5) function: deceleration until halfway, then acceleration. |
QEasingCurve::InSine | 17 | Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity. |
QEasingCurve::OutSine | 18 | Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity. |
QEasingCurve::InOutSine | 19 | Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration. |
QEasingCurve::OutInSine | 20 | Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration. |
QEasingCurve::InExpo | 21 | Easing curve for an exponential (2^t) function: accelerating from zero velocity. |
QEasingCurve::OutExpo | 22 | Easing curve for an exponential (2^t) function: decelerating from zero velocity. |
QEasingCurve::InOutExpo | 23 | Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration. |
QEasingCurve::OutInExpo | 24 | Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration. |
QEasingCurve::InCirc | 25 | Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity. |
QEasingCurve::OutCirc | 26 | Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity. |
QEasingCurve::InOutCirc | 27 | Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration. |
QEasingCurve::OutInCirc | 28 | Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration. |
QEasingCurve::InElastic | 29 | Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity. The peak amplitude can be set with the amplitude parameter, and the period of decay by the period parameter. |
QEasingCurve::OutElastic | 30 | Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity. The peak amplitude can be set with the amplitude parameter, and the period of decay by the period parameter. |
QEasingCurve::InOutElastic | 31 | Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration. |
QEasingCurve::OutInElastic | 32 | Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration. |
QEasingCurve::InBack | 33 | Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. |
QEasingCurve::OutBack | 34 | Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity. |
QEasingCurve::InOutBack | 35 | Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration. |
QEasingCurve::OutInBack | 36 | Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration. |
QEasingCurve::InBounce | 37 | Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity. |
QEasingCurve::OutBounce | 38 | Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity. |
QEasingCurve::InOutBounce | 39 | Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration. |
QEasingCurve::OutInBounce | 40 | Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration. |
QEasingCurve::Custom | 45 | This is returned if the user specified a custom curve type with setCustomType(). You can not call setType() with this value, but type() can return it. |
| QEasingCurve::QEasingCurve | ( | Type | type = Type::Linear | ) |
Constructs a new QEasingCurve using the given type.
| QEasingCurve::QEasingCurve | ( | const QEasingCurve & | other | ) |
Copy constructs a new QEasingCurve from other.
|
inline |
Move constructs a new QEasingCurve from other.
| QEasingCurve::~QEasingCurve | ( | ) |
Destroys the current QEasingCurve.
| qreal QEasingCurve::amplitude | ( | ) | const |
Returns the amplitude of the current QEasingCurve. This does not apply to all values in QEasingCurve::Type, only to bounce and elastic curves types.
| EasingFunction QEasingCurve::customType | ( | ) | const |
Returns a function pointer to the custom easing curve. If type() does not return QEasingCurve::Custom, this method will return a nullptr.
|
inline |
Compares this QEasingCurve with other and returns true if they are not equal.
|
inline |
Copy assigns from other and returns a reference to this QEasingCurve.
|
inline |
Move assigns from other and returns a reference to this QEasingCurve.
| bool QEasingCurve::operator== | ( | const QEasingCurve & | other | ) | const |
Compares the current QEasingCurve with other and returns true if they are equal. I
| qreal QEasingCurve::overshoot | ( | ) | const |
Returns the overshoot value. This is the how far past the end point the position can travel. This does not apply to all curve types, only when the type() is QEasingCurve::InBack, QEasingCurve::OutBack, QEasingCurve::InOutBack, or QEasingCurve::OutInBack.
| qreal QEasingCurve::period | ( | ) | const |
Returns the period. This does not apply to all curve types, only when the type() is QEasingCurve::InElastic, QEasingCurve::OutElastic, QEasingCurve::InOutElastic or QEasingCurve::OutInElastic.
| void QEasingCurve::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.
| void QEasingCurve::setCustomType | ( | EasingFunction | func | ) |
Sets a custom easing curve which is defined by the function func. The signature of the custom function must match the signature shown below. The range for progress and the return value is normalized between 0 and 1. The value for func can not be a nullptr.
| void QEasingCurve::setOvershoot | ( | qreal | overshoot | ) |
Sets the overshoot to overshoot. A value of 0 produces no overshoot. If you do not call this method, the overshoot value will be 1.70158 which will produce an overshoot of 10 percent.
| void QEasingCurve::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.
|
inline |
Swaps other with this QEasingCurve. This operation is very fast and never fails.
| Type QEasingCurve::type | ( | ) | const |
Returns the QEasingCurve::Type for this QEasingCurve.
Return the progress for this QEasingCurve at progress. While progress must be between 0 and 1, the returned progress can be outside those bounds. For instance, if the QEasingCurve::Type is QEasingCurve::InBack then progress will return negative values at the beginning of the curve.
|
friend |
Writes the given easing to the stream. Returns a reference to the stream.
Refer to Serializing Data Types for additional information.
|
related |
Reads from the stream into the given easing. Returns a reference to the stream.
Refer to Serializing Data Types for additional information.