This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Color.hpp
90 lines (80 loc) · 2.17 KB
/
Color.hpp
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
#ifndef __prog_Color_hpp__
#define __prog_Color_hpp__
#include <string>
namespace prog
{
typedef unsigned char rgb_value;
/**
* @brief Color representation as 3 integer values (red, green and blue).
*/
class Color
{
private:
rgb_value red_;
rgb_value green_;
rgb_value blue_;
public:
/**
* @brief Constructs the color black (0, 0, 0).
* @author Joana Noites
*/
Color();
/**
* @brief Constructs a color by copy.
* @author Joana Noites
*
* @param c Color to copy
*/
Color(const Color& other);
/**
* @brief Constructs a new Color object with provided rgb values red,
* green and blue.
* @author Joana Noites
*
* @param red Red value
* @param green Green value
* @param blue Blue value
*/
Color(rgb_value red, rgb_value green, rgb_value blue);
/**
* @brief Constructs a Color object with its hexadecimal representation.
* @author Bruno Oliveira & João Mendes
*
* @param hex String with hexadecimal value of the color, in the format
* #XXXXXX
*/
Color(const std::string& hex);
rgb_value red() const;
rgb_value& red();
rgb_value green() const;
rgb_value& green();
rgb_value blue() const;
rgb_value& blue();
/**
* @brief Operator '=='.
* @author Bruno Oliveira
*
* @param other Color to compare.
*
* @return Whether all RGB values match those of other.
*/
bool operator==(const Color& other) const;
/**
* @brief Operator '!='.
* @author Bruno Oliveira
*
* @param other Color to compare.
*
* @return Whether any RGB value differs from other's respective.
*/
bool operator!=(const Color& other) const;
/**
* @brief Transforms a color into its corresponding hexidecimal representation.
* @author Bruno Oliveira & Joana Noites
*
* @return String with hexadecimal value of the color, in the format #XXXXXX.
*/
std::string to_hex() const;
};
}
#endif