-
Notifications
You must be signed in to change notification settings - Fork 1
/
color.cpp
executable file
·53 lines (43 loc) · 1.21 KB
/
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
52
53
#include "color.hpp"
Color::Color(const float r, const float g, const float b)
{
std::get<0>(data) = r;
std::get<1>(data) = g;
std::get<2>(data) = b;
}
float Color::r() const
{
return std::get<0>(data);
}
float Color::g() const
{
return std::get<1>(data);
}
float Color::b() const
{
return std::get<2>(data);
}
Color operator +(const Color &color, const Color &another)
{
return Color(color.r() + another.r(), color.g() + another.g(), color.b() + another.b());
}
Color operator -(const Color &color, const Color &another)
{
return Color(color.r() - another.r(), color.g() - another.g(), color.b() - another.b());
}
Color operator *(const Color &color, const Color &another)
{
return Color(color.r() * another.r(), color.g() * another.g(), color.b() * another.b());
}
Color operator *(const Color &color, float scalar)
{
return Color(color.r() * scalar, color.g() * scalar, color.b() * scalar);
}
Color operator /(const Color &color, const Color &another)
{
return Color(color.r() / another.r(), color.g() / another.g(), color.b() / another.b());
}
Color operator /(const Color &color, float scalar)
{
return Color(color.r() / scalar, color.g() / scalar, color.b() / scalar);
}