mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx/Color: Use luminosity to compute grayscale value
Issue #9758 discusses this.
This commit is contained in:
parent
ca6c9be94c
commit
882d57326c
Notes:
sideshowbarker
2024-07-18 04:50:55 +09:00
Author: https://github.com/mustafaquraish Commit: https://github.com/SerenityOS/serenity/commit/882d57326c3 Pull-request: https://github.com/SerenityOS/serenity/pull/9763
1 changed files with 6 additions and 1 deletions
|
@ -221,9 +221,14 @@ public:
|
|||
alpha() * other.alpha() / 255);
|
||||
}
|
||||
|
||||
constexpr u8 luminosity() const
|
||||
{
|
||||
return (red() * 0.2126f + green() * 0.7152f + blue() * 0.0722f);
|
||||
}
|
||||
|
||||
constexpr Color to_grayscale() const
|
||||
{
|
||||
int gray = (red() + green() + blue()) / 3;
|
||||
auto gray = luminosity();
|
||||
return Color(gray, gray, gray, alpha());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue