C++11: Added _htmlColor literal operator.

Allows inline specification of colors in HTML syntax.
This commit is contained in:
Hans-Christian Ebke
2015-11-09 18:51:00 +01:00
parent 97ccb1d641
commit c2c627ed4d
2 changed files with 32 additions and 0 deletions

View File

@@ -412,6 +412,26 @@ typedef VectorT<double,6> Vec6d;
//=============================================================================
} // namespace OpenMesh
//=============================================================================
#ifdef CPP11_ENABLED
/**
* Literal operator for inline specification of colors in HTML syntax.
*
* Example:
* \code{.cpp}
* OpenMesh::Vec4f light_blue = 0x1FCFFFFF_htmlColor;
* \endcode
*/
constexpr OpenMesh::Vec4f operator"" _htmlColor(unsigned long long raw_color) {
return OpenMesh::Vec4f(
((raw_color >> 24) & 0xFF) / 255.0f,
((raw_color >> 16) & 0xFF) / 255.0f,
((raw_color >> 8) & 0xFF) / 255.0f,
((raw_color >> 0) & 0xFF) / 255.0f);
}
#endif
#endif // OPENMESH_VECTOR_HH defined
//=============================================================================
#endif // DOXYGEN