chiark / gitweb /
Refactoring from James H: the highlight and lowlight colour setup
[sgt-puzzles.git] / twiddle.c
index ac6f385dfd47f98e40527de91a865e5e604bc1fa..3e9e74e6f2450e398ad5733c6a40b8a6ad122ed6 100644 (file)
--- a/twiddle.c
+++ b/twiddle.c
@@ -765,27 +765,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]);
-
-    /*
-     * 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);
-    }
+    game_mkhighlight(fe, ret, COL_BACKGROUND, COL_HIGHLIGHT, COL_LOWLIGHT);
 
     for (i = 0; i < 3; i++) {
-        ret[COL_HIGHLIGHT * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 1.2F;
         ret[COL_HIGHLIGHT_GENTLE * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 1.1F;
-        ret[COL_LOWLIGHT * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 0.8F;
         ret[COL_LOWLIGHT_GENTLE * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 0.9F;
         ret[COL_TEXT * 3 + i] = 0.0;
     }