Coverage Report

Created: 2025-07-23 06:54

/src/qtbase/src/3rdparty/easing/easing.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
Disclaimer for Robert Penner's Easing Equations license:
3
4
TERMS OF USE - EASING EQUATIONS
5
6
Open source under the BSD License.
7
8
Copyright © 2001 Robert Penner
9
All rights reserved.
10
11
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12
13
    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
14
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
15
    * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18
*/
19
20
#include <QtCore/qmath.h>
21
#include <math.h>
22
#ifndef M_PI
23
#define M_PI 3.14159265358979323846
24
#endif
25
#ifndef M_PI_2
26
#define M_PI_2 (M_PI / 2)
27
#endif
28
29
QT_USE_NAMESPACE
30
31
/**
32
 * Easing equation function for a simple linear tweening, with no easing.
33
 *
34
 * @param t   Current time (in frames or seconds).
35
 * @return    The correct value.
36
 */
37
static qreal easeNone(qreal progress)
38
0
{
39
0
    return progress;
40
0
}
41
42
/**
43
 * Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
44
 *
45
 * @param t   Current time (in frames or seconds).
46
 * @return    The correct value.
47
 */
48
static qreal easeInQuad(qreal t)
49
0
{
50
0
    return t*t;
51
0
}
52
53
/**
54
* Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
55
*
56
* @param t    Current time (in frames or seconds).
57
* @return   The correct value.
58
*/
59
static qreal easeOutQuad(qreal t)
60
0
{
61
0
    return -t*(t-2);
62
0
}
63
64
/**
65
 * Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
66
 *
67
 * @param t   Current time (in frames or seconds).
68
 * @return    The correct value.
69
 */
70
static qreal easeInOutQuad(qreal t)
71
0
{
72
0
    t*=2.0;
73
0
    if (t < 1) {
74
0
        return t*t/qreal(2);
75
0
    } else {
76
0
        --t;
77
0
        return -0.5 * (t*(t-2) - 1);
78
0
    }
79
0
}
80
81
/**
82
 * Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
83
 *
84
 * @param t   Current time (in frames or seconds).
85
 * @return    The correct value.
86
 */
87
static qreal easeOutInQuad(qreal t)
88
0
{
89
0
    if (t < 0.5) return easeOutQuad (t*2)/2;
90
0
    return easeInQuad((2*t)-1)/2 + 0.5;
91
0
}
92
93
/**
94
 * Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
95
 *
96
 * @param t   Current time (in frames or seconds).
97
 * @return    The correct value.
98
 */
99
static qreal easeInCubic(qreal t)
100
0
{
101
0
    return t*t*t;
102
0
}
103
104
/**
105
 * Easing equation function for a cubic (t^3) easing out: decelerating to zero velocity.
106
 *
107
 * @param t   Current time (in frames or seconds).
108
 * @return    The correct value.
109
 */
110
static qreal easeOutCubic(qreal t)
111
0
{
112
0
    t-=1.0;
113
0
    return t*t*t + 1;
114
0
}
115
116
/**
117
 * Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
118
 *
119
 * @param t   Current time (in frames or seconds).
120
 * @return    The correct value.
121
 */
122
static qreal easeInOutCubic(qreal t)
123
0
{
124
0
    t*=2.0;
125
0
    if(t < 1) {
126
0
        return 0.5*t*t*t;
127
0
    } else {
128
0
        t -= qreal(2.0);
129
0
        return 0.5*(t*t*t + 2);
130
0
    }
131
0
}
132
133
/**
134
 * Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
135
 *
136
 * @param t   Current time (in frames or seconds).
137
 * @return    The correct value.
138
 */
139
static qreal easeOutInCubic(qreal t)
140
0
{
141
0
    if (t < 0.5) return easeOutCubic (2*t)/2;
142
0
    return easeInCubic(2*t - 1)/2 + 0.5;
143
0
}
144
145
/**
146
 * Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
147
 *
148
 * @param t   Current time (in frames or seconds).
149
 * @return    The correct value.
150
 */
151
static qreal easeInQuart(qreal t)
152
0
{
153
0
    return t*t*t*t;
154
0
}
155
156
/**
157
 * Easing equation function for a quartic (t^4) easing out: decelerating to zero velocity.
158
 *
159
 * @param t   Current time (in frames or seconds).
160
 * @return    The correct value.
161
 */
162
static qreal easeOutQuart(qreal t)
163
0
{
164
0
    t-= qreal(1.0);
165
0
    return - (t*t*t*t- 1);
166
0
}
167
168
/**
169
 * Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
170
 *
171
 * @param t   Current time (in frames or seconds).
172
 * @return    The correct value.
173
 */
174
static qreal easeInOutQuart(qreal t)
175
0
{
176
0
    t*=2;
177
0
    if (t < 1) return 0.5*t*t*t*t;
178
0
    else {
179
0
        t -= 2.0f;
180
0
        return -0.5 * (t*t*t*t- 2);
181
0
    }
182
0
}
183
184
/**
185
 * Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
186
 *
187
 * @param t   Current time (in frames or seconds).
188
 * @return    The correct value.
189
 */
190
static qreal easeOutInQuart(qreal t)
191
0
{
192
0
    if (t < 0.5) return easeOutQuart (2*t)/2;
193
0
    return easeInQuart(2*t-1)/2 + 0.5;
194
0
}
195
196
/**
197
 * Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
198
 *
199
 * @param t   Current time (in frames or seconds).
200
 * @return    The correct value.
201
 */
202
static qreal easeInQuint(qreal t)
203
0
{
204
0
    return t*t*t*t*t;
205
0
}
206
207
/**
208
 * Easing equation function for a quintic (t^5) easing out: decelerating to zero velocity.
209
 *
210
 * @param t   Current time (in frames or seconds).
211
 * @return    The correct value.
212
 */
213
static qreal easeOutQuint(qreal t)
214
0
{
215
0
    t-=1.0;
216
0
    return t*t*t*t*t + 1;
217
0
}
218
219
/**
220
 * Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
221
 *
222
 * @param t   Current time (in frames or seconds).
223
 * @return    The correct value.
224
 */
225
static qreal easeInOutQuint(qreal t)
226
0
{
227
0
    t*=2.0;
228
0
    if (t < 1) return 0.5*t*t*t*t*t;
229
0
    else {
230
0
        t -= 2.0;
231
0
        return 0.5*(t*t*t*t*t + 2);
232
0
    }
233
0
}
234
235
/**
236
 * Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
237
 *
238
 * @param t   Current time (in frames or seconds).
239
 * @return    The correct value.
240
 */
241
static qreal easeOutInQuint(qreal t)
242
0
{
243
0
    if (t < 0.5) return easeOutQuint (2*t)/2;
244
0
    return easeInQuint(2*t - 1)/2 + 0.5;
245
0
}
246
247
/**
248
 * Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
249
 *
250
 * @param t   Current time (in frames or seconds).
251
 * @return    The correct value.
252
 */
253
static qreal easeInSine(qreal t)
254
0
{
255
0
    return (t == 1.0) ? 1.0 : -::qCos(t * M_PI_2) + 1.0;
256
0
}
257
258
/**
259
 * Easing equation function for a sinusoidal (sin(t)) easing out: decelerating to zero velocity.
260
 *
261
 * @param t   Current time (in frames or seconds).
262
 * @return    The correct value.
263
 */
264
static qreal easeOutSine(qreal t)
265
0
{
266
0
    return ::qSin(t* M_PI_2);
267
0
}
268
269
/**
270
 * Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
271
 *
272
 * @param t   Current time (in frames or seconds).
273
 * @return    The correct value.
274
 */
275
static qreal easeInOutSine(qreal t)
276
0
{
277
0
    return -0.5 * (::qCos(M_PI*t) - 1);
278
0
}
279
280
/**
281
 * Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
282
 *
283
 * @param t   Current time (in frames or seconds).
284
 * @return    The correct value.
285
 */
286
static qreal easeOutInSine(qreal t)
287
0
{
288
0
    if (t < 0.5) return easeOutSine (2*t)/2;
289
0
    return easeInSine(2*t - 1)/2 + 0.5;
290
0
}
291
292
/**
293
 * Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
294
 *
295
 * @param t   Current time (in frames or seconds).
296
 * @return    The correct value.
297
 */
298
static qreal easeInExpo(qreal t)
299
0
{
300
0
    return (t==0 || t == 1.0) ? t : ::qPow(2.0, 10 * (t - 1)) - qreal(0.001);
301
0
}
302
303
/**
304
 * Easing equation function for an exponential (2^t) easing out: decelerating to zero velocity.
305
 *
306
 * @param t   Current time (in frames or seconds).
307
 * @return    The correct value.
308
 */
