17 #ifndef IGNITION_MATH_COLOR_HH_ 18 #define IGNITION_MATH_COLOR_HH_ 24 #include <ignition/math/config.hh> 31 inline namespace IGNITION_MATH_VERSION_NAMESPACE {
36 class IGNITION_MATH_VISIBLE
Color 57 public:
typedef unsigned int RGBA;
61 public:
typedef unsigned int BGRA;
65 public:
typedef unsigned int ARGB;
69 public:
typedef unsigned int ABGR;
79 public:
Color(
const float _r,
const float _g,
const float _b,
80 const float _a = 1.0);
87 public:
virtual ~
Color();
98 public:
void Set(
const float _r = 1,
const float _g = 1,
99 const float _b = 1,
const float _a = 1);
110 public:
void SetFromHSV(
const float _h,
const float _s,
const float _v);
120 public:
void SetFromYUV(
const float _y,
const float _u,
const float _v);
131 public:
float operator[](
const unsigned int _index);
135 public: RGBA AsRGBA()
const;
139 public: BGRA AsBGRA()
const;
143 public: ARGB AsARGB()
const;
147 public: ABGR AsABGR()
const;
151 public:
void SetFromRGBA(
const RGBA _v);
155 public:
void SetFromBGRA(
const BGRA _v);
159 public:
void SetFromARGB(
const ARGB _v);
163 public:
void SetFromABGR(
const ABGR _v);
168 public:
Color operator+(
const Color &_pt)
const;
173 public:
Color operator+(
const float &_v)
const;
178 public:
const Color &operator+=(
const Color &_pt);
183 public:
Color operator-(
const Color &_pt)
const;
188 public:
Color operator-(
const float &_v)
const;
193 public:
const Color &operator-=(
const Color &_pt);
198 public:
const Color operator/(
const Color &_pt)
const;
203 public:
const Color operator/(
const float &_v)
const;
208 public:
const Color &operator/=(
const Color &_pt);
213 public:
const Color operator*(
const Color &_pt)
const;
218 public:
const Color operator*(
const float &_v)
const;
223 public:
const Color &operator*=(
const Color &_pt);
228 public:
bool operator==(
const Color &_pt)
const;
233 public:
bool operator!=(
const Color &_pt)
const;
236 private:
void Clamp();
245 _out << _pt.r <<
" " << _pt.g <<
" " << _pt.b <<
" " << _pt.a;
256 _in.
setf(std::ios_base::skipws);
257 _in >> _pt.r >> _pt.g >> _pt.b;
276 public:
float R()
const;
280 public:
float G()
const;
284 public:
float B()
const;
288 public:
float A()
const;
308 public:
void R(
const float _r);
312 public:
void G(
const float _g);
316 public:
void B(
const float _b);
320 public:
void A(
const float _a);
323 private:
float r = 0;
326 private:
float g = 0;
329 private:
float b = 0;
332 private:
float a = 1;
friend std::ostream & operator<<(std::ostream &_out, const Color &_pt)
Stream insertion operator.
Definition: Color.hh:242
unsigned int ARGB
A ARGB packed value as an unsigned int.
Definition: Color.hh:65
static const Color Yellow
(1, 1, 0)
Definition: Color.hh:49
unsigned int BGRA
A BGRA packed value as an unsigned int.
Definition: Color.hh:61
static const Color Green
(0, 1, 0)
Definition: Color.hh:45
static const Color White
(1, 1, 1)
Definition: Color.hh:39
static const Color Red
(1, 0, 0)
Definition: Color.hh:43
The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to ke...
Definition: Vector3.hh:40
static const Color Blue
(0, 0, 1)
Definition: Color.hh:47
static const Color Cyan
(0, 1, 1)
Definition: Color.hh:53
unsigned int ABGR
A ABGR packed value as an unsigned int.
Definition: Color.hh:69
Defines a color using a red (R), green (G), blue (B), and alpha (A) component. Each color component i...
Definition: Color.hh:36
unsigned int RGBA
A RGBA packed value as an unsigned int.
Definition: Color.hh:57
static const Color Magenta
(1, 0, 1)
Definition: Color.hh:51
static const Color Black
(0, 0, 0)
Definition: Color.hh:41