Color3f. Add operator <

This commit is contained in:
Bjørn Erik Jensen 2017-10-06 14:34:11 +02:00
parent 0e832fad06
commit 5d672356d2
2 changed files with 17 additions and 1 deletions

View File

@ -258,6 +258,20 @@ Color3f Color3f::fromByteColor(ubyte r, ubyte g, ubyte b)
return c;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool operator < (const Color3f& color1, const Color3f& color2)
{
for (int i = 0; i < 3; i++)
{
if (color1.m_rgb[i] > color2.m_rgb[i])
return false;
else if (color1.m_rgb[i] < color2.m_rgb[i])
return true;
}
return false;
}
//==================================================================================================
@ -432,6 +446,5 @@ const ubyte* Color3ub::ptr() const
return m_rgb;
}
} // namespace cvf

View File

@ -135,10 +135,13 @@ public:
static Color3f fromByteColor(ubyte r, ubyte g, ubyte b);
friend bool operator < (const Color3f& color1, const Color3f& color2);
private:
float m_rgb[3];
};
bool operator < (const Color3f& color1, const Color3f& color2);
//==================================================================================================