summaryrefslogtreecommitdiff
path: root/SharedGraphics
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-10 16:00:29 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-10 16:00:29 +0200
commita74f3615ac810384841c94de82d0569d7e85be25 (patch)
tree93c5dff3e3d20fb31b469543bf8ff521c9a015f4 /SharedGraphics
parentcfab81a96146aaf5b350c90b575870e53f7b9534 (diff)
downloadserenity-a74f3615ac810384841c94de82d0569d7e85be25.zip
Color: Add to_grayscale() and darkened() helpers.
Diffstat (limited to 'SharedGraphics')
-rw-r--r--SharedGraphics/Color.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/SharedGraphics/Color.h b/SharedGraphics/Color.h
index dd075e3c7c..7fc72969ca 100644
--- a/SharedGraphics/Color.h
+++ b/SharedGraphics/Color.h
@@ -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;