-
Notifications
You must be signed in to change notification settings - Fork 1
/
color.h
36 lines (32 loc) · 1.04 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
//color.h
#ifndef _COLOR_H_
#define _COLOR_H_
class Color
{
public:
Color(double val) {r = g = b = val;}
Color(double red, double green, double blue);
Color(const Color & c) {*this = c;}
void R(double red) {r = red;}
void G(double green) {g = green;}
void B(double blue) {b = blue;}
double R() const {return r;}
double G() const {return g;}
double B() const {return b;}
void clamp();
//define some operators for this class:
Color& operator=(const Color& rhs);
friend Color operator * (const Color& c, double f);
friend Color operator * (double f, const Color& c);
friend Color operator * (const Color& c1, const Color& c2);
friend Color operator / (const Color& c, double f);
friend Color operator + (const Color& c1, const Color& c2);
//private:
//Data members are not private because of performance hits.
//Its better to access directly in critical cases than to use functions!
double r;
double g;
double b;
float maxComponent();
};
#endif