Merge pull request #6361 from maximecharriere/patch-1

Add CGAL::Color operator< and return values
This commit is contained in:
Laurent Rineau 2022-03-02 15:13:42 +01:00
commit db74265caf
1 changed files with 11 additions and 2 deletions

View File

@ -132,6 +132,11 @@ public:
return !( (*this) == c); return !( (*this) == c);
} }
bool operator<(const Color& c) const
{
return m_data < c.to_rgba();
}
unsigned char r() const { return red(); } unsigned char r() const { return red(); }
unsigned char g() const { return green(); } unsigned char g() const { return green(); }
unsigned char b() const { return blue(); } unsigned char b() const { return blue(); }
@ -206,7 +211,7 @@ public:
/*! /*!
replaces the rgb values of the colors by the one given as parameters. replaces the rgb values of the colors by the one given as parameters.
*/ */
void set_rgb (unsigned char red, Color& set_rgb (unsigned char red,
unsigned char green, unsigned char green,
unsigned char blue, unsigned char blue,
unsigned char alpha = 255) unsigned char alpha = 255)
@ -215,13 +220,15 @@ public:
m_data[1] = green; m_data[1] = green;
m_data[2] = blue; m_data[2] = blue;
m_data[3] = alpha; m_data[3] = alpha;
return *this;
} }
/*! /*!
replaces the rgb values of the colors by the conversion to rgb of replaces the rgb values of the colors by the conversion to rgb of
the hsv values given as parameters. the hsv values given as parameters.
*/ */
void set_hsv (double hue, Color& set_hsv (double hue,
double saturation, double saturation,
double value, double value,
unsigned char alpha = 255) unsigned char alpha = 255)
@ -275,6 +282,8 @@ public:
m_data[1] = (unsigned char)g; m_data[1] = (unsigned char)g;
m_data[2] = (unsigned char)b; m_data[2] = (unsigned char)b;
m_data[3] = alpha; m_data[3] = alpha;
return *this;
} }
/// @} /// @}