-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColor.hpp
84 lines (70 loc) · 1.9 KB
/
Color.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef COLOR_HPP_
#define COLOR_HPP_
#include <cstdint>
#define IS_LITTLE_ENDIAN (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
namespace arcade
{
///
/// \union Color
/// \brief Union to store RGBa color
///
union Color
{
///
/// \fn Color(uint32_t c = Black.full)
/// \brief Constructor to create color from a 4 bytes integer
/// \param[in] c 4 bytes integer value containing a color
///
Color(uint32_t c = Black.full);
///
/// \fn Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
/// \brief Constructor to create color from a 4 color component
/// \param[in] r Red color component value
/// \param[in] g Green color component value
/// \param[in] b Blue color component value
/// \param[in] a Alpha (opacity) color component value
///
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
bool operator==(Color const& col);
bool operator!=(Color const& col);
bool operator<=(Color const& col);
bool operator>=(Color const& col);
bool operator<(Color const& col);
bool operator>(Color const& col);
///
/// \fn Color(Color const &c)
/// \brief Constructor to copy a Color
/// \param[in] c Color to be copied
///
Color(Color const &c);
static const Color Black; /// Black color
static const Color White; /// White color
static const Color Red; /// Red color
static const Color Green; /// Green color
static const Color Blue; /// Blue color
static const Color Yellow; /// Yellow color
static const Color Magenta; /// Magenta color
static const Color Cyan; /// Cyan color
static const Color Transparent; /// Transparent color
uint32_t full; /// 4 bytes integer value of the color
uint8_t rgba[4]; /// array of the 4 color component
#if IS_LITTLE_ENDIAN
struct
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
};
#else
struct
{
uint8_t a;
uint8_t b;
uint8_t g;
uint8_t r;
};
#endif
};
}
#endif // !COLOR_HPP_