1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

Color: Add to_grayscale() and darkened() helpers.

This commit is contained in:
Andreas Kling 2019-04-10 16:00:29 +02:00
parent cfab81a961
commit a74f3615ac

View file

@ -72,6 +72,17 @@ public:
return Color(r, g, b, a);
}
Color to_grayscale() const
{
int gray = (red() + green() + blue()) / 3;
return Color(gray, gray, gray, alpha());
}
Color darkened() const
{
return Color(red() * 0.8, green() * 0.8, blue() * 0.8, alpha());
}
RGBA32 value() const { return m_value; }
String to_string() const;