summaryrefslogtreecommitdiff
path: root/src/gui/palette.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-06-21 00:23:21 +0300
committerAndrei Karas <akaras@inbox.ru>2013-06-21 00:23:21 +0300
commitc4668ac2d65e8ed2dd57703a6979a8c96667dcf0 (patch)
tree63e6d91bb864bab3dce4a258bb00cae941a3f4d9 /src/gui/palette.cpp
parent811b0152c0e3911a58c357ec84fac9f84dbe911a (diff)
downloadplus-c4668ac2d65e8ed2dd57703a6979a8c96667dcf0.tar.gz
plus-c4668ac2d65e8ed2dd57703a6979a8c96667dcf0.tar.bz2
plus-c4668ac2d65e8ed2dd57703a6979a8c96667dcf0.tar.xz
plus-c4668ac2d65e8ed2dd57703a6979a8c96667dcf0.zip
improve a bit drawing palette.
Diffstat (limited to 'src/gui/palette.cpp')
-rw-r--r--src/gui/palette.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index bc363bb35..abd328458 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -99,13 +99,13 @@ void Palette::advanceGradients()
void Palette::advanceGradient()
{
- if (get_elapsed_time(mRainbowTime) > 5)
+ const int time = get_elapsed_time(mRainbowTime);
+ if (time > 5)
{
// For slower systems, advance can be greater than one (advance > 1
// skips advance-1 steps). Should make gradient look the same
// independent of the framerate.
- const int advance = get_elapsed_time(mRainbowTime) / 5;
- double startColVal, destColVal;
+ const int advance = time / 5;
for (size_t i = 0, sz = mGradVector.size(); i < sz; i++)
{
@@ -114,12 +114,13 @@ void Palette::advanceGradient()
continue;
int delay = elem->delay;
+ const GradientType &grad = elem->grad;
- if (elem->grad == PULSE)
+ if (grad == PULSE)
delay = delay / 20;
const int numOfColors = (elem->grad == SPECTRUM ? 6 :
- elem->grad == PULSE ? 127 :
+ grad == PULSE ? 127 :
RAINBOW_COLOR_COUNT);
elem->gradientIndex = (elem->gradientIndex + advance)
@@ -136,7 +137,7 @@ void Palette::advanceGradient()
gcn::Color &color = elem->color;
int colVal;
- if (elem->grad == PULSE)
+ if (grad == PULSE)
{
colVal = static_cast<int>(255.0 *
sin(M_PI * colIndex / numOfColors));
@@ -147,7 +148,7 @@ void Palette::advanceGradient()
color.g = ((colVal * col.g) / 255) % (col.g + 1);
color.b = ((colVal * col.b) / 255) % (col.b + 1);
}
- if (elem->grad == SPECTRUM)
+ else if (grad == SPECTRUM)
{
if (colIndex % 2)
{ // falling curve
@@ -188,6 +189,8 @@ void Palette::advanceGradient()
const gcn::Color &startCol = RAINBOW_COLORS[colIndex];
const gcn::Color &destCol =
RAINBOW_COLORS[(colIndex + 1) % numOfColors];
+ double startColVal;
+ double destColVal;
if (delay)
startColVal = (cos(M_PI * pos / delay) + 1) / 2;