-
Notifications
You must be signed in to change notification settings - Fork 0
/
Color.h
123 lines (103 loc) · 2.35 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
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
/** @file Color.h */
#ifndef KQ_COLOR_H
#define KQ_COLOR_H
#include "Common.h"
#include "SDL.h"
/** @brief Represents a color
* This module defines a type for the colors and provides some color related functions.
* It encapsulates a library-dependent color.
*/
class Color
{
// Low level classes allowed to directly manipulate the encapsulated SDL objects
friend class Surface;
friend class TextSurface;
private:
static SDL_Surface *format_surface; /**< a dummy surface used to get a pixel format */
uint32_t internal_value; /**< the SDL 32-bit value representing this color */
SDL_Color internal_color; /**< the SDL color encapsulated */
// some predefined colors
static Color black;
static Color white;
static Color red;
static Color green;
static Color blue;
static Color yellow;
static Color magenta;
static Color cyan;
Color(uint32_t internal_value);
uint32_t get_internal_value() const;
SDL_Color* get_internal_color();
public:
static void initialize();
static void quit();
static Color& get_black();
static Color& get_white();
static Color& get_red();
static Color& get_green();
static Color& get_blue();
static Color& get_yellow();
static Color& get_magenta();
static Color& get_cyan();
Color();
Color(const Color& other);
Color(int r, int g, int b);
void get_components(int& r, int& g, int& b) const;
};
/**
* @brief Returns the black color.
* @return the black color
*/
inline Color& Color::get_black() {
return black;
}
/**
* @brief Returns the white color.
* @return the white color
*/
inline Color& Color::get_white() {
return white;
}
/**
* @brief Returns the red color.
* @return the red color
*/
inline Color& Color::get_red() {
return red;
}
/**
* @brief Returns the green color.
* @return the green color
*/
inline Color& Color::get_green() {
return green;
}
/**
* @brief Returns the blue color.
* @return the blue color
*/
inline Color& Color::get_blue() {
return blue;
}
/**
* @brief Returns the yellow color.
* @return the yellow color
*/
inline Color& Color::get_yellow() {
return yellow;
}
/**
* @brief Returns the magenta color.
* @return the magenta color
*/
inline Color& Color::get_magenta() {
return magenta;
}
/**
* @brief Returns the cyan color.
* @return the cyan color
*/
inline Color& Color::get_cyan() {
return cyan;
}
#endif