14 #include <argos3/core/utility/datatypes/datatypes.h>
15 #include <argos3/core/utility/string_utilities.h>
61 UInt8 un_alpha = 255) throw() :
62 m_tChannels(un_red, un_green, un_blue, un_alpha) {}
70 0.299f * m_tChannels.m_unRed +
71 0.587f * m_tChannels.m_unGreen +
72 0.114f * m_tChannels.m_unBlue;
79 inline UInt8 GetRed()
const throw() {
return m_tChannels.m_unRed; }
84 inline void SetRed(
UInt8 un_red)
throw() { m_tChannels.m_unRed = un_red; }
95 inline void SetGreen(
UInt8 un_green)
throw() { m_tChannels.m_unGreen = un_green; }
106 inline void SetBlue(
UInt8 un_blue)
throw() { m_tChannels.m_unBlue = un_blue; }
117 inline void SetAlpha(
UInt8 un_alpha)
throw() { m_tChannels.m_unAlpha = un_alpha; }
129 UInt8 un_alpha = 255) throw() {
143 inline void Set(
const std::string& str_color) {
167 ParseValues<UInt16>(str_color, 4, unValues,
',');
168 for(
UInt16 i = 0; i < 4; ++i) {
169 if(unValues[i] > 255) {
173 Set(unValues[0], unValues[1], unValues[2], unValues[3]);
186 return *
reinterpret_cast<UInt32*
>(&m_tChannels);
195 return m_tChannels == c_color2.m_tChannels;
204 return m_tChannels != c_color2.m_tChannels;
241 os << c_color.m_tChannels.m_unRed
242 <<
"," << c_color.m_tChannels.m_unGreen
243 <<
"," << c_color.m_tChannels.m_unBlue
244 <<
"," << c_color.m_tChannels.m_unAlpha;
260 std::string strColor;
262 c_color.
Set(strColor);
281 TChannels(
const UInt8 un_red,
282 const UInt8 un_green,
284 const UInt8 un_alpha = 255) :
288 m_unAlpha(un_alpha) {}
290 inline bool operator==(
const TChannels& t_channels)
const {
292 (m_unRed == t_channels.m_unRed) &&
293 (m_unGreen == t_channels.m_unGreen) &&
294 (m_unBlue == t_channels.m_unBlue) &&
295 (m_unAlpha == t_channels.m_unAlpha);
298 inline bool operator!=(
const TChannels& t_channels)
const {
300 (m_unRed != t_channels.m_unRed) ||
301 (m_unGreen != t_channels.m_unGreen) ||
302 (m_unBlue != t_channels.m_unBlue) ||
303 (m_unAlpha != t_channels.m_unAlpha);
void SetAlpha(UInt8 un_alpha)
Sets the alpha channel of the color.
friend std::ostream & operator<<(std::ostream &os, const CColor &c_color)
Output stream operator.
float Real
Collects all ARGoS code.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
unsigned char UInt8
8-bit unsigned integer.
void SetRed(UInt8 un_red)
Sets the red channel of the color.
UInt8 GetGreen() const
Returns the green channel of the color.
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception...
unsigned int UInt32
32-bit unsigned integer.
friend std::istream & operator>>(std::istream &is, CColor &c_color)
Input stream operator.
void Set(UInt8 un_red, UInt8 un_green, UInt8 un_blue, UInt8 un_alpha=255)
Sets the RGBA values of the color.
UInt8 GetRed() const
Returns the red channel of the color.
void Set(const std::string &str_color)
Sets the RGBA values of the color from a string.
The exception that wraps all errors in ARGoS.
Real ToGrayScale() const
Returns the color in grayscale.
CColor(UInt8 un_red, UInt8 un_green, UInt8 un_blue, UInt8 un_alpha=255)
Class constructor.
UInt8 GetAlpha() const
Returns the alpha channel of the color.
bool operator==(const CColor &c_color2) const
Returns true if the given color is identical to the current.
void SetBlue(UInt8 un_blue)
Sets the blue channel of the color.
UInt8 GetBlue() const
Returns the blue channel of the color.
unsigned short UInt16
16-bit unsigned integer.
The namespace containing all the ARGoS related code.
void SetGreen(UInt8 un_green)
Sets the green channel of the color.
CColor()
Class constructor.
bool operator!=(const CColor &c_color2) const
Returns true if the given color is different from the current.