SDL Utility
Color.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "Util.hpp"
10 
19  struct Color
20  {
21  Uint8 r;
22  Uint8 g;
23  Uint8 b;
24  Uint8 a;
25 
29  Color();
30 
39  Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255);
40 
46  Color(Uint32 color);
47 
54 
60  static Color FromHSV(Uint16 h, Uint8 s, Uint8 v);
61 
62 
64 
65  static const Color Black;
66  static const Color Red;
67  static const Color Green;
68  static const Color Blue;
69  static const Color Yellow;
70  static const Color Magenta;
71  static const Color Cyan;
72  static const Color White;
73 
74  static const Color Transparent;
75 
76 
78 
86  friend Color operator+(const Color& left, const Color& right);
87 
95  friend Color operator-(const Color& left, const Color& right);
96 
104  friend Color operator*(const Color& left, const Color& right);
105 
113  friend Color operator/(const Color& left, const Color& right);
114 
122  friend Color& operator+=(Color& left, const Color& right);
123 
131  friend Color& operator-=(Color& left, const Color& right);
132 
140  friend Color& operator*=(Color& left, const Color& right);
141 
149  friend Color& operator/=(Color& left, const Color& right);
150 
158  friend bool operator==(const Color& left, const Color& right);
159 
167  friend bool operator!=(const Color& left, const Color& right);
168  };
169 SDLU_END
Basic utility macros, typedefs...
uint8_t Uint8
Definition: Util.hpp:17
uint16_t Uint16
Definition: Util.hpp:20
#define SDLU_BEGIN
Definition: Util.hpp:32
uint32_t Uint32
Definition: Util.hpp:23
A structure holding color data.
Definition: Color.hpp:20
Uint8 b
Blue component.
Definition: Color.hpp:23
friend Color & operator+=(Color &left, const Color &right)
Componentwise color addition.
friend Color operator+(const Color &left, const Color &right)
Componentwise color addition.
friend Color operator*(const Color &left, const Color &right)
Componentwise color multiplication.
friend Color & operator/=(Color &left, const Color &right)
Componentwise color division.
friend bool operator==(const Color &left, const Color &right)
Componentwise color comparison.
friend bool operator!=(const Color &left, const Color &right)
Componentwise color comparison.
Uint8 g
Green component.
Definition: Color.hpp:22
friend Color operator-(const Color &left, const Color &right)
Componentwise color subtraction.
static Color FromHSV(Uint16 h, Uint8 s, Uint8 v)
Generate color from HSV values.
static const Color White
Default Color White (#FFFFFFFF)
Definition: Color.hpp:72
static const Color Blue
Default Color Blue (#0000FFFF)
Definition: Color.hpp:68
Uint8 r
Red component.
Definition: Color.hpp:21
static const Color Magenta
Default Color Magenta (#FF00FFFF)
Definition: Color.hpp:70
Uint32 ToInt()
Returns color data as a 32-Bit integer.
Uint8 a
Alpha component.
Definition: Color.hpp:24
static const Color Green
Default Color Green (#00FF00FF)
Definition: Color.hpp:67
Color()
Default constructor (Black)
Color(Uint32 color)
Construct color from a 32-Bit integer value.
friend Color & operator*=(Color &left, const Color &right)
Componentwise color multiplication.
static const Color Transparent
Default Color Transparent (#00000000)
Definition: Color.hpp:74
friend Color & operator-=(Color &left, const Color &right)
Componentwise color subtraction.
static const Color Cyan
Default Color Cyan (#00FFFFFF)
Definition: Color.hpp:71
static const Color Black
Default Color Black (#000000FF)
Definition: Color.hpp:65
Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a=255)
Construct color from four 8-Bit integer values.
static const Color Red
Default Color Red (#FF0000FF)
Definition: Color.hpp:66
friend Color operator/(const Color &left, const Color &right)
Componentwise color division.
static const Color Yellow
Default Color Yellow (#FFFF00FF)
Definition: Color.hpp:69