Graphics: Fadein/out should interpolate from current brightness

This commit is contained in:
Jonas Kulla 2014-08-22 23:53:11 +02:00
parent 24ad0990da
commit b751858b16
1 changed files with 9 additions and 3 deletions

View File

@ -727,9 +727,12 @@ void Graphics::fadeout(int duration)
{ {
FBO::unbind(); FBO::unbind();
float curr = p->brightness;
float diff = 255.0 - curr;
for (int i = duration-1; i > -1; --i) for (int i = duration-1; i > -1; --i)
{ {
setBrightness((255.0 / duration) * i); setBrightness(diff + (curr / duration) * i);
if (p->frozen) if (p->frozen)
{ {
@ -754,9 +757,12 @@ void Graphics::fadein(int duration)
{ {
FBO::unbind(); FBO::unbind();
for (int i = 0; i < duration; ++i) float curr = p->brightness;
float diff = 255.0 - curr;
for (int i = 1; i <= duration; ++i)
{ {
setBrightness((255.0 / duration) * i); setBrightness(curr + (diff / duration) * i);
if (p->frozen) if (p->frozen)
{ {