-
Notifications
You must be signed in to change notification settings - Fork 0
/
color.cpp
48 lines (38 loc) · 623 Bytes
/
color.cpp
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
#ifndef _COLOR_SIMPLE_INCLUDED_
#define _COLOR_SIMPLE_INCLUDED_
class Color{
public:
unsigned char r;
unsigned char g;
unsigned char b;
char a = -1;
Color(){
}
Color(unsigned char R, unsigned char G, unsigned char B, char A){
r = R;
g = G;
b = B;
a = A;
}
Color(const Color& cc){
r = cc.r;
g = cc.g;
b = cc.b;
a = cc.a;
}
Color operator*(double d){
double tr, tg, tb;
tr = d*r;
tg = d*g;
tb = d*b;
unsigned char R,G,B;
if(tr > 255) R = 255;
else R = tr;
if(tg > 255) G = 255;
else G = tg;
if(tb > 255) B = 255;
else B = tb;
return Color(R, G, B, a);
}
};
#endif