diff options
| author | Simon Tatham <anakin@pobox.com> | 2005-07-06 18:27:40 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2005-07-06 18:27:40 +0000 |
| commit | 753339737ea98fd9caf26a5913f8f210897ef04a (patch) | |
| tree | f70ebcb86e31e818d9bd98123e31977d37c5aa89 /misc.c | |
| parent | d4001cbc0d7e858518849363531af9f15246a911 (diff) | |
| download | puzzles-753339737ea98fd9caf26a5913f8f210897ef04a.zip puzzles-753339737ea98fd9caf26a5913f8f210897ef04a.tar.gz puzzles-753339737ea98fd9caf26a5913f8f210897ef04a.tar.bz2 puzzles-753339737ea98fd9caf26a5913f8f210897ef04a.tar.xz | |
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]
Diffstat (limited to 'misc.c')
| -rw-r--r-- | misc.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -169,4 +169,31 @@ unsigned char *hex2bin(const char *in, int outlen) return ret; } +void game_mkhighlight(frontend *fe, float *ret, + int background, int highlight, int lowlight) +{ + float max; + int i; + + frontend_default_colour(fe, &ret[background * 3]); + + /* + * Drop the background colour so that the highlight is + * noticeably brighter than it while still being under 1. + */ + max = ret[background*3]; + for (i = 1; i < 3; i++) + if (ret[background*3+i] > max) + max = ret[background*3+i]; + if (max * 1.2F > 1.0F) { + for (i = 0; i < 3; i++) + ret[background*3+i] /= (max * 1.2F); + } + + for (i = 0; i < 3; i++) { + ret[highlight * 3 + i] = ret[background * 3 + i] * 1.2F; + ret[lowlight * 3 + i] = ret[background * 3 + i] * 0.8F; + } +} + /* vim: set shiftwidth=4 tabstop=8: */ |