From 82dbd3f8ed15e3357fa368b1963905b42bd81b98 Mon Sep 17 00:00:00 2001 From: Stefan Frick Date: Thu, 20 Feb 2020 17:38:28 +0100 Subject: [PATCH] Added red, green and blue properties to Color class. These give access to separate RGB values in the range from 0 to 1, e.g. needed by compton/picom shadows. --- pywal/util.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pywal/util.py b/pywal/util.py index cd6628a..7a6787e 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -58,6 +58,21 @@ class Color: """Strip '#' from color.""" return self.hex_color[1:] + @property + def red(self): + """Red value as float between 0 and 1.""" + return "%.3f" % (hex_to_rgb(self.hex_color)[0]/255.) + + @property + def green(self): + """Green value as float between 0 and 1.""" + return "%.3f" % (hex_to_rgb(self.hex_color)[1]/255.) + + @property + def blue(self): + """Blue value as float between 0 and 1.""" + return "%.3f" % (hex_to_rgb(self.hex_color)[2]/255.) + def lighten(self, percent): """Lighten color by percent""" percent = float(re.sub(r'[\D\.]', '', str(percent)))