mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibGfx/Color: Add suggested_foreground_color()
method
This allows you to ask the color to recommend either white/black as a contrasting text color if you were using the color as the background. This uses the previously added luminosity() method.
This commit is contained in:
parent
882d57326c
commit
1cbab1c7e6
Notes:
sideshowbarker
2024-07-18 04:50:51 +09:00
Author: https://github.com/mustafaquraish Commit: https://github.com/SerenityOS/serenity/commit/1cbab1c7e66 Pull-request: https://github.com/SerenityOS/serenity/pull/9763
1 changed files with 5 additions and 0 deletions
|
@ -392,6 +392,11 @@ public:
|
|||
return Color(out_r, out_g, out_b);
|
||||
}
|
||||
|
||||
constexpr Color suggested_foreground_color() const
|
||||
{
|
||||
return luminosity() < 128 ? Color::White : Color::Black;
|
||||
}
|
||||
|
||||
private:
|
||||
constexpr explicit Color(RGBA32 rgba)
|
||||
: m_value(rgba)
|
||||
|
|
Loading…
Reference in a new issue