diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-05-17 23:38:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-17 23:38:30 +0300 |
commit | 59dc4ad66d2552ae1809555abd3c1e0faf99209f (patch) | |
tree | 3601d11524a489ec47ce5847a3a8d20e72032751 /src/gui/palette.cpp | |
parent | 3ba28f181216a150b3a59d912a8bbd9f8392f901 (diff) | |
download | plus-59dc4ad66d2552ae1809555abd3c1e0faf99209f.tar.gz plus-59dc4ad66d2552ae1809555abd3c1e0faf99209f.tar.bz2 plus-59dc4ad66d2552ae1809555abd3c1e0faf99209f.tar.xz plus-59dc4ad66d2552ae1809555abd3c1e0faf99209f.zip |
improve palette class.
Diffstat (limited to 'src/gui/palette.cpp')
-rw-r--r-- | src/gui/palette.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index df77a8fe7..bc363bb35 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -49,7 +49,6 @@ const gcn::Color Palette::RAINBOW_COLORS[7] = gcn::Color(153, 0, 153) }; -/** Number of Elemets of RAINBOW_COLORS */ const int Palette::RAINBOW_COLOR_COUNT = 7; Palette::Palette(const int size) : @@ -66,7 +65,7 @@ Palette::~Palette() mInstances.erase(this); } -const gcn::Color& Palette::getCharColor(const signed char c, bool &valid) +const gcn::Color& Palette::getCharColor(const signed char c, bool &valid) const { const CharColors::const_iterator it = mCharColors.find(c); if (it != mCharColors.end()) @@ -79,7 +78,7 @@ const gcn::Color& Palette::getCharColor(const signed char c, bool &valid) return BLACK; } -int Palette::getIdByChar(const signed char c, bool &valid) +int Palette::getIdByChar(const signed char c, bool &valid) const { const CharColors::const_iterator it = mCharColors.find(c); if (it != mCharColors.end()) @@ -102,7 +101,6 @@ void Palette::advanceGradient() { if (get_elapsed_time(mRainbowTime) > 5) { - int pos, colIndex, colVal, delay, numOfColors; // 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. @@ -111,30 +109,32 @@ void Palette::advanceGradient() for (size_t i = 0, sz = mGradVector.size(); i < sz; i++) { - if (!mGradVector[i]) + ColorElem *const elem = mGradVector[i]; + if (!elem) continue; - delay = mGradVector[i]->delay; + int delay = elem->delay; - if (mGradVector[i]->grad == PULSE) + if (elem->grad == PULSE) delay = delay / 20; - numOfColors = (mGradVector[i]->grad == SPECTRUM ? 6 : - mGradVector[i]->grad == PULSE ? 127 : - RAINBOW_COLOR_COUNT); + const int numOfColors = (elem->grad == SPECTRUM ? 6 : + elem->grad == PULSE ? 127 : + RAINBOW_COLOR_COUNT); - mGradVector[i]->gradientIndex = - (mGradVector[i]->gradientIndex + advance) % - (delay * numOfColors); + elem->gradientIndex = (elem->gradientIndex + advance) + % (delay * numOfColors); - pos = mGradVector[i]->gradientIndex % delay; + const int gradIndex = elem->gradientIndex; + const int pos = gradIndex % delay; + int colIndex; if (delay) - colIndex = mGradVector[i]->gradientIndex / delay; + colIndex = gradIndex / delay; else - colIndex = mGradVector[i]->gradientIndex; + colIndex = gradIndex; - ColorElem *const elem = mGradVector[i]; gcn::Color &color = elem->color; + int colVal; if (elem->grad == PULSE) { |