Skip to content

Commit

Permalink
Move inverse function into color_t
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Dec 11, 2016
1 parent 3f0485a commit 9f10226
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
10 changes: 10 additions & 0 deletions src/color.hpp
Expand Up @@ -19,6 +19,7 @@
#include <ostream>
#include <string>
#include <utility>
#include "global.hpp"

struct SDL_Color;

Expand Down Expand Up @@ -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)
Expand Down
13 changes: 1 addition & 12 deletions src/font/standard_colors.cpp
Expand Up @@ -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},
Expand All @@ -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},
Expand Down

0 comments on commit 9f10226

Please sign in to comment.