-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColor.cpp
51 lines (45 loc) · 930 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
49
50
51
#include "Color.h"
#include <assert.h>
/*
* Set Color Black
*/
Color::Color()
{
this->R = 0;
this->G = 0;
this->B = 0;
}
Color::Color( float r, float g, float b)
{
this->R = r;
this->G = g;
this->B = b;
}
Color Color::operator*(const Color& c) const
{
float new_r = this->R * c.R;
float new_g = this->G * c.G;
float new_b = this->B * c.B;
return Color(new_r, new_g, new_b);
}
Color Color::operator*(const float Factor) const
{
float new_r = this->R * Factor;
float new_g = this->G * Factor;
float new_b = this->B * Factor;
return Color(new_r, new_g, new_b);
}
Color Color::operator+(const Color& c) const
{
float new_r = this->R + c.R;
float new_g = this->G + c.G;
float new_b = this->B + c.B;
return Color(new_r, new_g, new_b);
}
Color& Color::operator+=(const Color& c)
{
this->R+= c.R;
this->G+= c.G;
this->B+= c.B;
return *this; // dummy (remove)
}