src/colors.h

changeset 250
2837b549e616
parent 206
654661eab7f3
child 264
76a025db4948
equal deleted inserted replaced
249:37d3c819cafa 250:2837b549e616
80 //! @brief Calculates the luma-value for the given color. 80 //! @brief Calculates the luma-value for the given color.
81 //! @details c.f. https://en.wikipedia.org/wiki/Luma_(video) 81 //! @details c.f. https://en.wikipedia.org/wiki/Luma_(video)
82 template<typename T> 82 template<typename T>
83 constexpr T luma(T r, T g, T b) 83 constexpr T luma(T r, T g, T b)
84 { 84 {
85 return 0.2126 * r + 0.7152 * g + 0.0722 * b; 85 return static_cast<T>(0.2126 * r + 0.7152 * g + 0.0722 * b);
86 } 86 }
87 87
88 //! @brief Checks whether or not the specified color index is a direct color 88 //! @brief Checks whether or not the specified color index is a direct color
89 constexpr bool isDirectColor(ColorIndex color) 89 constexpr bool isDirectColor(ColorIndex color)
90 { 90 {

mercurial