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 {
37 class IGNITION_MATH_VISIBLE
Color 58 public:
typedef unsigned int RGBA;
62 public:
typedef unsigned int BGRA;
66 public:
typedef unsigned int ARGB;
70 public:
typedef unsigned int ABGR;
80 public:
Color(
const float _r,
const float _g,
const float _b,
81 const float _a = 1.0);
88 public:
virtual ~
Color();
99 public:
void Set(
const float _r = 1,
const float _g = 1,
100 const float _b = 1,
const float _a = 1);
111 public:
void SetFromHSV(
const float _h,
const float _s,
const float _v);
121 public:
void SetFromYUV(
const float _y,
const float _u,
const float _v);
132 public:
float operator[](
const unsigned int _index);
136 public: RGBA AsRGBA()
const;
140 public: BGRA AsBGRA()
const;
144 public: ARGB AsARGB()
const;
148 public: ABGR AsABGR()
const;
152 public:
void SetFromRGBA(
const RGBA _v);
156 public:
void SetFromBGRA(
const BGRA _v);
160 public:
void SetFromARGB(
const ARGB _v);
164 public:
void SetFromABGR(
const ABGR _v);
169 public:
Color operator+(
const Color &_pt)
const;
174 public:
Color operator+(
const float &_v)
const;
179 public:
const Color &operator+=(
const Color &_pt);
184 public:
Color operator-(
const Color &_pt)
const;
189 public:
Color operator-(
const float &_v)
const;
194 public:
const Color &operator-=(
const Color &_pt);
199 public:
const Color operator/(
const Color &_pt)
const;
204 public:
const Color operator/(
const float &_v)
const;
209 public:
const Color &operator/=(
const Color &_pt);
214 public:
const Color operator*(
const Color &_pt)
const;
219 public:
const Color operator*(
const float &_v)
const;
224 public:
const Color &operator*=(
const Color &_pt);
229 public:
bool operator==(
const Color &_pt)
const;
234 public:
bool operator!=(
const Color &_pt)
const;
237 private:
void Clamp();
246 _out << _pt.r <<
" " << _pt.g <<
" " << _pt.b <<
" " << _pt.a;
257 _in.
setf(std::ios_base::skipws);
258 _in >> _pt.r >> _pt.g >> _pt.b;
268 else if (!_in.
fail())
277 public:
float R()
const;
281 public:
float G()
const;
285 public:
float B()
const;
289 public:
float A()
const;
309 public:
void R(
const float _r);
313 public:
void G(
const float _g);
317 public:
void B(
const float _b);
321 public:
void A(
const float _a);
324 private:
float r = 0;
327 private:
float g = 0;
330 private:
float b = 0;
333 private:
float a = 1;
friend std::ostream & operator<<(std::ostream &_out, const Color &_pt)
Stream insertion operator.
Definition: Color.hh:243
unsigned int ARGB
A ARGB packed value as an unsigned int.
Definition: Color.hh:66
static const Color Yellow
(1, 1, 0)
Definition: Color.hh:50
unsigned int BGRA
A BGRA packed value as an unsigned int.
Definition: Color.hh:62
static const Color Green
(0, 1, 0)
Definition: Color.hh:46
static const Color White
(1, 1, 1)
Definition: Color.hh:40
static const Color Red
(1, 0, 0)
Definition: Color.hh:44
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:48
static const Color Cyan
(0, 1, 1)
Definition: Color.hh:54
unsigned int ABGR
A ABGR packed value as an unsigned int.
Definition: Color.hh:70
Defines a color using a red (R), green (G), blue (B), and alpha (A) component. Each color component i...
Definition: Color.hh:37
unsigned int RGBA
A RGBA packed value as an unsigned int.
Definition: Color.hh:58
static const Color Magenta
(1, 0, 1)
Definition: Color.hh:52
static const Color Black
(0, 0, 0)
Definition: Color.hh:42