mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03: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
@ -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 New Issue
Block a user