[][src]Struct qt_core::QEasingCurve

#[repr(C)]
pub struct QEasingCurve { /* fields omitted */ }

The QEasingCurve class provides easing curves for controlling animation.

C++ class: QEasingCurve.

C++ documentation:

The QEasingCurve 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 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,

QEasingCurve easing(QEasingCurve::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 QPropertyAnimation, the associated easing curve will be used to control the progress of the interpolation between startValue and endValue:

QPropertyAnimation animation; 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.

Methods

impl QEasingCurve[src]

pub unsafe fn add_cubic_bezier_segment(
    &mut self,
    c1: impl CastInto<Ref<QPointF>>,
    c2: impl CastInto<Ref<QPointF>>,
    end_point: impl CastInto<Ref<QPointF>>
)
[src]

Adds a segment of a cubic bezier spline to define a custom easing curve. It is only applicable if type() is QEasingCurve::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.

Calls C++ function: void QEasingCurve::addCubicBezierSegment(const QPointF& c1, const QPointF& c2, const QPointF& endPoint).

C++ documentation:

Adds a segment of a cubic bezier spline to define a custom easing curve. It is only applicable if type() is QEasingCurve::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.

pub unsafe fn add_t_c_b_segment(
    &mut self,
    next_point: impl CastInto<Ref<QPointF>>,
    t: c_double,
    c: c_double,
    b: c_double
)
[src]

Adds a segment of a TCB bezier spline to define a custom easing curve. It is only applicable if type() is QEasingCurve::TCBSpline. The spline has to start explitly 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.

Calls C++ function: void QEasingCurve::addTCBSegment(const QPointF& nextPoint, double t, double c, double b).

C++ documentation:

Adds a segment of a TCB bezier spline to define a custom easing curve. It is only applicable if type() is QEasingCurve::TCBSpline. The spline has to start explitly 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.

pub unsafe fn amplitude(&self) -> c_double[src]

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

Calls C++ function: double QEasingCurve::amplitude() const.

C++ documentation:

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

See also setAmplitude().

pub unsafe fn copy_from(
    &mut self,
    other: impl CastInto<Ref<QEasingCurve>>
) -> MutRef<QEasingCurve>
[src]

Copy other.

Calls C++ function: QEasingCurve& QEasingCurve::operator=(const QEasingCurve& other).

C++ documentation:

Copy other.

pub unsafe fn custom_type(
    &self
) -> Option<extern "C" fn(_: c_double) -> c_double>
[src]

Returns the function pointer to the custom easing curve. If type() does not return QEasingCurve::Custom, this function will return 0.

Calls C++ function: double (*FN_PTR)(double) QEasingCurve::customType() const.

C++ documentation:

Returns the function pointer to the custom easing curve. If type() does not return QEasingCurve::Custom, this function will return 0.

See also setCustomType().

pub unsafe fn new_1a(type_: Type) -> CppBox<QEasingCurve>[src]

Constructs an easing curve of the given type.

Calls C++ function: [constructor] void QEasingCurve::QEasingCurve(QEasingCurve::Type type = …).

C++ documentation:

Constructs an easing curve of the given type.

pub unsafe fn new_0a() -> CppBox<QEasingCurve>[src]

The QEasingCurve class provides easing curves for controlling animation.

Calls C++ function: [constructor] void QEasingCurve::QEasingCurve().

C++ documentation:

The QEasingCurve 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 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,

QEasingCurve easing(QEasingCurve::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 QPropertyAnimation, the associated easing curve will be used to control the progress of the interpolation between startValue and endValue:

QPropertyAnimation animation; 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.

pub unsafe fn new_copy(
    other: impl CastInto<Ref<QEasingCurve>>
) -> CppBox<QEasingCurve>
[src]

Construct a copy of other.

Calls C++ function: [constructor] void QEasingCurve::QEasingCurve(const QEasingCurve& other).

C++ documentation:

Construct a copy of other.

pub unsafe fn overshoot(&self) -> c_double[src]

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

Calls C++ function: double QEasingCurve::overshoot() const.

C++ documentation:

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

See also setOvershoot().

pub unsafe fn period(&self) -> c_double[src]

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

Calls C++ function: double QEasingCurve::period() const.

C++ documentation:

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

See also setPeriod().

pub unsafe fn set_amplitude(&mut self, amplitude: c_double)[src]

Sets the amplitude to amplitude.

Calls C++ function: void QEasingCurve::setAmplitude(double amplitude).

C++ documentation:

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

pub unsafe fn set_custom_type(
    &mut self,
    func: Option<extern "C" fn(_: c_double) -> c_double>
)
[src]

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 are 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 QEasingCurve::Custom. func cannot be zero.

Calls C++ function: void QEasingCurve::setCustomType(double (*FN_PTR)(double) func).

C++ documentation:

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 are 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 QEasingCurve::Custom. func cannot be zero.

See also customType() and valueForProgress().

pub unsafe fn set_overshoot(&mut self, overshoot: c_double)[src]

Sets the overshoot to overshoot.

Calls C++ function: void QEasingCurve::setOvershoot(double overshoot).

C++ documentation:

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

pub unsafe fn set_period(&mut self, period: c_double)[src]

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.

Calls C++ function: void QEasingCurve::setPeriod(double period).

C++ documentation:

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

pub unsafe fn set_type(&mut self, type_: Type)[src]

Sets the type of the easing curve to type.

Calls C++ function: void QEasingCurve::setType(QEasingCurve::Type type).

C++ documentation:

Sets the type of the easing curve to type.

See also type().

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn swap(&mut self, other: impl CastInto<MutRef<QEasingCurve>>)[src]

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

Calls C++ function: void QEasingCurve::swap(QEasingCurve& other).

C++ documentation:

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

This function was introduced in Qt 5.0.

pub unsafe fn to_cubic_spline(&self) -> CppBox<QVectorOfQPointF>[src]

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.

Calls C++ function: QVector<QPointF> QEasingCurve::toCubicSpline() const.

C++ documentation:

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.

This function was introduced in Qt 5.0.

pub unsafe fn type_(&self) -> Type[src]

Returns the type of the easing curve.

Calls C++ function: QEasingCurve::Type QEasingCurve::type() const.

C++ documentation:

Returns the type of the easing curve.

See also setType().

pub unsafe fn value_for_progress(&self, progress: c_double) -> c_double[src]

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, QEasingCurve::InBack will return negative values in the beginning of the function.

Calls C++ function: double QEasingCurve::valueForProgress(double progress) const.

C++ documentation:

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, QEasingCurve::InBack will return negative values in the beginning of the function.

Trait Implementations

impl PartialEq<Ref<QEasingCurve>> for QEasingCurve[src]

fn eq(&self, other: &Ref<QEasingCurve>) -> bool[src]

Compare this easing curve with other and returns true if they are equal. It will also compare the properties of a curve.

Calls C++ function: bool QEasingCurve::operator==(const QEasingCurve& other) const.

C++ documentation:

Compare this easing curve with other and returns true if they are equal. It will also compare the properties of a curve.

impl CppDeletable for QEasingCurve[src]

unsafe fn delete(&mut self)[src]

Destructor.

Calls C++ function: [destructor] void QEasingCurve::~QEasingCurve().

C++ documentation:

Destructor.

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]