Refactoring from James H: the highlight and lowlight colour setup

common to Fifteen, Sixteen, Twiddle and Pegs is now a utility
function in misc.c.

[originally from svn r6076]
This commit is contained in:
Simon Tatham
2005-07-06 18:27:40 +00:00
parent d4001cbc0d
commit 753339737e
6 changed files with 37 additions and 76 deletions

View File

@ -706,28 +706,11 @@ static float *game_colours(frontend *fe, game_state *state, int *ncolours)
{
float *ret = snewn(3 * NCOLOURS, float);
int i;
float max;
frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
game_mkhighlight(fe, ret, COL_BACKGROUND, COL_HIGHLIGHT, COL_LOWLIGHT);
/*
* Drop the background colour so that the highlight is
* noticeably brighter than it while still being under 1.
*/
max = ret[COL_BACKGROUND*3];
for (i = 1; i < 3; i++)
if (ret[COL_BACKGROUND*3+i] > max)
max = ret[COL_BACKGROUND*3+i];
if (max * 1.2F > 1.0F) {
for (i = 0; i < 3; i++)
ret[COL_BACKGROUND*3+i] /= (max * 1.2F);
}
for (i = 0; i < 3; i++) {
ret[COL_HIGHLIGHT * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 1.2F;
ret[COL_LOWLIGHT * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 0.8F;
for (i = 0; i < 3; i++)
ret[COL_TEXT * 3 + i] = 0.0;
}
*ncolours = NCOLOURS;
return ret;