From 9914ff2a5563aaf43036a9df2c5e30c3930b81f0 Mon Sep 17 00:00:00 2001 From: Azalea Date: Thu, 1 Jun 2023 22:03:02 -0700 Subject: [PATCH] [+] Implement color overlaying --- hyfetch/color_util.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hyfetch/color_util.py b/hyfetch/color_util.py index 7bc32c88..d277526e 100644 --- a/hyfetch/color_util.py +++ b/hyfetch/color_util.py @@ -239,3 +239,13 @@ class RGB: def is_light(self): return self.hsl().l > 0.5 + + def overlay(self, color: 'RGB', alpha: float) -> 'RGB': + """ + Overlay a color on top of this color + + :param color: Overlay color + :param alpha: Overlay alpha + :return: New color (original isn't modified) + """ + return RGB(*[round((1 - alpha) * v1 + alpha * v2) for v1, v2 in zip(self, color)])