-
Notifications
You must be signed in to change notification settings - Fork 0
/
rgb.h
45 lines (41 loc) · 1.19 KB
/
rgb.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
#ifndef _RGB_H_
#define _RGB_H_ 1
/**
* this class defines color in rgb colorspace, each component varies in [0,1]
* there might be other colorspaces such as yuv. when needed, defines it as follow
*/
class rgb{
public:
// constructors
rgb(double _r,double _g,double _b);
rgb(const rgb &_orig);
rgb();
double operator[](int i)const;
double &operator[](int i);
double getR()const;
double getG()const;
double getB()const;
void setR(double _r);
void setG(double _g);
void setB(double _b);
// operators
friend rgb operator+(const rgb &c1,const rgb &c2);
friend rgb operator-(const rgb &c1,const rgb &c2);
friend rgb operator*(const rgb &c1,double scale);
friend rgb operator*(double scale,const rgb &c1);
friend rgb operator*(const rgb &c1,const rgb &c2);
friend rgb operator/(const rgb &c1,double scale);
friend rgb operator/(double scale,const rgb &c1);
friend rgb operator/(const rgb &c1,const rgb &c2);
const rgb &operator+()const;
rgb operator-()const;
rgb &operator+=(const rgb &c);
rgb &operator-=(const rgb &c);
rgb &operator*=(double scale);
rgb &operator*=(const rgb &c);
rgb &operator/=(double scale);
rgb &operator/=(const rgb &c);
private:
double r,g,b;
};
#endif // _RGB_H_