Merge branch 'master' into jgrpp
# Conflicts: # src/genworld_gui.cpp # src/gfx.cpp # src/lang/korean.txt # src/linkgraph/linkgraph_gui.cpp # src/linkgraph/linkgraph_gui.h # src/music.cpp # src/table/settings.ini # src/town_cmd.cpp # src/train_cmd.cpp
This commit is contained in:
@@ -1111,6 +1111,7 @@ void DoPaletteAnimations()
|
||||
/**
|
||||
* Determine a contrasty text colour for a coloured background.
|
||||
* @param background Background colour.
|
||||
* @param threshold Background colour brightness threshold below which the background is considered dark and TC_WHITE is returned, range: 0 - 255, default 128.
|
||||
* @return TC_BLACK or TC_WHITE depending on what gives a better contrast.
|
||||
*/
|
||||
TextColour GetContrastColour(uint8 background, uint8 threshold)
|
||||
@@ -1120,7 +1121,7 @@ TextColour GetContrastColour(uint8 background, uint8 threshold)
|
||||
* The following formula computes 1000 * brightness^2, with brightness being in range 0 to 255. */
|
||||
uint sq1000_brightness = c.r * c.r * 299 + c.g * c.g * 587 + c.b * c.b * 114;
|
||||
/* Compare with threshold brightness which defaults to 128 (50%) */
|
||||
return sq1000_brightness < threshold * 128 * 1000 ? TC_WHITE : TC_BLACK;
|
||||
return sq1000_brightness < ((uint) threshold) * ((uint) threshold) * 1000 ? TC_WHITE : TC_BLACK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user