Commit eaba16db authored by hybrid's avatar hybrid

Another lightness calculation method.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2727 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 23b9b108
...@@ -191,13 +191,19 @@ namespace video ...@@ -191,13 +191,19 @@ namespace video
0 means no blue, 255 means full blue. */ 0 means no blue, 255 means full blue. */
u32 getBlue() const { return color & 0xff; } u32 getBlue() const { return color & 0xff; }
//! Returns the luminance of the color. //! Get lightness of the color in the range [0,255]
f32 getLightness() const
{
return 0.5f*(core::max_(core::max_(getRed(),getGreen()),getBlue())+core::min_(core::min_(getRed(),getGreen()),getBlue()));
}
//! Get luminance of the color in the range [0,255].
f32 getLuminance() const f32 getLuminance() const
{ {
return 0.3f*getRed() + 0.59f*getGreen() + 0.11f*getBlue(); return 0.3f*getRed() + 0.59f*getGreen() + 0.11f*getBlue();
} }
//! Returns the average intensity of the color. //! Get average intensity of the color in the range [0,255].
u32 getAverage() const u32 getAverage() const
{ {
return ( getRed() + getGreen() + getBlue() ) / 3; return ( getRed() + getGreen() + getBlue() ) / 3;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment