-
Notifications
You must be signed in to change notification settings - Fork 0
/
Color.hpp
51 lines (44 loc) · 1.54 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
#ifndef __prog_Color_hpp__
#define __prog_Color_hpp__
namespace prog
{
typedef unsigned char rgb_value; // Defines the type rgb_value holding values from 0 to 255 (the RGB spectrum).
/*
Represents colors using primary colors red, green and blue with 8-bits per RGB channel.
Also implemented functions to obtain, modify and compare these values.
*/
class Color
{
private:
// Color's red rgb_value.
rgb_value r;
// Color's green rgb_value.
rgb_value g;
// Color's blue rgb_value.
rgb_value b;
public:
// Default constructor, creates the color black.
Color();
// Copy constructor.
Color(const Color &c);
// Constructor with arguments (arguments red, green and blue).
Color(rgb_value r, rgb_value g, rgb_value b);
// Gets the red RGB channel value.
rgb_value red() const;
// Sets the red RGB channel value.
rgb_value &red();
// Gets the green RGB channel value.
rgb_value green() const;
// Sets the green RGB channel value.
rgb_value &green();
// Gets the blue RGB channel value.
rgb_value blue() const;
// Sets the green RGB channel value.
rgb_value &blue();
// Operator for equality comparison between 2 colors.
bool operator==(const Color &other) const;
// Operator for difference comparison between 2 colors.
bool operator!=(const Color &other) const;
};
}
#endif