This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
forked from rpbpolis/spic-prj-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Color.hpp
200 lines (173 loc) · 6.75 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#ifndef COLOR_H_
#define COLOR_H_
namespace spic {
/**
* @brief Color represents a red-green-blue color with alpha.
* @spicapi
*/
class Color {
public:
/**
* @brief Constructor, accepting an rgb value.
* @param red The red component, 0 ≤ r ≤ 1.
* @param green The green component, 0 ≤ g ≤ 1.
* @param blue The blue component, 0 ≤ b ≤ 1.
* @sharedapi
*/
Color(double red, double green, double blue);
/**
* @brief Constructor, accepting an rgb value and an alpha (transparency).
* @param red The red component, 0 ≤ r ≤ 1.
* @param green The green component, 0 ≤ g ≤ 1.
* @param blue The blue component, 0 ≤ b ≤ 1.
* @param alpha The transparency component, 0 ≤ alpha ≤ 1.
* @spicapi
*/
Color(double red, double green, double blue, double alpha);
/**
* @brief One of the standard colors (read-only): white.
* @return A reference to a statically allocated Color instance.
* @spicapi
*/
static const Color& white() { return _white; }
/**
* @brief One of the standard colors (read-only): red.
* @return A reference to a statically allocated Color instance.
* @spicapi
*/
static const Color& red() { return _red; }
/**
* @brief One of the standard colors (read-only): green.
* @return A reference to a statically allocated Color instance.
* @spicapi
*/
static const Color& green() { return _green; }
/**
* @brief One of the standard colors (read-only): blue.
* @return A reference to a statically allocated Color instance.
* @spicapi
*/
static const Color& blue() { return _blue; }
/**
* @brief One of the standard colors (read-only): cyan.
* @return A reference to a statically allocated Color instance.
* @spicapi
*/
static const Color& cyan() { return _cyan; }
/**
* @brief One of the standard colors (read-only): magenta.
* @return A reference to a statically allocated Color instance.
* @spicapi
*/
static const Color& magenta() { return _magenta; }
/**
* @brief One of the standard colors (read-only): yellow.
* @return A reference to a statically allocated Color instance.
* @spicapi
*/
static const Color& yellow() { return _yellow; }
/**
* @brief One of the standard colors (read-only): black.
* @return A reference to a statically allocated Color instance.
* @spicapi
*/
static const Color& black() { return _black; }
/**
* @brief One of the standard colors (read-only): purple.
* @return A reference to a statically allocated Color instance.
* @sharedapi
*/
static const Color& purple();
/**
* @brief One of the standard colors (read-only): lime.
* @return A reference to a statically allocated Color instance.
* @sharedapi
*/
static const Color& lime();
/**
* @brief One of the standard colors (read-only): orange.
* @return A reference to a statically allocated Color instance.
* @sharedapi
*/
static const Color& orange();
/**
* @brief One of the standard colors (read-only): transparent.
* @return A reference to a statically allocated Color instance.
* @sharedapi
*/
static const Color& transparent();
// ... more standard colors here
/**
* @brief Set the RGB values of the color
* @param red The red part of the color
* @param green The green part of the color
* @param blue The blue part of the color
* @sharedapi
*/
void SetColor(double red, double green, double blue);
/**
* @brief Set the RGBA values of the color
* @param red The red part of the color
* @param green The green part of the color
* @param blue The blue part of the color
* @param alpha The alpha part of the color
* @sharedapi
*/
void SetColor(double red, double green, double blue, double alpha);
/**
* @brief The red part of the color
* @return A reference to the statically red part of the color.
* @sharedapi
*/
double R() const;
/**
* @brief The green part of the color
* @return A reference to the statically green part of the color.
* @sharedapi
*/
double G() const;
/**
* @brief The blue part of the color
* @return A reference to the statically blue part of the color.
* @sharedapi
*/
double B() const;
/**
* @brief The alpha part of the color
* @return A reference to the statically alpha part of the color.
* @sharedapi
*/
double A() const;
/**
* @brief Compare two instances of a color.
* @param rhs The instance to compare to this.
* @return Whether the two color are the same.
*/
bool operator==(const Color& rhs) const;
/**
* @brief Compare two instances of a color.
* @param rhs The instance to compare to this.
* @return Whether the two color are not the same.
*/
bool operator!=(const Color& rhs) const;
private:
double r;
double g;
double b;
double a;
static Color _white;
static Color _red;
static Color _green;
static Color _blue;
static Color _cyan;
static Color _magenta;
static Color _yellow;
static Color _black;
static Color _purple;
static Color _lime;
static Color _orange;
static Color _transparent;
// ... more standard color here
};
}
#endif // COLOR_H_