17 #ifndef GZ_MATH_COLOR_HH_
18 #define GZ_MATH_COLOR_HH_
26 #include <gz/math/config.hh>
31 inline namespace GZ_MATH_VERSION_NAMESPACE {
66 public:
typedef unsigned int RGBA;
75 public:
typedef unsigned int BGRA;
84 public:
typedef unsigned int ARGB;
93 public:
typedef unsigned int ABGR;
103 public: constexpr
Color(
const float _r,
const float _g,
const float _b,
104 const float _a = 1.0)
105 : r(_r), g(_g), b(_b), a(_a)
126 public:
void Set(
const float _r = 1,
const float _g = 1,
127 const float _b = 1,
const float _a = 1);
138 public:
void SetFromHSV(
const float _h,
const float _s,
const float _v);
148 public:
void SetFromYUV(
const float _y,
const float _u,
const float _v);
272 private: constexpr
void Clamp()
275 if (!(this->r >= 0)) { this->r = 0; }
276 if (!(this->g >= 0)) { this->g = 0; }
277 if (!(this->b >= 0)) { this->b = 0; }
278 if (!(this->a >= 0)) { this->a = 0; }
279 if (this->r > 1) { this->r = this->r/255.0f; }
280 if (this->g > 1) { this->g = this->g/255.0f; }
281 if (this->b > 1) { this->b = this->b/255.0f; }
282 if (this->a > 1) { this->a = 1; }
292 for (
auto i : {0, 1, 2, 3})
309 _in.
setf(std::ios_base::skipws);
310 _in >> _pt.r >> _pt.g >> _pt.b;
320 else if (!_in.
fail())
329 public:
float R()
const;
333 public:
float G()
const;
337 public:
float B()
const;
341 public:
float A()
const;
361 public:
void R(
const float _r);
365 public:
void G(
const float _g);
369 public:
void B(
const float _b);
373 public:
void A(
const float _a);
376 private:
float r = 0;
379 private:
float g = 0;
382 private:
float b = 0;
385 private:
float a = 1;