summaryrefslogtreecommitdiff
path: root/pywal/util.py
diff options
context:
space:
mode:
authorAmit Prasad <17amitprasad@gmail.com>2019-12-17 20:29:04 -0500
committerAmit Prasad <17amitprasad@gmail.com>2019-12-17 20:29:04 -0500
commit02acd28f0641667ff658a4e5a19061ef8657e697 (patch)
tree78474e734954809d73d5f4e4d435295b2c1806b5 /pywal/util.py
parentb9fd064d3069024b7d9084d3303e28fede3ad4b0 (diff)
Added ability to modify colors using methods ( .lighten(%), .darken(%), .saturate(%) for now)
Diffstat (limited to 'pywal/util.py')
-rw-r--r--pywal/util.py13
1 files changed, 10 insertions, 3 deletions
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: