2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file palette_func.h Functions related to palettes. */
10 #ifndef PALETTE_FUNC_H
11 #define PALETTE_FUNC_H
14 #include "strings_type.h"
15 #include "string_type.h"
17 extern Palette _cur_palette
; ///< Current palette
19 bool CopyPalette(Palette
&local_palette
, bool force_copy
= false);
20 void GfxInitPalettes();
22 uint8_t GetNearestColourIndex(uint8_t r
, uint8_t g
, uint8_t b
);
24 inline uint8_t GetNearestColourIndex(const Colour colour
)
26 return GetNearestColourIndex(colour
.r
, colour
.g
, colour
.b
);
30 * Checks if a Colours value is valid.
32 * @param colours The value to check
33 * @return true if the given value is a valid Colours.
35 inline bool IsValidColours(Colours colours
)
37 return colours
< COLOUR_END
;
40 TextColour
GetContrastColour(uint8_t background
, uint8_t threshold
= 128);
43 * All 16 colour gradients
44 * 8 colours per gradient from darkest (0) to lightest (7)
46 extern byte _colour_gradient
[COLOUR_END
][8];
49 * Return the colour for a particular greyscale level.
50 * @param level Intensity, 0 = black, 15 = white
53 #define GREY_SCALE(level) (level)
55 static const uint8_t PC_BLACK
= GREY_SCALE(1); ///< Black palette colour.
56 static const uint8_t PC_DARK_GREY
= GREY_SCALE(6); ///< Dark grey palette colour.
57 static const uint8_t PC_GREY
= GREY_SCALE(10); ///< Grey palette colour.
58 static const uint8_t PC_WHITE
= GREY_SCALE(15); ///< White palette colour.
60 static const uint8_t PC_VERY_DARK_RED
= 0xB2; ///< Almost-black red palette colour.
61 static const uint8_t PC_DARK_RED
= 0xB4; ///< Dark red palette colour.
62 static const uint8_t PC_RED
= 0xB8; ///< Red palette colour.
64 static const uint8_t PC_VERY_DARK_BROWN
= 0x56; ///< Almost-black brown palette colour.
66 static const uint8_t PC_ORANGE
= 0xC2; ///< Orange palette colour.
68 static const uint8_t PC_YELLOW
= 0xBF; ///< Yellow palette colour.
69 static const uint8_t PC_LIGHT_YELLOW
= 0x44; ///< Light yellow palette colour.
70 static const uint8_t PC_VERY_LIGHT_YELLOW
= 0x45; ///< Almost-white yellow palette colour.
72 static const uint8_t PC_GREEN
= 0xD0; ///< Green palette colour.
74 static const uint8_t PC_VERY_DARK_BLUE
= 0x9A; ///< Almost-black blue palette colour.
75 static const uint8_t PC_DARK_BLUE
= 0x9D; ///< Dark blue palette colour.
76 static const uint8_t PC_LIGHT_BLUE
= 0x98; ///< Light blue palette colour.
78 static const uint8_t PC_ROUGH_LAND
= 0x52; ///< Dark green palette colour for rough land.
79 static const uint8_t PC_GRASS_LAND
= 0x54; ///< Dark green palette colour for grass land.
80 static const uint8_t PC_BARE_LAND
= 0x37; ///< Brown palette colour for bare land.
81 static const uint8_t PC_RAINFOREST
= 0x5C; ///< Pale green palette colour for rainforest.
82 static const uint8_t PC_FIELDS
= 0x25; ///< Light brown palette colour for fields.
83 static const uint8_t PC_TREES
= 0x57; ///< Green palette colour for trees.
84 static const uint8_t PC_WATER
= 0xC9; ///< Dark blue palette colour for water.
86 #endif /* PALETTE_FUNC_H */