blob: 494d0b89f71d193bbd35381488879a42425efeae (
plain)
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
85
86
87
88
89
90
91
92
93
94
|
#ifndef NW4R_UT_COLOR_H
#define NW4R_UT_COLOR_H
#include "nw4r/types_nw4r.h"
#include "rvl/GX/GXTypes.h"
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace ut {
class Color : public GXColor {
public:
Color() {
*this = WHITE;
}
Color(u32 color) {
*this = color;
}
Color(int red, int green, int blue, int alpha) {
Set(red, green, blue, alpha);
}
Color(const GXColor &clr) {
*this = clr;
}
~Color() {}
void Set(int red, int green, int blue, int alpha) {
r = red;
g = green;
b = blue;
a = alpha;
}
Color &operator=(u32 color) {
ToU32ref() = color;
return *this;
}
Color &operator=(const GXColor &c) {
*this = *reinterpret_cast<const u32 *>(&c);
return *this;
}
Color operator|(u32 color) {
return Color(ToU32() | color);
}
Color operator&(u32 color) {
return Color(ToU32() & color);
}
u32 &ToU32ref() {
return *reinterpret_cast<u32 *>(this);
}
const u32 &ToU32ref() const {
return *reinterpret_cast<const u32 *>(this);
}
u32 ToU32() const {
return ToU32ref();
}
operator u32() const {
return ToU32ref();
}
operator GXColorS10() const {
GXColorS10 c;
c.r = r;
c.g = g;
c.b = b;
c.a = a;
return c;
}
// clang-format off
static const u32 RED = 0xFF0000FF;
static const u32 GREEN = 0x00FF00FF;
static const u32 BLUE = 0x0000FFFF;
static const u32 CYAN = 0x00FFFFFF;
static const u32 MAGENTA = 0xFF00FFFF;
static const u32 YELLOW = 0xFFFF00FF;
static const u32 BLACK = 0x000000FF;
static const u32 GRAY = 0x808080FF;
static const u32 WHITE = 0xFFFFFFFF;
// clang-format on
} ALIGN_DECL(4);
} // namespace ut
} // namespace nw4r
#endif
|