summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-04-23 21:25:35 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-04-23 21:25:35 (GMT)
commit686f82e51124747cbe650d04dfb053830b6660fa (patch)
tree25dfdbde3bbb5970b79bff5a456fb2ac38d3656d /src
parenteaa9cedb527b59bdc58ea87a464f2a6c842246e6 (diff)
downloadQt-686f82e51124747cbe650d04dfb053830b6660fa.zip
Qt-686f82e51124747cbe650d04dfb053830b6660fa.tar.gz
Qt-686f82e51124747cbe650d04dfb053830b6660fa.tar.bz2
Fix a bug in the ease{In,Out}Bounce easing functions + small cleanup.
The bug was in easeOutBounce_helper(), where the last else-block adjusted t wrong. It should adjust t so that the peak is at t == 0, but it adjusted it too little. The old code did t -= (2.25f/2.75f), but it should have been 21/22. The rest of the changes in that function is just simple mathematical rewrites (use a more readable fraction), and removed the b argument, since that was always 0. Finally, fixing the original bug also revealed a bug in the first line of easeOutBounce_helper(), where we always returned 1.0 for t == 1.0. That was wrong since it did not respect c.
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/easing/easing.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/3rdparty/easing/easing.cpp b/src/3rdparty/easing/easing.cpp
index 340be86..9177c26 100644
--- a/src/3rdparty/easing/easing.cpp
+++ b/src/3rdparty/easing/easing.cpp
@@ -547,20 +547,20 @@ static qreal easeOutInBack(qreal t, qreal s)
return easeInBack(2*t - 1, s)/2 + 0.5;
}
-static qreal easeOutBounce_helper(qreal t, qreal b, qreal c, qreal a)
-{
- if (t == 1.0) return 1.0;
- if (t < (1/2.75)) {
- return c*(7.5625*t*t) + b;
- } else if (t < (2/2.75)) {
- t -= (1.5f/2.75f);
- return -a * (1. - (7.5625*t*t + .75)) + (b + c);
- } else if (t < (2.5/2.75)) {
- t -= (2.25f/2.75f);
- return -a * (1. - (7.5625*t*t + .9375)) + (b + c);
+static qreal easeOutBounce_helper(qreal t, qreal c, qreal a)
+{
+ if (t == 1.0) return c;
+ if (t < (4/11.0)) {
+ return c*(7.5625*t*t);
+ } else if (t < (8/11.0)) {
+ t -= (6/11.0);
+ return -a * (1. - (7.5625*t*t + .75)) + c;
+ } else if (t < (10/11.0)) {
+ t -= (9/11.0);
+ return -a * (1. - (7.5625*t*t + .9375)) + c;
} else {
- t -= (2.65f/2.75f);
- return -a * (1. - (7.5625*t*t + .984375)) + (b + c);
+ t -= (21/22.0);
+ return -a * (1. - (7.5625*t*t + .984375)) + c;
}
}
@@ -573,7 +573,7 @@ static qreal easeOutBounce_helper(qreal t, qreal b, qreal c, qreal a)
*/
static qreal easeOutBounce(qreal t, qreal a)
{
- return easeOutBounce_helper(t, 0, 1, a);
+ return easeOutBounce_helper(t, 1, a);
}
/**
@@ -585,7 +585,7 @@ static qreal easeOutBounce(qreal t, qreal a)
*/
static qreal easeInBounce(qreal t, qreal a)
{
- return 1.0 - easeOutBounce_helper(1.0-t, 0, 1.0, a);
+ return 1.0 - easeOutBounce_helper(1.0-t, 1.0, a);
}
@@ -611,8 +611,8 @@ static qreal easeInOutBounce(qreal t, qreal a)
*/
static qreal easeOutInBounce(qreal t, qreal a)
{
- if (t < 0.5) return easeOutBounce_helper(t*2, 0, 0.5, a);
- return 1.0 - easeOutBounce_helper (2.0-2*t, 0.0, 0.5, a);
+ if (t < 0.5) return easeOutBounce_helper(t*2, 0.5, a);
+ return 1.0 - easeOutBounce_helper (2.0-2*t, 0.5, a);
}
static inline qreal qt_sinProgress(qreal value)