diff --git a/src/color.hpp b/src/color.hpp index c602b58c6c0b..63ed890c5e43 100644 --- a/src/color.hpp +++ b/src/color.hpp @@ -19,6 +19,7 @@ #include #include #include +#include "global.hpp" struct SDL_Color; @@ -223,6 +224,15 @@ struct color_t std::max(a, c.a), }; } + + CONSTEXPR color_t inverse() const { + return { + static_cast(255 - r), + static_cast(255 - g), + static_cast(255 - b), + a + }; + } }; inline std::ostream& operator<<(std::ostream& s, const color_t& c) diff --git a/src/font/standard_colors.cpp b/src/font/standard_colors.cpp index 19624ab47708..c93a0c867b88 100644 --- a/src/font/standard_colors.cpp +++ b/src/font/standard_colors.cpp @@ -16,17 +16,6 @@ namespace font { -// TODO: evalulate whether this should become a color_t member -static color_t inverse(const color_t& color) -{ - return { - static_cast(255 - color.r), - static_cast(255 - color.g), - static_cast(255 - color.b), - 255 // TODO: should we respect alpha? - }; -} - const color_t NORMAL_COLOR {0xDD, 0xDD, 0xDD}, GRAY_COLOR {0x77, 0x77, 0x77}, @@ -41,7 +30,7 @@ const color_t LABEL_COLOR {0x6B, 0x8C, 0xFF}, BIGMAP_COLOR {0xFF, 0xFF, 0xFF}; -const color_t DISABLED_COLOR = inverse(PETRIFIED_COLOR); +const color_t DISABLED_COLOR = PETRIFIED_COLOR.inverse(); const color_t weapon_color {245, 230, 193},