Class controlling the game's color palette.
Definition at line 44 of file palette.h.
void Palette::advanceGradient |
( |
| ) |
|
|
protected |
Definition at line 85 of file palette.cpp.
93 const int advance = time / 5;
95 for (
size_t i = 0, sz =
mGradVector.size(); i < sz; i++)
101 int delay = elem->delay;
111 elem->gradientIndex = (elem->gradientIndex + advance)
112 % (delay * numOfColors);
114 const int gradIndex = elem->gradientIndex;
115 const int pos = delay != 0 ? (gradIndex % delay) : gradIndex;
118 colIndex = gradIndex / delay;
120 colIndex = gradIndex;
122 Color &color = elem->color;
128 sin(M_PI * colIndex / numOfColors));
130 const Color &col = elem->testColor;
132 color.
r = ((colVal * col.
r) / 255) % (col.
r + 1);
133 color.
g = ((colVal * col.
g) / 255) % (col.
g + 1);
134 color.
b = ((colVal * col.
b) / 255) % (col.
b + 1);
138 if ((colIndex % 2) != 0)
143 (cos(M_PI * pos / delay) + 1) / 2);
148 (cos(M_PI * pos) + 1) / 2);
155 colVal =
CAST_S32(255.0 * (cos(M_PI *
156 (delay - pos) / delay) + 1) / 2);
160 colVal =
CAST_S32(255.0 * (cos(M_PI *
161 (delay - pos)) + 1) / 2);
165 color.
r = (colIndex == 0 || colIndex == 5) ? 255 :
166 (colIndex == 1 || colIndex == 4) ? colVal : 0;
167 color.
g = (colIndex == 1 || colIndex == 2) ? 255 :
168 (colIndex == 0 || colIndex == 3) ? colVal : 0;
169 color.
b = (colIndex == 3 || colIndex == 4) ? 255 :
170 (colIndex == 2 || colIndex == 5) ? colVal : 0;
181 startColVal = (cos(M_PI * pos / delay) + 1) / 2;
185 destColVal = 1 - startColVal;
188 * startCol.
r + destColVal * destCol.
r);
191 * startCol.
g + destColVal * destCol.
g);
194 * startCol.
b + destColVal * destCol.
b);
static const Color RAINBOW_COLORS[7]
static const int RAINBOW_COLOR_COUNT
GradientType ::T GradientTypeT
int get_elapsed_time(const int startTime)
References A_NONNULLPOINTER, Color::b, CAST_S32, Color::g, get_elapsed_time(), mGradVector, mRainbowTime, GradientType::PULSE, Color::r, GradientType::RAINBOW, RAINBOW_COLOR_COUNT, RAINBOW_COLORS, GradientType::SPECTRUM, and tick_time.