blip  0.1
Color.hpp
Go to the documentation of this file.
1 
2 #ifndef __blip_Color_hpp
3 #define __blip_Color_hpp
4 
5 #include <blip/Blip.hpp>
6 
7 namespace blip {
8 
14 class Color
15 {
16  public:
17 
21  explicit Color(uint32_t rgba) throw();
22 
26  Color(uint8_t red = 0, uint8_t green = 0, uint8_t blue = 0,
27  uint8_t alpha = 255) throw();
28 
30  ~Color() throw();
31 
33  inline void setRed(uint8_t red) throw()
34  { _red = red; }
35 
37  inline uint8_t getRed() const throw()
38  { return(_red); }
39 
41  inline void setGreen(uint8_t green) throw()
42  { _green = green; }
43 
45  inline uint8_t getGreen() const throw()
46  { return(_green); }
47 
49  inline void setBlue(uint8_t blue) throw()
50  { _blue = blue; }
51 
53  inline uint8_t getBlue() const throw()
54  { return(_blue); }
55 
57  inline void setAlpha(uint8_t alpha) throw()
58  { _alpha = alpha; }
59 
61  inline uint8_t getAlpha() const throw()
62  { return(_alpha); }
63 
65  void setColor(int red, int green, int blue, int alpha) throw();
66 
68  void setRGBA(uint32_t rgba) throw();
69 
71  uint32_t toRGBA() const throw();
72 
74  void getHSL(float* hue, float* saturation, float* lightness) const throw();
75 
77  void setHSL(float hue, float saturation, float lightness) throw();
78 
80  static const Color BLACK;
82  static const Color BLUE;
84  static const Color CYAN;
86  static const Color DARK_BLUE;
88  static const Color DARK_CYAN;
90  static const Color DARK_GRAY;
92  static const Color DARK_GREEN;
94  static const Color DARK_MAGENTA;
96  static const Color DARK_RED;
98  static const Color DARK_YELLOW;
100  static const Color GRAY;
102  static const Color GREEN;
104  static const Color LIGHT_GRAY;
106  static const Color MAGENTA;
108  static const Color RED;
110  static const Color TRANSPARENT;
112  static const Color WHITE;
114  static const Color YELLOW;
115 
116  private:
117 
118  float hueToRGB(float a, float b, float h) const throw();
119 
120  uint8_t _red;
121  uint8_t _green;
122  uint8_t _blue;
123  uint8_t _alpha;
124 };
125 
126 } // namespace blip
127 
128 #endif // __blip_Color_h
static const Color BLUE
Blue (#0000FF)
Definition: Color.hpp:82
static const Color DARK_GREEN
Dark green (#008000)
Definition: Color.hpp:92
static const Color DARK_RED
Dark red (#800000)
Definition: Color.hpp:96
void setRGBA(uint32_t rgba)
Set the color from the 32-bit packed RGBA representation.
Definition: Color.cpp:62
void setAlpha(uint8_t alpha)
Set the alpha component of the color.
Definition: Color.hpp:57
A color with red, green, blue, and alpha components.
Definition: Color.hpp:14
uint8_t getGreen() const
Get the green component of the color.
Definition: Color.hpp:45
uint8_t getBlue() const
Get the blue component of the color.
Definition: Color.hpp:53
void setBlue(uint8_t blue)
Set the blue component of the color.
Definition: Color.hpp:49
static const Color WHITE
White (#FFFFFF)
Definition: Color.hpp:112
static const Color GREEN
Green (#00FF00)
Definition: Color.hpp:102
void setHSL(float hue, float saturation, float lightness)
Set this color using hue, saturation, and lightness values.
Definition: Color.cpp:154
static const Color LIGHT_GRAY
Light gray (#C0C0C0)
Definition: Color.hpp:104
~Color()
Destructor.
Definition: Color.cpp:55
static const Color DARK_CYAN
Dark cyan (#008080)
Definition: Color.hpp:88
static const Color GRAY
Gray (#A0A0A0)
Definition: Color.hpp:100
WAV file format details at: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/.
Definition: AccelerometerSensorEvent.cpp:3
void setColor(int red, int green, int blue, int alpha)
Set all components of the color.
Definition: Color.cpp:76
uint32_t toRGBA() const
Get the color&#39;s 32-bit packed RGBA representation.
Definition: Color.cpp:87
static const Color CYAN
Cyan (#00FFFF)
Definition: Color.hpp:84
static const Color DARK_GRAY
Dark gray (#808080)
Definition: Color.hpp:90
static const Color DARK_YELLOW
Dark yellow (#808000)
Definition: Color.hpp:98
static const Color YELLOW
Yellow (#FFFF00)
Definition: Color.hpp:114
static const Color RED
Red (#FF0000)
Definition: Color.hpp:108
void setRed(uint8_t red)
Set the red component of the color.
Definition: Color.hpp:33
static const Color BLACK
Black (#000000)
Definition: Color.hpp:80
void setGreen(uint8_t green)
Set the green component of the color.
Definition: Color.hpp:41
uint8_t getRed() const
Get the red component of the color.
Definition: Color.hpp:37
void getHSL(float *hue, float *saturation, float *lightness) const
Get the hue, saturation, and lightness values for this color.
Definition: Color.cpp:104
uint8_t getAlpha() const
Get the alpha component of the color.
Definition: Color.hpp:61
Color(uint32_t rgba)
Construct a new Color from the given packed 32-bit RGBA representation.
Definition: Color.cpp:47
static const Color DARK_BLUE
Dark blue (#000080)
Definition: Color.hpp:86
static const Color TRANSPARENT
Transparent black.
Definition: Color.hpp:110
static const Color MAGENTA
Magenta (#FF00FF)
Definition: Color.hpp:106
static const Color DARK_MAGENTA
Dark magenta (#800080)
Definition: Color.hpp:94