mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
LibGfx: Add saturation modification functions to Color
This operates via the HSV color space; I'm not 100% sure whether the conversions are lossless.
This commit is contained in:
parent
5bb277d9ec
commit
049c1a536c
1 changed files with 9 additions and 0 deletions
|
@ -313,6 +313,15 @@ public:
|
|||
Vector<Color> shades(u32 steps, float max = 1.f) const;
|
||||
Vector<Color> tints(u32 steps, float max = 1.f) const;
|
||||
|
||||
constexpr Color saturated_to(float saturation) const
|
||||
{
|
||||
auto hsv = to_hsv();
|
||||
auto alpha = this->alpha();
|
||||
auto color = Color::from_hsv(hsv.hue, static_cast<double>(saturation), hsv.value);
|
||||
color.set_alpha(alpha);
|
||||
return color;
|
||||
}
|
||||
|
||||
constexpr Color inverted() const
|
||||
{
|
||||
return Color(~red(), ~green(), ~blue(), alpha());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue