265#ifndef QT_NO_DEBUG_STREAM
266#include <QtCore/qdebug.h>
267#include <QtCore/qstring.h>
270#ifndef QT_NO_DATASTREAM
271#include <QtCore/qdatastream.h>
274#include <QtCore/qpoint.h>
275#include <QtCore/qlist.h>
331 qreal overshoot = 1.70158)
403#include "../../3rdparty/easing/easing.cpp"
515 int currentSegment = 0;
523 singleCubicBezier = &
_curves.data()[currentSegment];
548 qWarning(
"QEasingCurve: Invalid bezier curve");
566 const qreal p0 = singleCubicBezier.
p0y;
569 const qreal p3 = singleCubicBezier.
p3y;
576 const qreal s_cubic = s_squared *
s;
577 const qreal t_cubic = t_squared *
t;
579 return s_cubic * p0 + 3 * s_squared *
t *
p1 + 3 *
s * t_squared *
p2 + t_cubic * p3;
584 const qreal p0 = singleCubicBezier.
p0x;
587 const qreal p3 = singleCubicBezier.
p3x;
594 const qreal s_cubic = s_squared *
s;
595 const qreal t_cubic = t_squared *
t;
597 return s_cubic * p0 + 3 * s_squared *
t *
p1 + 3 *
s * t_squared *
p2 + t_cubic * p3;
602 const qreal p0 = singleCubicBezier.
p0x;
605 const qreal p3 = singleCubicBezier.
p3x;
609 return -3*p0 + 3*
p1 + 6*p0*
t - 12*
p1*
t + 6*
p2*
t + 3*p3*t_squared - 3*p0*t_squared + 9*
p1*t_squared - 9*
p2*t_squared;
623 const qreal f = t_cubic + t_cubic +
d;
625 t =
t * (t_cubic +
d +
d) /
f;
642 const unsigned int B1 = 709921077;
645 ux.i = (ux.i / 3 + B1);
657 const unsigned int B1 = 715094163;
659#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
668 ut.pt[h0] = hx / 3 + B1;
675 return std::sqrt(1-
x)*(1.5707963267948966192313216916398f +
x*(-0.213300989f +
x*(0.077980478f +
x*-0.02164095f)));
691 const qreal a = 0.405284735;
692 const qreal b = 1.27323954;
700 return 0.225 * (cos * -1 * cos - cos) + cos;
701 return 0.225 * (cos * cos - cos) + cos;
707 return 0.225 * (cos * 1 * -cos - cos) + cos;
708 return 0.225 * (cos * cos - cos) + cos;
713 return (
f >= -0.01 &&
f <= 1.01);
727 s1 = 0.463614 - 0.0347815 *
x + 0.00218245 * x_squared + 0.402421 * x_plus_one_sqrt;
731 s3 = 0.463614 + 0.402421 * one_minus_x_sqrt + 0.0347815 *
x + 0.00218245 * x_squared;
735 s2 = -0.401644 * one_minus_x_sqrt - 0.0686804 *
x + 0.401644 * x_plus_one_sqrt;
746 if (c < 0.000001 && c > -0.000001)
749 const qreal a_by3 =
a / 3.0;
754 const qreal q = 2.0 * a_cubic / 27.0 -
a *
b / 3.0 +
c;
758 const qreal D = 0.25 * q_squared + p_cubic / 27.0;
782 const qreal sqrtP = -3.0*
qSqrt(3.0) / (p_minus_sqrt *
p);
785 const qreal g = -
q * 0.5 * sqrtP;
817 const qreal p0 = singleCubicBezier.
p0x;
820 const qreal p3 = singleCubicBezier.
p3x;
822 const qreal factorT3 = p3 - p0 + 3 *
p1 - 3 *
p2;
823 const qreal factorT2 = 3 * p0 - 6 *
p1 + 3 *
p2;
824 const qreal factorT1 = -3 * p0 + 3 *
p1;
825 const qreal factorT0 = p0 -
x;
833 return -factorT0 / factorT1;
835 const qreal discriminant = factorT1 * factorT1 - 4.0 * factorT2 * factorT0;
836 if (discriminant < 0.0)
839 if (discriminant == 0.0)
840 return -factorT1 / (2.0 * factorT2);
842 const qreal solution1 = (-factorT1 + std::sqrt(discriminant)) / (2.0 * factorT2);
843 if (solution1 >= 0.0 && solution1 <= 1.0)
846 const qreal solution2 = (-factorT1 - std::sqrt(discriminant)) / (2.0 * factorT2);
847 if (solution2 >= 0.0 && solution2 <= 1.0)
853 const qreal a = factorT2 / factorT3;
854 const qreal b = factorT1 / factorT3;
855 const qreal c = factorT0 / factorT3;
875 qWarning(
"QEasingCurve: Invalid tcb curve");
910 return easeInElastic(
t,
a,
p);
912 return easeOutElastic(
t,
a,
p);
914 return easeInOutElastic(
t,
a,
p);
916 return easeOutInElastic(
t,
a,
p);
943 return easeInBounce(
t,
a);
945 return easeOutBounce(
t,
a);
947 return easeInOutBounce(
t,
a);
949 return easeOutInBounce(
t,
a);
981 return easeInBack(
t,
o);
983 return easeOutBack(
t,
o);
985 return easeInOutBack(
t,
o);
987 return easeOutInBack(
t,
o);
1002 return &easeOutQuad;
1004 return &easeInOutQuad;
1006 return &easeOutInQuad;
1008 return &easeInCubic;
1010 return &easeOutCubic;
1012 return &easeInOutCubic;
1014 return &easeOutInCubic;
1016 return &easeInQuart;
1018 return &easeOutQuart;
1020 return &easeInOutQuart;
1022 return &easeOutInQuart;
1024 return &easeInQuint;
1026 return &easeOutQuint;
1028 return &easeInOutQuint;
1030 return &easeOutInQuint;
1034 return &easeOutSine;
1036 return &easeInOutSine;
1038 return &easeOutInSine;
1042 return &easeOutExpo;
1044 return &easeInOutExpo;
1046 return &easeOutInExpo;
1050 return &easeOutCirc;
1052 return &easeInOutCirc;
1054 return &easeOutInCirc;
1057 return &easeInCurve;
1059 return &easeOutCurve;
1061 return &easeSineCurve;
1063 return &easeCosineCurve;
1168 }
else if (d_ptr->
config ||
other.d_ptr->config) {
1296 c_minusOne = tcbPoints.
at(
i - 2).
_point;
1297 b_0 = tcbPoints.
at(
i - 1).
_b;
1302 b_1 = tcbPoints.
at(
i).
_b;
1305 const qreal dx_0 = 0.5 * (1-t_0) * ((1 + b_0) * (1 + c_0) * (c0.
x() - c_minusOne.
x()) + (1- b_0) * (1 - c_0) * (c3.
x() - c0.
x()));
1306 const qreal dy_0 = 0.5 * (1-t_0) * ((1 + b_0) * (1 + c_0) * (c0.
y() - c_minusOne.
y()) + (1- b_0) * (1 - c_0) * (c3.
y() - c0.
y()));
1308 const qreal dx_1 = 0.5 * (1-t_1) * ((1 + b_1) * (1 - c_1) * (c3.
x() - c0.
x()) + (1 - b_1) * (1 + c_1) * (c4.
x() - c3.
x()));
1309 const qreal dy_1 = 0.5 * (1-t_1) * ((1 + b_1) * (1 - c_1) * (c3.
y() - c0.
y()) + (1 - b_1) * (1 + c_1) * (c4.
y() - c3.
y()));
1314 QPointF c1 = (3 * c0 + d_0) / 3;
1316 bezierPoints << c1 <<
c2 << c3;
1318 return bezierPoints;
1342 if (nextPoint ==
QPointF(1.0, 1.0)) {
1372 qreal period = -1.0;
1373 qreal overshoot = -1.0;
1381 bezierCurves = std::move(
config->_bezierCurves);
1382 tcbPoints = std::move(
config->_tcbPoints);
1388 if (
isConfigFunction(newType) || (amp != -1.0) || (period != -1.0) || (overshoot != -1.0) ||
1395 if (overshoot != -1.0)
1397 config->_bezierCurves = std::move(bezierCurves);
1398 config->_tcbPoints = std::move(tcbPoints);
1436 qWarning(
"Function pointer must not be null");
1461 progress = qBound<qreal>(0, progress, 1);
1463 return d_ptr->
func(progress);
1470#ifndef QT_NO_DEBUG_STREAM
1475 <<
"func:" <<
reinterpret_cast<const void *
>(
item.
d_ptr->func);
1485#ifndef QT_NO_DATASTREAM
1546#include "moc_qeasingcurve.cpp"
\inmodule QtCore\reentrant
QList< QPointF > _bezierCurves
virtual ~QEasingCurveFunction()
bool operator==(const QEasingCurveFunction &other) const
QEasingCurveFunction(QEasingCurve::Type type, qreal period=0.3, qreal amplitude=1.0, qreal overshoot=1.70158)
virtual qreal value(qreal t)
virtual QEasingCurveFunction * copy() const
QEasingCurveFunction * config
QEasingCurve::EasingFunction func
QEasingCurvePrivate(const QEasingCurvePrivate &other)
void setType_helper(QEasingCurve::Type)
EasingFunction customType() const
Returns the function pointer to the custom easing curve.
~QEasingCurve()
Destructor.
void setAmplitude(qreal amplitude)
Sets the amplitude to amplitude.
bool operator==(const QEasingCurve &other) const
Compare this easing curve with other and returns true if they are equal.
void setPeriod(qreal period)
Sets the period to period.
qreal period() const
Returns the period.
Type type() const
Returns the type of the easing curve.
qreal overshoot() const
Returns the overshoot.
qreal(* EasingFunction)(qreal progress)
This is a typedef for a pointer to a function with the following signature:
void addCubicBezierSegment(const QPointF &c1, const QPointF &c2, const QPointF &endPoint)
Adds a segment of a cubic bezier spline to define a custom easing curve.
QEasingCurve(Type type=Linear)
Constructs an easing curve of the given type.
void setOvershoot(qreal overshoot)
Sets the overshoot to overshoot.
void addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qreal b)
Adds a segment of a TCB bezier spline to define a custom easing curve.
void setCustomType(EasingFunction func)
Sets a custom easing curve that is defined by the user in the function func.
Type
The type of easing curve.
qreal valueForProgress(qreal progress) const
Return the effective progress for the easing curve at progress.
qreal amplitude() const
Returns the amplitude.
void setType(Type type)
Sets the type of the easing curve to type.
QList< QPointF > toCubicSpline() const
QScopedPointer< QGraphicsItemPrivate > d_ptr
qsizetype size() const noexcept
bool isEmpty() const noexcept
const T & constLast() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
static QList< QPointF > tcbToBezier(const TCBPoints &tcbPoints)
static QEasingCurve::EasingFunction curveToFunc(QEasingCurve::Type curve)
static QT_BEGIN_NAMESPACE bool isConfigFunction(QEasingCurve::Type type)
QDataStream & operator>>(QDataStream &stream, TCBPoint &point)
QList< TCBPoint > TCBPoints
static QEasingCurveFunction * curveToFunctionObject(QEasingCurve::Type type)
QDataStream & operator<<(QDataStream &stream, const TCBPoint &point)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
qfloat16 qSqrt(qfloat16 f)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLenum GLenum GLsizei count
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLdouble GLdouble GLdouble GLdouble q
#define QT_BEGIN_INCLUDE_NAMESPACE
#define QT_END_INCLUDE_NAMESPACE
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
unsigned long long quint64
QEasingCurveFunction * copy() const override
qreal value(qreal t) override
BackEase(QEasingCurve::Type type)
static float _fast_cbrt(float x)
static qreal evaluateDerivateForX(const SingleCubicBezier &singleCubicBezier, qreal t)
static qreal evaluateForX(const SingleCubicBezier &singleCubicBezier, qreal t)
static qreal _acos(qreal x)
static void cosacos(qreal x, qreal &s1, qreal &s2, qreal &s3)
static qreal _cos(qreal x)
static qreal _cbrt(qreal d)
static qreal newtonIteration(const SingleCubicBezier &singleCubicBezier, qreal t, qreal x)
static qreal evaluateSegmentForY(const SingleCubicBezier &singleCubicBezier, qreal t)
static qreal singleRealSolutionForCubic(qreal a, qreal b, qreal c)
qreal value(qreal x) override
QList< SingleCubicBezier > _curves
QEasingCurveFunction * copy() const override
void getBezierSegment(SingleCubicBezier *&singleCubicBezier, qreal x)
static qreal findTForX(const SingleCubicBezier &singleCubicBezier, qreal x)
QList< qreal > _intervals
BezierEase(QEasingCurve::Type type=QEasingCurve::BezierSpline)
static double _fast_cbrt(double d)
static bool inRange(qreal f)
static bool almostZero(qreal value)
BounceEase(QEasingCurve::Type type)
QEasingCurveFunction * copy() const override
qreal value(qreal t) override
qreal value(qreal t) override
ElasticEase(QEasingCurve::Type type)
QEasingCurveFunction * copy() const override
QEasingCurveFunction * copy() const override
qreal value(qreal x) override
bool operator==(const TCBPoint &other) const
TCBPoint(QPointF point, qreal t, qreal c, qreal b)