-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor.hpp
More file actions
41 lines (34 loc) · 1.31 KB
/
Copy pathColor.hpp
File metadata and controls
41 lines (34 loc) · 1.31 KB
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
#pragma once
namespace CGF
{
enum ColorComponent{R = 0, G, B, A};
////////////////////////////////////////////////////////////////////////////////
/*!
@class Color
@brief Simple color class, individual colors must be in the range [0,255]
Alpha is assumed to be 255 (opaque) if not specified
*/
////////////////////////////////////////////////////////////////////////////////
class Color
{
public:
Color() : mColorRGBA{0, 0, 0, 255} {}
Color(const unsigned char r, const unsigned char g, const unsigned char b) : mColorRGBA{r, g, b, 255} {}
Color(const unsigned char r, const unsigned char g, const unsigned char b, const unsigned char a) : mColorRGBA{r, g, b, a} {}
Color(const Color & rhs) = default;
Color & operator=(const Color & rhs) = default;
~Color() = default;
// Getter
unsigned char GetR() const { return mColorRGBA[R]; }
unsigned char GetG() const { return mColorRGBA[G]; }
unsigned char GetB() const { return mColorRGBA[B]; }
unsigned char GetA() const { return mColorRGBA[A]; }
// Setter
void SetR(const unsigned char r) { mColorRGBA[R] = r; }
void SetG(const unsigned char g) { mColorRGBA[G] = g; }
void SetB(const unsigned char b) { mColorRGBA[B] = b; }
void SetA(const unsigned char a) { mColorRGBA[A] = a; }
private:
unsigned char mColorRGBA[4];
}; // class Color
} // namespace CGF