-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor.hh
More file actions
245 lines (227 loc) · 8.52 KB
/
color.hh
File metadata and controls
245 lines (227 loc) · 8.52 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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#ifndef OBJSDL_COLOR_HH
#define OBJSDL_COLOR_HH
#include <tuple>
#include "short_types.hh"
namespace SDL {
enum class BlendMode {
normal,
multiply,
screen,
overlay,
hard_light,
soft_light_photoshop,
soft_light_pegtop,
soft_light_illusions_hu,
soft_light_w3c,
color_dodge,
linear_dodge,
divide,
color_burn,
linear_burn,
vivid_light,
linear_light,
subtract,
add,
difference,
darken_only,
lighten_only,
hue,
saturation,
color,
perceived_luminocity_color,
luminocity,
perceived_luminocity,
alpha_compositing,
average
};
struct Color {
uchar r;
uchar g;
uchar b;
uchar a;
Color(); // black
Color(cuchar r, cuchar g, cuchar b, cuchar a=255);
Color(cuchar luminocity, cuchar a=255);
uchar luminocity() const;
uchar perceived_luminocity() const;
Color with_luminocity(cuchar luminocity) const;
Color with_perceived_luminocity(cuchar luminocity) const;
uchar max() const;
uchar min() const;
std::tuple<uchar, uchar, uchar> cmy() const;
static Color from_cmy(cuchar c, cuchar m, cuchar y, cuchar a=255);
uchar hue() const;
std::tuple<uchar, uchar, uchar> hsv() const;
static Color from_hsv(cuchar h, cuchar s, cuchar v, cuchar a=255);
std::tuple<uchar, uchar, uchar> hsl() const;
static Color from_hsl(cuchar h, cuchar s, cuchar l, cuchar a=255);
Color inverted() const;
Color with_alpha(cuchar alpha) const;
Color opaque() const;
static Color blend(
const Color bottom,
const Color top,
const BlendMode mode=BlendMode::alpha_compositing
);
struct colors { // namespace
colors(); // raises error.
static const Color alice_blue;
static const Color antique_white;
static const Color aqua;
static const Color aquamarine;
static const Color azure;
static const Color beige;
static const Color bisque;
static const Color black;
static const Color blanched_almond;
static const Color blue;
static const Color blue_violet;
static const Color brown;
static const Color burly_wood;
static const Color cadet_blue;
static const Color chartreuse;
static const Color chocolate;
static const Color coral;
static const Color cornflower_blue;
static const Color cornsilk;
static const Color crimson;
static const Color cyan;
static const Color dark_blue;
static const Color dark_cyan;
static const Color dark_golden_rod;
static const Color dark_gray;
static const Color dark_grey;
static const Color dark_green;
static const Color dark_khaki;
static const Color dark_magenta;
static const Color dark_olive_green;
static const Color dark_orange;
static const Color dark_orchid;
static const Color dark_red;
static const Color dark_salmon;
static const Color dark_sea_green;
static const Color dark_slate_blue;
static const Color dark_slate_gray;
static const Color dark_slate_grey;
static const Color dark_turquoise;
static const Color dark_violet;
static const Color deep_pink;
static const Color deep_sky_blue;
static const Color dim_gray;
static const Color dim_grey;
static const Color dodger_blue;
static const Color fire_brick;
static const Color floral_white;
static const Color forest_green;
static const Color fuchsia;
static const Color gainsboro;
static const Color ghost_white;
static const Color gold;
static const Color golden_rod;
static const Color gray;
static const Color grey;
static const Color green;
static const Color green_yellow;
static const Color honey_dew;
static const Color hot_pink;
static const Color indian_red;
static const Color indigo;
static const Color ivory;
static const Color khaki;
static const Color lavender;
static const Color lavender_bush;
static const Color lawn_green;
static const Color lemon_chiffon;
static const Color light_blue;
static const Color light_coral;
static const Color light_cyan;
static const Color light_golden_rod_yellow;
static const Color light_gray;
static const Color light_grey;
static const Color light_green;
static const Color light_pink;
static const Color light_salmon;
static const Color light_sea_green;
static const Color light_sky_blue;
static const Color light_slate_gray;
static const Color light_slate_grey;
static const Color light_steel_blue;
static const Color light_yellow;
static const Color lime;
static const Color lime_green;
static const Color linen;
static const Color magenta;
static const Color maroon;
static const Color medium_aqua_marine;
static const Color medium_blue;
static const Color medium_orchid;
static const Color medium_purple;
static const Color medium_sea_green;
static const Color medium_slate_blue;
static const Color medium_spring_green;
static const Color medium_turquoise;
static const Color medium_violet_red;
static const Color midnight_blue;
static const Color mint_cream;
static const Color misty_rose;
static const Color moccasin;
static const Color navajo_white;
static const Color navy;
static const Color old_lace;
static const Color olive;
static const Color olive_drab;
static const Color orange;
static const Color orange_red;
static const Color orchid;
static const Color pale_golden_rod;
static const Color pale_green;
static const Color pale_turquoise;
static const Color pale_violet_red;
static const Color papaya_whip;
static const Color peach_puff;
static const Color peru;
static const Color pink;
static const Color plum;
static const Color powder_blue;
static const Color purple;
static const Color reecca_pruple;
static const Color red;
static const Color rosy_brown;
static const Color royal_blue;
static const Color saddle_brown;
static const Color salmon;
static const Color sandy_brown;
static const Color sea_green;
static const Color sea_shell;
static const Color sienna;
static const Color silver;
static const Color sky_blue;
static const Color slate_blue;
static const Color slate_gray;
static const Color slate_grey;
static const Color snow;
static const Color spring_green;
static const Color steel_blue;
static const Color tan;
static const Color teal;
static const Color thistle;
static const Color tomato;
static const Color turquoise;
static const Color violet;
static const Color wheat;
static const Color white;
static const Color white_smoke;
static const Color yellow;
static const Color yellow_green;
static const Color transparent;
};
};
Color operator+(const Color, const Color);
Color operator-(const Color, const Color);
Color operator*(const Color, const Color);
Color operator/(const Color, const Color);
Color operator*(cfloat, const Color);
Color operator*(const Color, cfloat);
Color operator/(const Color, cfloat);
}
#endif