mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +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
1 changed files with 5 additions and 0 deletions
|
@ -392,6 +392,11 @@ public:
|
||||||
return Color(out_r, out_g, out_b);
|
return Color(out_r, out_g, out_b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr Color suggested_foreground_color() const
|
||||||
|
{
|
||||||
|
return luminosity() < 128 ? Color::White : Color::Black;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
constexpr explicit Color(RGBA32 rgba)
|
constexpr explicit Color(RGBA32 rgba)
|
||||||
: m_value(rgba)
|
: m_value(rgba)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue