PySide6.QtCore.QEasingCurve

class QEasingCurve

The QEasingCurve class provides easing curves for controlling animation. More

Added in version 4.6.

Synopsis

Methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

Warning

This section contains snippets that were automatically translated from C++ to Python and may contain errors.

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 QEasingCurve class is usually used in conjunction with the QVariantAnimation and QPropertyAnimation classes but can be used on its own. It is usually used to accelerate the interpolation from zero velocity (ease in) or decelerate to zero velocity (ease out). Ease in and ease out can also be combined in the same easing curve.

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,

easing = QEasingCurve(QEasingCurve.InOutQuad)
for t in range(0.0, 1.0):
    qWarning() << "Effective progress" << t << "is"
               << easing.valueForProgress(t)

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

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

animation = QPropertyAnimation()
animation.setStartValue(0)
animation.setEndValue(1000)
animation.setDuration(1000)
animation.setEasingCurve(QEasingCurve.InOutQuad)

The ability to set an amplitude, overshoot, or period depends on the QEasingCurve type. Amplitude access is available to curves that 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 interpolate beyond the end points and return to the end point, acting similar to a boomerang.

The Easing Curves Example contains samples of QEasingCurve types and lets you change the curve settings.

class Type

The type of easing curve.

Constant

Description

QEasingCurve.Linear

../../_images/qeasingcurve-linear.png

Easing curve for a linear (t) function: velocity is constant.

Constant

Description

QEasingCurve.InQuad

../../_images/qeasingcurve-inquad.png

Easing curve for a quadratic (t^2) function: accelerating from zero velocity.

Constant

Description

QEasingCurve.OutQuad

../../_images/qeasingcurve-outquad.png

Easing curve for a quadratic (t^2) function: decelerating to zero velocity.

Constant

Description

QEasingCurve.InOutQuad

../../_images/qeasingcurve-inoutquad.png

Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration.

Constant

Description

QEasingCurve.OutInQuad

../../_images/qeasingcurve-outinquad.png

Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration.

Constant

Description

QEasingCurve.InCubic

../../_images/qeasingcurve-incubic.png

Easing curve for a cubic (t^3) function: accelerating from zero velocity.

Constant

Description

QEasingCurve.OutCubic

../../_images/qeasingcurve-outcubic.png

Easing curve for a cubic (t^3) function: decelerating to zero velocity.

Constant

Description

QEasingCurve.InOutCubic

../../_images/qeasingcurve-inoutcubic.png

Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration.

Constant

Description

QEasingCurve.OutInCubic

../../_images/qeasingcurve-outincubic.png

Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration.

Constant

Description

QEasingCurve.InQuart

../../_images/qeasingcurve-inquart.png

Easing curve for a quartic (t^4) function: accelerating from zero velocity.

Constant

Description

QEasingCurve.OutQuart

../../_images/qeasingcurve-outquart.png

Easing curve for a quartic (t^4) function: decelerating to zero velocity.

Constant

Description

QEasingCurve.InOutQuart

../../_images/qeasingcurve-inoutquart.png

Easing curve for a quartic (t^4) function: acceleration until halfway, then deceleration.

Constant

Description

QEasingCurve.OutInQuart

../../_images/qeasingcurve-outinquart.png

Easing curve for a quartic (t^4) function: deceleration until halfway, then acceleration.

Constant

Description

QEasingCurve.InQuint

../../_images/qeasingcurve-inquint.png

Easing curve for a quintic (t^5) easing in: accelerating from zero velocity.

Constant

Description

QEasingCurve.OutQuint

../../_images/qeasingcurve-outquint.png

Easing curve for a quintic (t^5) function: decelerating to zero velocity.

Constant

Description

QEasingCurve.InOutQuint

../../_images/qeasingcurve-inoutquint.png

Easing curve for a quintic (t^5) function: acceleration until halfway, then deceleration.

Constant

Description

QEasingCurve.OutInQuint

../../_images/qeasingcurve-outinquint.png

Easing curve for a quintic (t^5) function: deceleration until halfway, then acceleration.

Constant

Description

QEasingCurve.InSine

../../_images/qeasingcurve-insine.png

Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity.

Constant

Description

QEasingCurve.OutSine

../../_images/qeasingcurve-outsine.png

Easing curve for a sinusoidal (sin(t)) function: decelerating to zero velocity.

Constant

Description

QEasingCurve.InOutSine

../../_images/qeasingcurve-inoutsine.png

Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration.

Constant

Description

QEasingCurve.OutInSine

../../_images/qeasingcurve-outinsine.png

Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration.

Constant

Description

QEasingCurve.InExpo

../../_images/qeasingcurve-inexpo.png

Easing curve for an exponential (2^t) function: accelerating from zero velocity.

Constant

Description

QEasingCurve.OutExpo

../../_images/qeasingcurve-outexpo.png

Easing curve for an exponential (2^t) function: decelerating to zero velocity.

Constant

Description

QEasingCurve.InOutExpo

../../_images/qeasingcurve-inoutexpo.png

Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration.

Constant

Description

QEasingCurve.OutInExpo

../../_images/qeasingcurve-outinexpo.png

Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration.

Constant

Description

QEasingCurve.InCirc

../../_images/qeasingcurve-incirc.png

Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity.

Constant

Description

QEasingCurve.OutCirc

../../_images/qeasingcurve-outcirc.png

Easing curve for a circular (sqrt(1-t^2)) function: decelerating to zero velocity.

Constant

Description

QEasingCurve.InOutCirc

../../_images/qeasingcurve-inoutcirc.png

Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration.

Constant

Description

QEasingCurve.OutInCirc

../../_images/qeasingcurve-outincirc.png

Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration.

Constant

Description

QEasingCurve.InElastic

../../_images/qeasingcurve-inelastic.png

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.

Constant

Description

QEasingCurve.OutElastic

../../_images/qeasingcurve-outelastic.png

Easing curve for an elastic (exponentially decaying sine wave) function: decelerating to zero velocity. The peak amplitude can be set with the amplitude parameter, and the period of decay by the period parameter.

Constant

Description

QEasingCurve.InOutElastic

../../_images/qeasingcurve-inoutelastic.png

Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration.

Constant

Description

QEasingCurve.OutInElastic

../../_images/qeasingcurve-outinelastic.png

Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration.

Constant

Description

QEasingCurve.InBack

../../_images/qeasingcurve-inback.png

Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.

Constant

Description

QEasingCurve.OutBack

../../_images/qeasingcurve-outback.png

Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity.

Constant

Description

QEasingCurve.InOutBack

../../_images/qeasingcurve-inoutback.png

Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.

Constant

Description

QEasingCurve.OutInBack

../../_images/qeasingcurve-outinback.png

Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.

Constant

Description

QEasingCurve.InBounce

../../_images/qeasingcurve-inbounce.png

Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity.

Constant

Description

QEasingCurve.OutBounce

../../_images/qeasingcurve-outbounce.png

Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity.

Constant

Description

QEasingCurve.InOutBounce

../../_images/qeasingcurve-inoutbounce.png

Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration.

Constant

Description

QEasingCurve.OutInBounce

../../_images/qeasingcurve-outinbounce.png

Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration.

Constant

Description

QEasingCurve.BezierSpline

Allows defining a custom easing curve using a cubic bezier spline

QEasingCurve.TCBSpline

Allows defining a custom easing curve using a TCB spline

QEasingCurve.Custom

This is returned if the user specified a custom curve type with setCustomType() . Note that you cannot call setType() with this value, but type() can return it.

__init__([type=QEasingCurve.Type.Linear])
Parameters:

typeType

Constructs an easing curve of the given type.

__init__(other)
Parameters:

otherQEasingCurve

Construct a copy of other.

addCubicBezierSegment(c1, c2, endPoint)
Parameters:

Adds a segment of a cubic bezier spline to define a custom easing curve. It is only applicable if type() is BezierSpline . Note that the spline implicitly starts at (0.0, 0.0) and has to end at (1.0, 1.0) to be a valid easing curve. c1 and c2 are the control points used for drawing the curve. endPoint is the endpoint of the curve.

addTCBSegment(nextPoint, t, c, b)
Parameters:
  • nextPointQPointF

  • t – float

  • c – float

  • b – float

Adds a segment of a TCB bezier spline to define a custom easing curve. It is only applicable if type() is TCBSpline . The spline has to start explicitly at (0.0, 0.0) and has to end at (1.0, 1.0) to be a valid easing curve. The tension t changes the length of the tangent vector. The continuity c changes the sharpness in change between the tangents. The bias b changes the direction of the tangent vector. nextPoint is the sample position. All three parameters are valid between -1 and 1 and define the tangent of the control point. If all three parameters are 0 the resulting spline is a Catmull-Rom spline. The begin and endpoint always have a bias of -1 and 1, since the outer tangent is not defined.

amplitude()
Return type:

float

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

See also

setAmplitude()

customType()
Return type:

object

__ne__(rhs)
Parameters:

rhsQEasingCurve

Return type:

bool

Compares easing curve lhs with rhs and returns true if they are not equal; otherwise returns false. It will also compare the properties of the curves.

See also

operator==()

__eq__(rhs)
Parameters:

rhsQEasingCurve

Return type:

bool

Compares easing curve lhs with rhs and returns true if they are equal; otherwise returns false. It will also compare the properties of the curves.

overshoot()
Return type:

float

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

See also

setOvershoot()

period()
Return type:

float

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

See also

setPeriod()

setAmplitude(amplitude)
Parameters:

amplitude – float

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()

setCustomType(callable)
Parameters:

callable – object

setOvershoot(overshoot)
Parameters:

overshoot – float

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()

setPeriod(period)
Parameters:

period – float

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()

setType(type)
Parameters:

typeType

Sets the type of the easing curve to type.

See also

type()

swap(other)
Parameters:

otherQEasingCurve

Swaps curve other with this curve. This operation is very fast and never fails.

toCubicSpline()
Return type:

.list of QPointF

Returns the cubicBezierSpline that defines a custom easing curve. If the easing curve does not have a custom bezier easing curve the list is empty.

type()
Return type:

Type

Returns the type of the easing curve.

See also

setType()

valueForProgress(progress)
Parameters:

progress – float

Return type:

float

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