-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcolor.cpp
127 lines (108 loc) · 2.84 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**********************************************************
* Jigsaw *
* A jigsaw puzzle creator/solver/game *
* by Ed Salisbury (ed@edsalisbury.net), *
* Matt Goralczyk (matthew.goralczyk@ucdenver.edu), *
* and James Brayton (james.brayton@gmail.com) *
* (c)2012, Some Rights Reserved *
**********************************************************/
/*
* License:
* Except where otherwise noted, this work is licensed under Creative Commons
* Attribution ShareAlike 3.0.
*
* You are free:
* ~ to Share -- to copy, distribute and transmit the work
* ~ to Remix -- to adapt the work
*
* Under the following conditions:
* ~ Attribution. You must attribute the work in the manner specified by the
* author or licensor (but not in any way that suggests that they endorse
* you or your use of the work).
* ~ Share Alike. If you alter, transform, or build upon this work, you may
* distribute the resulting work only under the same, similar or a
* compatible license.
* ~ For any reuse or distribution, you must make clear to others the license
* terms of this work. The best way to do this is with a link to the
* license's web page (http://creativecommons.org/licenses/by-sa/3.0/)
* ~ Any of the above conditions can be waived if you get permission from the
* copyright holder.
* ~ Nothing in this license impairs or restricts the author's moral rights.
*/
#include "color.h"
Color::Color()
{
mRed = 0;
mBlue = 0;
mGreen = 0;
mAlpha = 0;
}
Color::Color(UINT red, UINT green, UINT blue, UINT alpha)
{
mRed = red;
mGreen = green;
mBlue = blue;
mAlpha = alpha;
}
UINT Color::Red() const
{
return mRed;
}
UINT Color::Green() const
{
return mGreen;
}
UINT Color::Blue() const
{
return mBlue;
}
UINT Color::Alpha() const
{
return mAlpha;
}
void Color::Red(UINT color)
{
mRed = color;
}
void Color::Green(UINT color)
{
mGreen = color;
}
void Color::Blue(UINT color)
{
mBlue = color;
}
void Color::Alpha(UINT alpha)
{
mAlpha = alpha;
}
bool Color::operator==(const Color& other) const
{
if (mRed == other.Red() && mGreen == other.Green() && mBlue == other.Blue() && mAlpha == other.Alpha())
{
return true;
}
return false;
}
bool Color::operator!=(const Color& other) const
{
return !(*this == other);
}
Color& Color::operator=(const Color& other)
{
if (this == &other)
return *this;
mRed = other.Red();
mGreen = other.Green();
mBlue = other.Blue();
mAlpha = other.Alpha();
return *this;
}
std::ostream& operator << (std::ostream& out, const Color& color)
{
out << color.Red() << ", ";
out << color.Green() << ", ";
out << color.Blue() << ", ";
out << color.Alpha();
return out;
}