Add color hex output
This commit is contained in:
parent
b6fd6630dc
commit
b0fd3562cf
1 changed files with 27 additions and 0 deletions
|
|
@ -163,6 +163,33 @@ namespace psemek::gfx
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
struct as_hex
|
||||||
|
{
|
||||||
|
geom::vector<std::uint8_t, N> color;
|
||||||
|
|
||||||
|
as_hex(geom::vector<std::uint8_t, N> const & color)
|
||||||
|
: color{color}
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename OStream, std::size_t N>
|
||||||
|
OStream & operator << (OStream & os, as_hex<N> const & c)
|
||||||
|
{
|
||||||
|
static auto const hex_v = [](std::uint8_t value) -> char
|
||||||
|
{
|
||||||
|
if (value < 10)
|
||||||
|
return '0' + value;
|
||||||
|
else
|
||||||
|
return 'a' + (value - 10);
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto v : c.color.coords)
|
||||||
|
os << hex_v(v >> 4) << hex_v(v & 15);
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
struct generic_color
|
struct generic_color
|
||||||
{
|
{
|
||||||
color_4f c;
|
color_4f c;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue