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

This commit is contained in:
Andreas Kling 2019-04-10 16:00:29 +02:00
commit a74f3615ac
Notes: sideshowbarker 2024-07-19 14:46:23 +09:00

View file

@ -72,6 +72,17 @@ public:
return Color(r, g, b, a); 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; } RGBA32 value() const { return m_value; }
String to_string() const; String to_string() const;