309
static qreal easeOutExpo(qreal t)
310
0
{
311
0
    return (t==1.0) ? 1.0 : 1.001 * (-::qPow(2.0f, -10 * t) + 1);
312
0
}
313
314
/**
315
 * Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
316
 *
317
 * @param t   Current time (in frames or seconds).
318
 * @return    The correct value.
319
 */
320
static qreal easeInOutExpo(qreal t)
321
0
{
322
0
    if (t==0.0) return qreal(0.0);
323
0
    if (t==1.0) return qreal(1.0);
324
0
    t*=2.0;
325
0
    if (t < 1) return 0.5 * ::qPow(qreal(2.0), 10 * (t - 1)) - 0.0005;
326
0
    return 0.5 * 1.0005 * (-::qPow(qreal(2.0), -10 * (t - 1)) + 2);
327
0
}
328
329
/**
330
 * Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
331
 *
332
 * @param t   Current time (in frames or seconds).
333
 * @return    The correct value.
334
 */
335
static qreal easeOutInExpo(qreal t)
336
0
{
337
0
    if (t < 0.5) return easeOutExpo (2*t)/2;
338
0
    return easeInExpo(2*t - 1)/2 + 0.5;
339
0
}
340
341
/**
342
 * Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
343
 *
344
 * @param t   Current time (in frames or seconds).
345
 * @return    The correct value.
346
 */
347
static qreal easeInCirc(qreal t)
348
0
{
349
0
    return -(::sqrt(1 - t*t) - 1);
350
0
}
351
352
/**
353
 * Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating to zero velocity.
354
 *
355
 * @param t   Current time (in frames or seconds).
356
 * @return    The correct value.
357
 */
358
static qreal easeOutCirc(qreal t)
359
0
{
360
0
    t-= qreal(1.0);
361
0
    return ::sqrt(1 - t* t);
362
0
}
363
364
/**
365
 * Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
366
 *
367
 * @param t   Current time (in frames or seconds).
368
 * @return    The correct value.
369
 */
370
static qreal easeInOutCirc(qreal t)
371
0
{
372
0
    t*=qreal(2.0);
373
0
    if (t < 1) {
374
0
        return -0.5 * (::sqrt(1 - t*t) - 1);
375
0
    } else {
376
0
        t -= qreal(2.0);
377
0
        return 0.5 * (::sqrt(1 - t*t) + 1);
378
0
    }
379
0
}
380
381
/**
382
 * Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
383
 *
384
 * @param t   Current time (in frames or seconds).
385
 * @return    The correct value.
386
 */
387
static qreal easeOutInCirc(qreal t)
388
0
{
389
0
    if (t < 0.5) return easeOutCirc (2*t)/2;
390
0
    return easeInCirc(2*t - 1)/2 + 0.5;
391
0
}
392
393
static qreal easeInElastic_helper(qreal t, qreal b, qreal c, qreal d, qreal a, qreal p)
394
0
{
395
0
    if (t==0) return b;
396
0
    qreal t_adj = (qreal)t / (qreal)d;
397
0
    if (t_adj==1) return b+c;
398
399
0
    qreal s;
400
0
    if(a < ::qFabs(c)) {
401
0
        a = c;
402
0
        s = p / 4.0f;
403
0
    } else {
404
0
        s = p / (2 * M_PI) * ::qAsin(c / a);
405
0
    }
406
407
0
    t_adj -= 1.0f;
408
0
    return -(a*::qPow(2.0f,10*t_adj) * ::qSin( (t_adj*d-s)*(2*M_PI)/p )) + b;
409
0
}
410
411
/**
412
 * Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity.
413
 *
414
 * @param t   Current time (in frames or seconds).
415
 * @param a   Amplitude.
416
 * @param p   Period.
417
 * @return    The correct value.
418
 */
419
static qreal easeInElastic(qreal t, qreal a, qreal p)
420
0
{
421
0
    return easeInElastic_helper(t, 0, 1, 1, a, p);
422
0
}
423
424
static qreal easeOutElastic_helper(qreal t, qreal /*b*/, qreal c, qreal /*d*/, qreal a, qreal p)
425
0
{
426
0
    if (t==0) return 0;
427
0
    if (t==1) return c;
428
429
0
    qreal s;
430
0
    if(a < c) {
431
0
        a = c;
432
0
        s = p / 4.0f;
433
0
    } else {
434
0
        s = p / (2 * M_PI) * ::qAsin(c / a);
435
0
    }
436
437
0
    return (a*::qPow(2.0f,-10*t) * ::qSin( (t-s)*(2*M_PI)/p ) + c);
438
0
}
439
440
/**
441
 * Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating to zero velocity.
442
 *
443
 * @param t   Current time (in frames or seconds).
444
 * @param a   Amplitude.
445
 * @param p   Period.
446
 * @return    The correct value.
447
 */
448
static qreal easeOutElastic(qreal t, qreal a, qreal p)
449
0
{
450
0
    return easeOutElastic_helper(t, 0, 1, 1, a, p);
451
0
}
452
453
/**
454
 * Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
455
 *
456
 * @param t   Current time (in frames or seconds).
457
 * @param a   Amplitude.
458
 * @param p   Period.
459
 * @return    The correct value.
460
 */
461
static qreal easeInOutElastic(qreal t, qreal a, qreal p)
462
0
{
463
0
    if (t==0) return 0.0;
464
0
    t*=2.0;
465
0
    if (t==2) return 1.0;
466
467
0
    qreal s;
468
0
    if(a < 1.0) {
469
0
        a = 1.0;
470
0
        s = p / 4.0f;
471
0
    } else {
472
0
        s = p / (2 * M_PI) * ::qAsin(1.0 / a);
473
0
    }
474
475
0
    if (t < 1) return -.5*(a*::qPow(2.0f,10*(t-1)) * ::qSin( (t-1-s)*(2*M_PI)/p ));
476
0
    return a*::qPow(2.0f,-10*(t-1)) * ::qSin( (t-1-s)*(2*M_PI)/p )*.5 + 1.0;
477
0
}
478
479
/**
480
 * Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
481
 *
482
 * @param t   Current time (in frames or seconds).
483
 * @param a   Amplitude.
484
 * @param p   Period.
485
 * @return    The correct value.
486
 */
487
static qreal easeOutInElastic(qreal t, qreal a, qreal p)
488
0
{
489
0
    if (t < 0.5) return easeOutElastic_helper(t*2, 0, 0.5, 1.0, a, p);
490
0
    return easeInElastic_helper(2*t - 1.0, 0.5, 0.5, 1.0, a, p);
491
0
}
492
493
/**
494
 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
495
 *
496
 * @param t   Current time (in frames or seconds).
497
 * @param s   Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
498
 * @return    The correct value.
499
 */
500
static qreal easeInBack(qreal t, qreal s)
501
0
{
502
0
    return t*t*((s+1)*t - s);
503
0
}
504
505
/**
506
 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity.
507
 *
508
 * @param t   Current time (in frames or seconds).
509
 * @param s   Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
510
 * @return    The correct value.
511
 */
512
static qreal easeOutBack(qreal t, qreal s)
513
0
{
514
0
    t-= qreal(1.0);
515
0
    return t*t*((s+1)*t+ s) + 1;
516
0
}
517
518
/**
519
 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
520
 *
521
 * @param t   Current time (in frames or seconds).
522
 * @param s   Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
523
 * @return    The correct value.
524
 */
525
static qreal easeInOutBack(qreal t, qreal s)
526
0
{
527
0
    t *= 2.0;
528
0
    if (t < 1) {
529
0
        s *= 1.525f;
530
0
        return 0.5*(t*t*((s+1)*t - s));
531
0
    } else {
532
0
        t -= 2;
533
0
        s *= 1.525f;
534
0
        return 0.5*(t*t*((s+1)*t+ s) + 2);
535
0
    }
536
0
}
537
538
/**
539
 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
540
 *
541
 * @param t   Current time (in frames or seconds).
542
 * @param s   Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
543
 * @return    The correct value.
544
 */
