-
Notifications
You must be signed in to change notification settings - Fork 0
/
Color.h
84 lines (71 loc) · 1.86 KB
/
Color.h
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
//============================================================================
// @name : Color.h
// @author : Ward Gauderis
// @date : 4/28/19
// @version :
// @copyright : BA1 Informatica - Ward Gauderis - University of Antwerp
// @description :
//============================================================================
#ifndef ENGINE_CMAKE_COLOR_H
#define ENGINE_CMAKE_COLOR_H
struct Color {
double red;
double green;
double blue;
Color() {
red = 0;
green = 0;
blue = 0;
}
Color(const std::vector<double> &color) {
red = color[0];
green = color[1];
blue = color[2];
}
Color(const double r, const double g, const double b) {
red = r;
green = g;
blue = b;
}
bool operator<(const Color &comp) const {
if (red < comp.red) return true;
if (comp.red < red) return false;
if (green < comp.green) return true;
if (comp.green < green) return false;
return blue < comp.blue;
}
Color &operator+=(const Color &color) {
red += color.red;
green += color.green;
blue += color.blue;
return *this;
}
Color operator+(const Color &color) const {
Color c = *this;
c += color;
return c;
}
Color &operator*=(const Color &color) {
red *= color.red;
green *= color.green;
blue *= color.blue;
return *this;
}
Color operator*(const Color &color) const {
Color c = *this;
c *= color;
return c;
}
Color &operator*=(const double value) {
red *= value;
green *= value;
blue *= value;
return *this;
}
Color operator*(const double value) const {
Color c = *this;
c *= value;
return c;
}
};
#endif //ENGINE_CMAKE_COLOR_H