5
6
7
8
9
10
11
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
82
83
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
254
255
256
257
258
259
260
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>
281 return (type >= QEasingCurve::InElastic
282 && type <= QEasingCurve::OutInBounce) ||
283 type == QEasingCurve::BezierSpline ||
284 type == QEasingCurve::TCBSpline;
299 return _point == other._point &&
300 qFuzzyCompare(_t, other._t) &&
301 qFuzzyCompare(_c, other._c) &&
302 qFuzzyCompare(_b, other._b);
309 stream << point._point
318 stream >> point._point
354 if (stream.version() > QDataStream::Qt_5_12) {
355 stream << func->_bezierCurves;
368 if (stream.version() > QDataStream::Qt_5_12) {
369 stream >> func->_bezierCurves;
380 QEasingCurve::EasingFunction func = curveToFunc(_t);
387 rv->_bezierCurves = _bezierCurves;
394 return _t == other._t &&
395 qFuzzyCompare(_p, other._p) &&
396 qFuzzyCompare(_a, other._a) &&
397 qFuzzyCompare(_o, other._o) &&
398 _bezierCurves == other._bezierCurves &&
399 _tcbPoints == other._tcbPoints;
402QT_BEGIN_INCLUDE_NAMESPACE
403#include "../../3rdparty/easing/easing.cpp"
404QT_END_INCLUDE_NAMESPACE
406class QEasingCurvePrivate
409 QEasingCurvePrivate()
410 : type(QEasingCurve::Linear),
414 QEasingCurvePrivate(
const QEasingCurvePrivate &other)
416 config(other.config ? other.config->copy() :
nullptr),
419 ~QEasingCurvePrivate() {
delete config; }
420 void setType_helper(QEasingCurve::Type);
422 QEasingCurve::Type type;
423 QEasingCurveFunction *config;
424 QEasingCurve::EasingFunction func;
448 if (_bezierCurves.constLast() == QPointF(1.0, 1.0)) {
450 _curveCount = _bezierCurves.size() / 3;
453 _intervals[i] = _bezierCurves.at(i * 3 + 2).x();
456 _curves[0].p0x = 0.0;
457 _curves[0].p0y = 0.0;
459 _curves[0].p1x = _bezierCurves.at(0).x();
460 _curves[0].p1y = _bezierCurves.at(0).y();
462 _curves[0].p2x = _bezierCurves.at(1).x();
463 _curves[0].p2y = _bezierCurves.at(1).y();
465 _curves[0].p3x = _bezierCurves.at(2).x();
466 _curves[0].p3y = _bezierCurves.at(2).y();
469 _curves[i].p0x = _bezierCurves.at(_bezierCurves.size() - 4).x();
470 _curves[i].p0y = _bezierCurves.at(_bezierCurves.size() - 4).y();
472 _curves[i].p1x = _bezierCurves.at(_bezierCurves.size() - 3).x();
473 _curves[i].p1y = _bezierCurves.at(_bezierCurves.size() - 3).y();
475 _curves[i].p2x = _bezierCurves.at(_bezierCurves.size() - 2).x();
476 _curves[i].p2y = _bezierCurves.at(_bezierCurves.size() - 2).y();
478 _curves[i].p3x = _bezierCurves.at(_bezierCurves.size() - 1).x();
479 _curves[i].p3y = _bezierCurves.at(_bezierCurves.size() - 1).y();
481 _curves[i].p0x = _bezierCurves.at(i * 3 - 1).x();
482 _curves[i].p0y = _bezierCurves.at(i * 3 - 1).y();
484 _curves[i].p1x = _bezierCurves.at(i * 3).x();
485 _curves[i].p1y = _bezierCurves.at(i * 3).y();
487 _curves[i].p2x = _bezierCurves.at(i * 3 + 1).x();
488 _curves[i].p2y = _bezierCurves.at(i * 3 + 1).y();
490 _curves[i].p3x = _bezierCurves.at(i * 3 + 2).x();
491 _curves[i].p3y = _bezierCurves.at(i * 3 + 2).y();
507 rv->_bezierCurves = _bezierCurves;
515 int currentSegment = 0;
518 if (x <= _intervals.data()[currentSegment])
523 singleCubicBezier = &_curves.data()[currentSegment];
529 qreal currentXValue = evaluateForX(singleCubicBezier, t);
531 const qreal newT = t - (currentXValue - x) / evaluateDerivateForX(singleCubicBezier, t);
538 Q_ASSERT(_bezierCurves.size() % 3 == 0);
540 if (_bezierCurves.isEmpty()) {
548 qWarning(
"QEasingCurve: Invalid bezier curve");
559 getBezierSegment(singleCubicBezier, x);
561 return evaluateSegmentForY(*singleCubicBezier, findTForX(*singleCubicBezier, x));
566 const qreal p0 = singleCubicBezier.p0y;
567 const qreal p1 = singleCubicBezier.p1y;
568 const qreal p2 = singleCubicBezier.p2y;
569 const qreal p3 = singleCubicBezier.p3y;
571 const qreal s = 1 - t;
573 const qreal s_squared = s * s;
574 const qreal t_squared = t * t;
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;
585 const qreal p1 = singleCubicBezier.p1x;
586 const qreal p2 = singleCubicBezier.p2x;
587 const qreal p3 = singleCubicBezier.p3x;
589 const qreal s = 1 - t;
591 const qreal s_squared = s * s;
592 const qreal t_squared = t * t;
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;
603 const qreal p1 = singleCubicBezier.p1x;
604 const qreal p2 = singleCubicBezier.p2x;
605 const qreal p3 = singleCubicBezier.p3x;
607 const qreal t_squared = t * t;
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;
619 qreal t = _fast_cbrt(d);
622 const qreal t_cubic = t * t * t;
623 const qreal f = t_cubic + t_cubic + d;
625 t = t * (t_cubic + d + d) / f;
629
630
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
667 quint32 hx = ux.pt[h0];
668 ut.pt[h0] = hx / 3 + B1;
675 return std::sqrt(1-x)*(1.5707963267948966192313216916398f + x*(-0.213300989f + x*(0.077980478f + x*-0.02164095f)));
680 const qreal pi_times2 = 2 *
M_PI;
681 const qreal pi_neg = -1 *
M_PI;
682 const qreal pi_by2 =
M_PI / 2.0;
691 const qreal a = 0.405284735;
692 const qreal b = 1.27323954;
694 const qreal x_squared = x * x;
697 qreal cos = b * x + a * x_squared;
700 return 0.225 * (cos * -1 * cos - cos) + cos;
701 return 0.225 * (cos * cos - cos) + cos;
704 qreal cos = b * x - a * x_squared;
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);
716 void static inline cosacos(qreal x, qreal &s1, qreal &s2, qreal &s3 )
721 const qreal x_squared = x * x;
722 const qreal x_plus_one_sqrt = qSqrt(1.0 + x);
723 const qreal one_minus_x_sqrt = qSqrt(1.0 - x);
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;
751 const qreal a_cubic = a * a * a;
753 const qreal p = b - a * a_by3;
754 const qreal q = 2.0 * a_cubic / 27.0 - a * b / 3.0 + c;
756 const qreal q_squared = q * q;
757 const qreal p_cubic = p * p * p;
758 const qreal D = 0.25 * q_squared + p_cubic / 27.0;
761 const qreal D_sqrt = qSqrt(D);
762 qreal u = _cbrt(-q * 0.5 + D_sqrt);
763 qreal v = _cbrt(-q * 0.5 - D_sqrt);
766 qreal t1 = z1 - a_by3;
771 qreal t2 = z2 - a_by3;
776 const qreal p_minus_sqrt = qSqrt(-p);
779 const qreal f = qSqrt(4.0 / 3.0) * p_minus_sqrt;
782 const qreal sqrtP = -3.0*qSqrt(3.0) / (p_minus_sqrt * p);
785 const qreal g = -q * 0.5 * sqrtP;
791 cosacos(g, s1, s2, s3);
793 qreal z1 = -1 * f * s2;
794 qreal t1 = z1 - a_by3;
799 qreal t2 = z2 - a_by3;
803 qreal z3 = -1 * f * s3;
804 qreal t3 = z3 - a_by3;
812 return value > -1e-3 && value < 1e-3;
817 const qreal p0 = singleCubicBezier.p0x;
818 const qreal p1 = singleCubicBezier.p1x;
819 const qreal p2 = singleCubicBezier.p2x;
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;
828 if (almostZero(factorT3)) {
829 if (almostZero(factorT2)) {
830 if (almostZero(factorT1))
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;
857 return singleRealSolutionForCubic(a, b, c);
872 Q_ASSERT(_bezierCurves.size() % 3 == 0);
874 if (_bezierCurves.isEmpty()) {
875 qWarning(
"QEasingCurve: Invalid tcb curve");
879 return BezierEase::value(x);
899 rv->_bezierCurves = _bezierCurves;
906 qreal p = (_p < 0) ? qreal(0.3) : _p;
907 qreal a = (_a < 0) ? qreal(1.0) : _a;
909 case QEasingCurve::InElastic:
910 return easeInElastic(t, a, p);
911 case QEasingCurve::OutElastic:
912 return easeOutElastic(t, a, p);
913 case QEasingCurve::InOutElastic:
914 return easeInOutElastic(t, a, p);
915 case QEasingCurve::OutInElastic:
916 return easeOutInElastic(t, a, p);
933 rv->_bezierCurves = _bezierCurves;
940 qreal a = (_a < 0) ? qreal(1.0) : _a;
942 case QEasingCurve::InBounce:
943 return easeInBounce(t, a);
944 case QEasingCurve::OutBounce:
945 return easeOutBounce(t, a);
946 case QEasingCurve::InOutBounce:
947 return easeInOutBounce(t, a);
948 case QEasingCurve::OutInBounce:
949 return easeOutInBounce(t, a);
966 rv->_bezierCurves = _bezierCurves;
978 qreal o = (_o < 0) ? qreal(1.70158) : _o;
980 case QEasingCurve::InBack:
981 return easeInBack(t, o);
982 case QEasingCurve::OutBack:
983 return easeOutBack(t, o);
984 case QEasingCurve::InOutBack:
985 return easeInOutBack(t, o);
986 case QEasingCurve::OutInBack:
987 return easeOutInBack(t, o);
997 case QEasingCurve::Linear:
999 case QEasingCurve::InQuad:
1001 case QEasingCurve::OutQuad:
1002 return &easeOutQuad;
1003 case QEasingCurve::InOutQuad:
1004 return &easeInOutQuad;
1005 case QEasingCurve::OutInQuad:
1006 return &easeOutInQuad;
1007 case QEasingCurve::InCubic:
1008 return &easeInCubic;
1009 case QEasingCurve::OutCubic:
1010 return &easeOutCubic;
1011 case QEasingCurve::InOutCubic:
1012 return &easeInOutCubic;
1013 case QEasingCurve::OutInCubic:
1014 return &easeOutInCubic;
1015 case QEasingCurve::InQuart:
1016 return &easeInQuart;
1017 case QEasingCurve::OutQuart:
1018 return &easeOutQuart;
1019 case QEasingCurve::InOutQuart:
1020 return &easeInOutQuart;
1021 case QEasingCurve::OutInQuart:
1022 return &easeOutInQuart;
1023 case QEasingCurve::InQuint:
1024 return &easeInQuint;
1025 case QEasingCurve::OutQuint:
1026 return &easeOutQuint;
1027 case QEasingCurve::InOutQuint:
1028 return &easeInOutQuint;
1029 case QEasingCurve::OutInQuint:
1030 return &easeOutInQuint;
1031 case QEasingCurve::InSine:
1033 case QEasingCurve::OutSine:
1034 return &easeOutSine;
1035 case QEasingCurve::InOutSine:
1036 return &easeInOutSine;
1037 case QEasingCurve::OutInSine:
1038 return &easeOutInSine;
1039 case QEasingCurve::InExpo:
1041 case QEasingCurve::OutExpo:
1042 return &easeOutExpo;
1043 case QEasingCurve::InOutExpo:
1044 return &easeInOutExpo;
1045 case QEasingCurve::OutInExpo:
1046 return &easeOutInExpo;
1047 case QEasingCurve::InCirc:
1049 case QEasingCurve::OutCirc:
1050 return &easeOutCirc;
1051 case QEasingCurve::InOutCirc:
1052 return &easeInOutCirc;
1053 case QEasingCurve::OutInCirc:
1054 return &easeOutInCirc;
1056 case QEasingCurve::InCurve:
1057 return &easeInCurve;
1058 case QEasingCurve::OutCurve:
1059 return &easeOutCurve;
1060 case QEasingCurve::SineCurve:
1061 return &easeSineCurve;
1062 case QEasingCurve::CosineCurve:
1063 return &easeCosineCurve;
1072 case QEasingCurve::InElastic:
1073 case QEasingCurve::OutElastic:
1074 case QEasingCurve::InOutElastic:
1075 case QEasingCurve::OutInElastic:
1077 case QEasingCurve::OutBounce:
1078 case QEasingCurve::InBounce:
1079 case QEasingCurve::OutInBounce:
1080 case QEasingCurve::InOutBounce:
1082 case QEasingCurve::InBack:
1083 case QEasingCurve::OutBack:
1084 case QEasingCurve::InOutBack:
1085 case QEasingCurve::OutInBack:
1087 case QEasingCurve::BezierSpline:
1089 case QEasingCurve::TCBSpline:
1099
1100
1101
1102
1103
1104
1105
1108
1109
1110QEasingCurve::QEasingCurve(Type type)
1111 : d_ptr(
new QEasingCurvePrivate)
1117
1118
1119QEasingCurve::QEasingCurve(
const QEasingCurve &other)
1120 : d_ptr(
new QEasingCurvePrivate(*other.d_ptr))
1126
1127
1129QEasingCurve::~QEasingCurve()
1135
1136
1137
1140
1141
1142
1143
1144
1145
1148
1149
1150
1151
1154
1155
1156
1157
1158
1159
1162 bool res = lhs.d_ptr->func == rhs.d_ptr->func
1163 && lhs.d_ptr->type == rhs.d_ptr->type;
1165 if (lhs.d_ptr->config && rhs.d_ptr->config) {
1167 res = lhs.d_ptr->config->operator==(*(rhs.d_ptr->config));
1169 }
else if (lhs.d_ptr->config || rhs.d_ptr->config) {
1171 res = qFuzzyCompare(lhs.amplitude(), rhs.amplitude())
1172 && qFuzzyCompare(lhs.period(), rhs.period())
1173 && qFuzzyCompare(lhs.overshoot(), rhs.overshoot());
1180
1181
1182
1183
1184
1185
1186
1187
1190
1191
1192
1193
1194
1195
1196qreal QEasingCurve::amplitude()
const
1198 return d_ptr->config ? d_ptr->config->_a : qreal(1.0);
1202
1203
1204
1205
1206
1207
1208void QEasingCurve::setAmplitude(qreal amplitude)
1211 d_ptr->config = curveToFunctionObject(d_ptr->type);
1212 d_ptr->config->_a = amplitude;
1216
1217
1218
1219
1220qreal QEasingCurve::period()
const
1222 return d_ptr->config ? d_ptr->config->_p : qreal(0.3);
1226
1227
1228
1229
1230
1231
1232void QEasingCurve::setPeriod(qreal period)
1235 d_ptr->config = curveToFunctionObject(d_ptr->type);
1236 d_ptr->config->_p = period;
1240
1241
1242
1243
1244qreal QEasingCurve::overshoot()
const
1246 return d_ptr->config ? d_ptr->config->_o : qreal(1.70158);
1250
1251
1252
1253
1254
1255
1256void QEasingCurve::setOvershoot(qreal overshoot)
1259 d_ptr->config = curveToFunctionObject(d_ptr->type);
1260 d_ptr->config->_o = overshoot;
1264
1265
1266
1267
1268
1269
1270
1271void QEasingCurve::addCubicBezierSegment(
const QPointF & c1,
const QPointF & c2,
const QPointF & endPoint)
1274 d_ptr->config = curveToFunctionObject(d_ptr->type);
1275 d_ptr->config->_bezierCurves << c1 << c2 << endPoint;
1280 const int count = tcbPoints.size();
1281 QList<QPointF> bezierPoints;
1282 bezierPoints.reserve(3 * (count - 1));
1284 for (
int i = 1; i < count; i++) {
1285 const qreal t_0 = tcbPoints.at(i - 1)._t;
1286 const qreal c_0 = tcbPoints.at(i - 1)._c;
1289 qreal
const t_1 = tcbPoints.at(i)._t;
1290 qreal
const c_1 = tcbPoints.at(i)._c;
1294 const QPointF c0(tcbPoints.at(i - 1)._point);
1295 const QPointF c3(tcbPoints.at(i)._point);
1299 c_minusOne = tcbPoints.at(i - 2)._point;
1300 b_0 = tcbPoints.at(i - 1)._b;
1303 if (i < (count - 1)) {
1304 c4 = tcbPoints.at(i + 1)._point;
1305 b_1 = tcbPoints.at(i)._b;
1308 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()));
1309 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()));
1311 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()));
1312 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 const QPointF d_0 = QPointF(dx_0, dy_0);
1315 const QPointF d_1 = QPointF(dx_1, dy_1);
1317 QPointF c1 = (3 * c0 + d_0) / 3;
1318 QPointF c2 = (3 * c3 - d_1) / 3;
1319 bezierPoints << c1 << c2 << c3;
1321 return bezierPoints;
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338void QEasingCurve::addTCBSegment(
const QPointF &nextPoint, qreal t, qreal c, qreal b)
1341 d_ptr->config = curveToFunctionObject(d_ptr->type);
1343 d_ptr->config->_tcbPoints.append(TCBPoint(nextPoint, t, c, b));
1345 if (nextPoint == QPointF(1.0, 1.0)) {
1346 d_ptr->config->_bezierCurves = tcbToBezier(d_ptr->config->_tcbPoints);
1347 d_ptr->config->_tcbPoints.clear();
1353
1354
1355
1356
1357
1358
1359QList<QPointF> QEasingCurve::toCubicSpline()
const
1361 return d_ptr->config ? d_ptr->config->_bezierCurves : QList<QPointF>();
1365
1366
1367QEasingCurve::Type QEasingCurve::type()
const
1372void QEasingCurvePrivate::setType_helper(QEasingCurve::Type newType)
1375 qreal period = -1.0;
1376 qreal overshoot = -1.0;
1377 QList<QPointF> bezierCurves;
1378 QList<TCBPoint> tcbPoints;
1382 period = config->_p;
1383 overshoot = config->_o;
1384 bezierCurves =
std::move(config->_bezierCurves);
1391 if (isConfigFunction(newType) || (amp != -1.0) || (period != -1.0) || (overshoot != -1.0) ||
1392 !bezierCurves.isEmpty()) {
1393 config = curveToFunctionObject(newType);
1397 config->_p = period;
1398 if (overshoot != -1.0)
1399 config->_o = overshoot;
1400 config->_bezierCurves =
std::move(bezierCurves);
1403 }
else if (newType != QEasingCurve::Custom) {
1404 func = curveToFunc(newType);
1406 Q_ASSERT((func ==
nullptr) == (config !=
nullptr));
1411
1412
1413void QEasingCurve::setType(Type type)
1415 if (d_ptr->type == type)
1417 if (type < Linear || type >= NCurveTypes - 1) {
1418 qWarning(
"QEasingCurve: Invalid curve type %d", type);
1422 d_ptr->setType_helper(type);
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436void QEasingCurve::setCustomType(EasingFunction func)
1439 qWarning(
"Function pointer must not be null");
1443 d_ptr->setType_helper(Custom);
1447
1448
1449
1450
1451QEasingCurve::EasingFunction QEasingCurve::customType()
const
1453 return d_ptr->type == Custom ? d_ptr->func :
nullptr;
1457
1458
1459
1460
1461
1462qreal QEasingCurve::valueForProgress(qreal progress)
const
1464 progress = qBound<qreal>(0, progress, 1);
1466 return d_ptr->func(progress);
1467 else if (d_ptr->config)
1468 return d_ptr->config->value(progress);
1473#ifndef QT_NO_DEBUG_STREAM
1476 QDebugStateSaver saver(debug);
1477 debug <<
"type:" << item.d_ptr->type
1478 <<
"func:" <<
reinterpret_cast<
const void *>(item.d_ptr->func);
1479 if (item.d_ptr->config) {
1480 debug << QString::fromLatin1(
"period:%1").arg(item.d_ptr->config->_p, 0,
'f', 20)
1481 << QString::fromLatin1(
"amp:%1").arg(item.d_ptr->config->_a, 0,
'f', 20)
1482 << QString::fromLatin1(
"overshoot:%1").arg(item.d_ptr->config->_o, 0,
'f', 20);
1488#ifndef QT_NO_DATASTREAM
1490
1491
1492
1493
1494
1495
1496
1497
1501 stream << quint8(easing.d_ptr->type);
1502 stream << quint64(quintptr(easing.d_ptr->func));
1504 bool hasConfig = easing.d_ptr->config;
1505 stream << hasConfig;
1507 stream << easing.d_ptr->config;
1513
1514
1515
1516
1517
1518
1519
1520
1524 QEasingCurve::Type type;
1527 type =
static_cast<QEasingCurve::Type>(int_type);
1528 easing.setType(type);
1532 easing.d_ptr->func = QEasingCurve::EasingFunction(quintptr(ptr_func));
1535 stream >> hasConfig;
1536 delete easing.d_ptr->config;
1537 easing.d_ptr->config =
nullptr;
1541 easing.d_ptr->config = config;
1549#include "moc_qeasingcurve.cpp"
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
QList< QPointF > _bezierCurves
\inmodule QtCore\reentrant
static QList< QPointF > tcbToBezier(const TCBPoints &tcbPoints)
static QEasingCurve::EasingFunction curveToFunc(QEasingCurve::Type curve)
Q_DECLARE_TYPEINFO(TCBPoint, Q_PRIMITIVE_TYPE)
static QT_BEGIN_NAMESPACE bool isConfigFunction(QEasingCurve::Type type)
QDataStream & operator<<(QDataStream &stream, QEasingCurveFunction *func)
QList< TCBPoint > TCBPoints
QDataStream & operator>>(QDataStream &stream, QEasingCurveFunction *func)
QDataStream & operator>>(QDataStream &stream, TCBPoint &point)
static QEasingCurveFunction * curveToFunctionObject(QEasingCurve::Type type)
QDataStream & operator<<(QDataStream &stream, const TCBPoint &point)
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
bool comparesEqual(const QFileInfo &lhs, const QFileInfo &rhs)
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)
QList< SingleCubicBezier > _curves
static qreal singleRealSolutionForCubic(qreal a, qreal b, qreal c)
qreal value(qreal x) override
QEasingCurveFunction * copy() const override
void getBezierSegment(SingleCubicBezier *&singleCubicBezier, qreal x)
static qreal findTForX(const SingleCubicBezier &singleCubicBezier, qreal x)
BezierEase(QEasingCurve::Type type=QEasingCurve::BezierSpline)
QList< qreal > _intervals
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)