From 02acd28f0641667ff658a4e5a19061ef8657e697 Mon Sep 17 00:00:00 2001 From: Amit Prasad <17amitprasad@gmail.com> Date: Tue, 17 Dec 2019 20:29:04 -0500 Subject: Added ability to modify colors using methods ( .lighten(%), .darken(%), .saturate(%) for now) --- pywal/util.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'pywal/util.py') diff --git a/pywal/util.py b/pywal/util.py index 2fe0762..c105a56 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -9,6 +9,7 @@ import shutil import subprocess import sys import platform +import re class Color: @@ -57,10 +58,17 @@ class Color: """Strip '#' from color.""" return self.hex_color[1:] - @property def lighten(self,percent): """Lighten color by percent""" - return lighten_color(self.hex_color,percent/100) + return Color(lighten_color(self.hex_color,float(re.sub(r'[\D\.]','',percent))/100)) + + def darken(self,percent): + """Darken color by percent""" + return Color(darken_color(self.hex_color,float(re.sub(r'[\D\.]','',percent))/100)) + + def saturate(self,percent): + """Saturate a color""" + return Color(saturate_color(self.hex_color,float(re.sub(r'[\D\.]','',percent))/100)) def read_file(input_file): @@ -68,7 +76,6 @@ def read_file(input_file): with open(input_file, "r") as file: return file.read().splitlines() - def read_file_json(input_file): """Read data from a json file.""" with open(input_file, "r") as json_file: -- cgit v1.2.3