2013-11-11 10:00:37 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// STL includes
|
|
|
|
#include <cstdint>
|
|
|
|
#include <ostream>
|
|
|
|
|
|
|
|
struct ColorRgba
|
|
|
|
{
|
|
|
|
/// The red color channel
|
|
|
|
uint8_t red;
|
|
|
|
/// The green color channel
|
|
|
|
uint8_t green;
|
|
|
|
/// The blue color channel
|
|
|
|
uint8_t blue;
|
|
|
|
|
|
|
|
/// The alpha mask channel
|
|
|
|
uint8_t alpha;
|
|
|
|
|
|
|
|
/// 'Black' RgbColor (0, 0, 0, 255)
|
2020-08-08 13:22:37 +02:00
|
|
|
static const ColorRgba BLACK;
|
2013-11-11 10:00:37 +01:00
|
|
|
/// 'Red' RgbColor (255, 0, 0, 255)
|
2020-08-08 13:22:37 +02:00
|
|
|
static const ColorRgba RED;
|
2013-11-11 10:00:37 +01:00
|
|
|
/// 'Green' RgbColor (0, 255, 0, 255)
|
2020-08-08 13:22:37 +02:00
|
|
|
static const ColorRgba GREEN;
|
2013-11-11 10:00:37 +01:00
|
|
|
/// 'Blue' RgbColor (0, 0, 255, 255)
|
2020-08-08 13:22:37 +02:00
|
|
|
static const ColorRgba BLUE;
|
2013-11-11 10:00:37 +01:00
|
|
|
/// 'Yellow' RgbColor (255, 255, 0, 255)
|
2020-08-08 13:22:37 +02:00
|
|
|
static const ColorRgba YELLOW;
|
2013-11-11 10:00:37 +01:00
|
|
|
/// 'White' RgbColor (255, 255, 255, 255
|
2020-08-08 13:22:37 +02:00
|
|
|
static const ColorRgba WHITE;
|
2013-11-11 10:00:37 +01:00
|
|
|
};
|
|
|
|
|
2023-02-17 16:02:51 +01:00
|
|
|
/// Assert to ensure that the size of the structure is 'only' 4 bytes
|
2013-11-11 10:00:37 +01:00
|
|
|
static_assert(sizeof(ColorRgba) == 4, "Incorrect size of ColorARGB");
|
|
|
|
|
|
|
|
///
|
2023-02-17 16:02:51 +01:00
|
|
|
/// Stream operator to write ColorRgba to an outputstream (format "'{'[alpha]', '[red]','[green]','[blue]'}'")
|
2013-11-11 10:00:37 +01:00
|
|
|
///
|
|
|
|
/// @param os The output stream
|
|
|
|
/// @param color The color to write
|
|
|
|
/// @return The output stream (with the color written to it)
|
|
|
|
///
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, const ColorRgba& color)
|
|
|
|
{
|
2020-08-08 13:22:37 +02:00
|
|
|
os << "{"
|
|
|
|
<< color.alpha << ","
|
|
|
|
<< color.red << ","
|
|
|
|
<< color.green << ","
|
|
|
|
<< color.blue
|
|
|
|
<< "}";
|
|
|
|
|
2013-11-11 10:00:37 +01:00
|
|
|
return os;
|
|
|
|
}
|