From 120e5b6b6f95328877d8bfbdda5b1a2f429df47f Mon Sep 17 00:00:00 2001 From: MacDue Date: Thu, 18 May 2023 19:02:00 +0100 Subject: [PATCH] LibGfx: Add Color::with_opacity(float opacity) This returns the color with its alpha scaled by the opacity. --- Userland/Libraries/LibGfx/Color.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibGfx/Color.h b/Userland/Libraries/LibGfx/Color.h index 5d85f35692..6f01981cb8 100644 --- a/Userland/Libraries/LibGfx/Color.h +++ b/Userland/Libraries/LibGfx/Color.h @@ -331,6 +331,11 @@ public: alpha()); } + constexpr Color with_opacity(float opacity) const + { + return with_alpha(alpha() * opacity); + } + constexpr Color darkened(float amount = 0.5f) const { return Color(red() * amount, green() * amount, blue() * amount, alpha());