Cuberite
A lightweight, fast and extensible game server for Minecraft
Color.cpp
Go to the documentation of this file.
1 #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
2 
3 #include "Color.h"
4 
5 
6 
7 
8 
9 #define COLOR_RED_BITS 0x00FF0000
10 #define COLOR_GREEN_BITS 0x0000FF00
11 #define COLOR_BLUE_BITS 0x000000FF
12 #define COLOR_RED_OFFSET 16
13 #define COLOR_GREEN_OFFSET 8
14 
15 
16 
17 
18 
19 void cColor::SetColor(unsigned char a_Red, unsigned char a_Green, unsigned char a_Blue)
20 {
21  m_Color = (static_cast<unsigned int>(a_Red) << COLOR_RED_OFFSET) + (static_cast<unsigned int>(a_Green) << COLOR_GREEN_OFFSET) + (static_cast<unsigned int>(a_Blue));
22 }
23 
24 
25 
26 
27 
28 void cColor::SetRed(unsigned char a_Red)
29 {
30  m_Color = (static_cast<unsigned int>(a_Red) << COLOR_RED_OFFSET) + ((COLOR_GREEN_BITS | COLOR_BLUE_BITS) & m_Color);
31 }
32 
33 
34 
35 
36 
37 void cColor::SetGreen(unsigned char a_Green)
38 {
39  m_Color = (static_cast<unsigned int>(a_Green) << COLOR_GREEN_OFFSET) + ((COLOR_RED_BITS | COLOR_BLUE_BITS) & m_Color);
40 }
41 
42 
43 
44 
45 
46 void cColor::SetBlue(unsigned char a_Blue)
47 {
48  m_Color = static_cast<unsigned int>(a_Blue) + ((COLOR_RED_BITS | COLOR_GREEN_BITS) & m_Color);
49 }
50 
51 
52 
53 
54 
55 unsigned char cColor::GetRed() const
56 {
58 }
59 
60 
61 
62 
63 
64 unsigned char cColor::GetGreen() const
65 {
67 }
68 
69 
70 
71 
72 
73 unsigned char cColor::GetBlue() const
74 {
75  return m_Color & COLOR_BLUE_BITS;
76 }
#define COLOR_BLUE_BITS
Definition: Color.cpp:11
void SetBlue(unsigned char a_Blue)
Alters the blue value of the color.
Definition: Color.cpp:46
#define COLOR_RED_BITS
Definition: Color.cpp:9
void SetColor(unsigned char a_Red, unsigned char a_Green, unsigned char a_Blue)
Changes the color.
Definition: Color.cpp:19
#define COLOR_GREEN_BITS
Definition: Color.cpp:10
#define COLOR_GREEN_OFFSET
Definition: Color.cpp:13
unsigned int m_Color
Definition: Color.h:56
unsigned char GetRed() const
Returns the red value of the color.
Definition: Color.cpp:55
unsigned char GetBlue() const
Returns the blue value of the color.
Definition: Color.cpp:73
#define COLOR_RED_OFFSET
Definition: Color.cpp:12
unsigned char GetGreen() const
Returns the green value of the color.
Definition: Color.cpp:64
void SetGreen(unsigned char a_Green)
Alters the green value of the color.
Definition: Color.cpp:37
void SetRed(unsigned char a_Red)
Alters the red value of the color.
Definition: Color.cpp:28