17 #ifndef IGNITION_MATH_COLOR_HH_ 18 #define IGNITION_MATH_COLOR_HH_ 25 #include <ignition/math/config.hh> 32 inline namespace IGNITION_MATH_VERSION_NAMESPACE {
41 class IGNITION_MATH_VISIBLE
Color 67 public:
typedef unsigned int RGBA;
76 public:
typedef unsigned int BGRA;
85 public:
typedef unsigned int ARGB;
94 public:
typedef unsigned int ABGR;
104 public:
Color(
const float _r,
const float _g,
const float _b,
105 const float _a = 1.0);
112 public:
virtual ~
Color();
116 public:
void Reset();
123 public:
void Set(
const float _r = 1,
const float _g = 1,
124 const float _b = 1,
const float _a = 1);
135 public:
void SetFromHSV(
const float _h,
const float _s,
const float _v);
145 public:
void SetFromYUV(
const float _y,
const float _u,
const float _v);
156 public:
float operator[](
const unsigned int _index);
160 public: RGBA AsRGBA()
const;
164 public: BGRA AsBGRA()
const;
168 public: ARGB AsARGB()
const;
172 public: ABGR AsABGR()
const;
176 public:
void SetFromRGBA(
const RGBA _v);
180 public:
void SetFromBGRA(
const BGRA _v);
184 public:
void SetFromARGB(
const ARGB _v);
188 public:
void SetFromABGR(
const ABGR _v);
193 public:
Color operator+(
const Color &_pt)
const;
198 public:
Color operator+(
const float &_v)
const;
203 public:
const Color &operator+=(
const Color &_pt);
208 public:
Color operator-(
const Color &_pt)
const;
213 public:
Color operator-(
const float &_v)
const;
218 public:
const Color &operator-=(
const Color &_pt);
223 public:
const Color operator/(
const Color &_pt)
const;
228 public:
const Color operator/(
const float &_v)
const;
233 public:
const Color &operator/=(
const Color &_pt);
238 public:
const Color operator*(
const Color &_pt)
const;
243 public:
const Color operator*(
const float &_v)
const;
248 public:
const Color &operator*=(
const Color &_pt);
253 public:
bool operator==(
const Color &_pt)
const;
258 public:
bool operator!=(
const Color &_pt)
const;
261 private:
void Clamp();
270 _out << _pt.r <<
" " << _pt.g <<
" " << _pt.b <<
" " << _pt.a;
281 _in.
setf(std::ios_base::skipws);
282 _in >> _pt.r >> _pt.g >> _pt.b;
292 else if (!_in.
fail())
301 public:
float R()
const;
305 public:
float G()
const;
309 public:
float B()
const;
313 public:
float A()
const;
333 public:
void R(
const float _r);
337 public:
void G(
const float _g);
341 public:
void B(
const float _b);
345 public:
void A(
const float _a);
348 private:
float r = 0;
351 private:
float g = 0;
354 private:
float b = 0;
357 private:
float a = 1;
friend std::ostream & operator<<(std::ostream &_out, const Color &_pt)
Stream insertion operator.
Definition: Color.hh:267
unsigned int ARGB
A ARGB packed value as an unsigned int Each 8 bits corresponds to a channel.
Definition: Color.hh:85
static const Color Yellow
(1, 1, 0)
Definition: Color.hh:54
unsigned int BGRA
A BGRA packed value as an unsigned int Each 8 bits corresponds to a channel.
Definition: Color.hh:76
static const Color Green
(0, 1, 0)
Definition: Color.hh:50
static const Color White
(1, 1, 1)
Definition: Color.hh:44
static const Color Red
(1, 0, 0)
Definition: Color.hh:48
The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to ke...
Definition: Vector3.hh:41
static const Color Blue
(0, 0, 1)
Definition: Color.hh:52
static const Color Cyan
(0, 1, 1)
Definition: Color.hh:58
unsigned int ABGR
A ABGR packed value as an unsigned int Each 8 bits corresponds to a channel.
Definition: Color.hh:94
Defines a color using a red (R), green (G), blue (B), and alpha (A) component. Each color component i...
Definition: Color.hh:41
unsigned int RGBA
A RGBA packed value as an unsigned int Each 8 bits corresponds to a channel.
Definition: Color.hh:67
static const Color Magenta
(1, 0, 1)
Definition: Color.hh:56
static const Color Black
(0, 0, 0)
Definition: Color.hh:46