Move inverse function into color_t

This commit is contained in:
Celtic Minstrel 2016-12-11 00:10:35 -05:00
parent 3f0485aaa4
commit 9f102269bc
2 changed files with 11 additions and 12 deletions

View File

@ -19,6 +19,7 @@
#include <ostream>
#include <string>
#include <utility>
#include "global.hpp"
struct SDL_Color;
@ -223,6 +224,15 @@ struct color_t
std::max<uint8_t>(a, c.a),
};
}
CONSTEXPR color_t inverse() const {
return {
static_cast<uint8_t>(255 - r),
static_cast<uint8_t>(255 - g),
static_cast<uint8_t>(255 - b),
a
};
}
};
inline std::ostream& operator<<(std::ostream& s, const color_t& c)

View File

@ -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<uint8_t>(255 - color.r),
static_cast<uint8_t>(255 - color.g),
static_cast<uint8_t>(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},