545
static qreal easeOutInBack(qreal t, qreal s)
546
0
{
547
0
    if (t < 0.5) return easeOutBack (2*t, s)/2;
548
0
    return easeInBack(2*t - 1, s)/2 + 0.5;
549
0
}
550
551
static qreal easeOutBounce_helper(qreal t, qreal c, qreal a)
552
0
{
553
0
    if (t == 1.0) return c;
554
0
    if (t < (4/11.0)) {
555
0
        return c*(7.5625*t*t);
556
0
    } else if (t < (8/11.0)) {
557
0
        t -= (6/11.0);
558
0
        return -a * (1. - (7.5625*t*t + .75)) + c;
559
0
    } else if (t < (10/11.0)) {
560
0
        t -= (9/11.0);
561
0
        return -a * (1. - (7.5625*t*t + .9375)) + c;
562
0
    } else {
563
0
        t -= (21/22.0);
564
0
        return -a * (1. - (7.5625*t*t + .984375)) + c;
565
0
    }
566
0
}
567
568
/**
569
 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating to zero velocity.
570
 *
571
 * @param t   Current time (in frames or seconds).
572
 * @param a   Amplitude.
573
 * @return    The correct value.
574
 */
575
static qreal easeOutBounce(qreal t, qreal a)
576
0
{
577
0
    return easeOutBounce_helper(t, 1, a);
578
0
}
579
580
/**
581
 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
582
 *
583
 * @param t   Current time (in frames or seconds).
584
 * @param a   Amplitude.
585
 * @return    The correct value.
586
 */
587
static qreal easeInBounce(qreal t, qreal a)
588
0
{
589
0
    return 1.0 - easeOutBounce_helper(1.0-t, 1.0, a);
590
0
}
591
592
593
/**
594
 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
595
 *
596
 * @param t   Current time (in frames or seconds).
597
 * @param a   Amplitude.
598
 * @return    The correct value.
599
 */
600
static qreal easeInOutBounce(qreal t, qreal a)
601
0
{
602
0
    if (t < 0.5) return easeInBounce (2*t, a)/2;
603
0
    else return (t == 1.0) ? 1.0 : easeOutBounce (2*t - 1, a)/2 + 0.5;
604
0
}
605
606
/**
607
 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
608
 *
609
 * @param t   Current time (in frames or seconds).
610
 * @param a   Amplitude.
611
 * @return    The correct value.
612
 */
613
static qreal easeOutInBounce(qreal t, qreal a)
614
0
{
615
0
    if (t < 0.5) return easeOutBounce_helper(t*2, 0.5, a);
616
0
    return 1.0 - easeOutBounce_helper (2.0-2*t, 0.5, a);
617
0
}
618
619
static inline qreal qt_sinProgress(qreal value)
620
0
{
621
0
    return qSin((value * M_PI) - M_PI_2) / 2 + qreal(0.5);
622
0
}
623
624
static inline qreal qt_smoothBeginEndMixFactor(qreal value)
625
0
{
626
0
    return qMin(qMax(1 - value * 2 + qreal(0.3), qreal(0.0)), qreal(1.0));
627
0
}
628
629
// SmoothBegin blends Smooth and Linear Interpolation.
630
// Progress 0 - 0.3      : Smooth only
631
// Progress 0.3 - ~ 0.5  : Mix of Smooth and Linear
632
// Progress ~ 0.5  - 1   : Linear only
633
634
/**
635
 * Easing function that starts growing slowly, then increases in speed. At the end of the curve the speed will be constant.
636
 */
637
static qreal easeInCurve(qreal t)
638
0
{
639
0
    const qreal sinProgress = qt_sinProgress(t);
640
0
    const qreal mix = qt_smoothBeginEndMixFactor(t);
641
0
    return sinProgress * mix + t * (1 - mix);
642
0
}
643
644
/**
645
 * Easing function that starts growing steadily, then ends slowly. The speed will be constant at the beginning of the curve.
646
 */
647
static qreal easeOutCurve(qreal t)
648
0
{
649
0
    const qreal sinProgress = qt_sinProgress(t);
650
0
    const qreal mix = qt_smoothBeginEndMixFactor(1 - t);
651
0
    return sinProgress * mix + t * (1 - mix);
652
0
}
653
654
/**
655
 * Easing function where the value grows sinusoidally. Note that the calculated  end value will be 0 rather than 1.
656
 */
657
static qreal easeSineCurve(qreal t)
658
0
{
659
0
    return (qSin(((t * M_PI * 2)) - M_PI_2) + 1) / 2;
660
0
}
661
662
/**
663
 * Easing function where the value grows cosinusoidally. Note that the calculated start value will be 0.5 and the end value will be 0.5
664
 * contrary to the usual 0 to 1 easing curve.
665
 */
666
static qreal easeCosineCurve(qreal t)
667
0
{
668
0
    return (qCos(((t * M_PI * 2)) - M_PI_2) + 1) / 2;
669
0
}
670