diff options
| author | Amit Prasad <17amitprasad@gmail.com> | 2019-12-20 09:44:19 -0500 |
|---|---|---|
| committer | Amit Prasad <17amitprasad@gmail.com> | 2019-12-20 09:44:19 -0500 |
| commit | c29151de464ee9267872c48115fc79bc7a0075b6 (patch) | |
| tree | 49b8067d596c844299ae7e9285f14389ed8da010 /pywal/util.py | |
| parent | c0896043aa9b212809048cab2607a0d2f3edf78b (diff) | |
Beautify
Diffstat (limited to 'pywal/util.py')
| -rw-r--r-- | pywal/util.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/pywal/util.py b/pywal/util.py index c105a56..74fe1f0 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -36,7 +36,7 @@ class Color: def rgba(self): """Convert a hex color to rgba.""" return "rgba(%s,%s,%s,%s)" % (*hex_to_rgb(self.hex_color), - int(self.alpha_num)/100) + int(self.alpha_num) / 100) @property def alpha(self): @@ -58,17 +58,17 @@ class Color: """Strip '#' from color.""" return self.hex_color[1:] - def lighten(self,percent): + def lighten(self, percent): """Lighten color by percent""" - return Color(lighten_color(self.hex_color,float(re.sub(r'[\D\.]','',percent))/100)) + return Color(lighten_color(self.hex_color, float(re.sub(r'[\D\.]', '', percent)) / 100)) - def darken(self,percent): + def darken(self, percent): """Darken color by percent""" - return Color(darken_color(self.hex_color,float(re.sub(r'[\D\.]','',percent))/100)) + return Color(darken_color(self.hex_color, float(re.sub(r'[\D\.]', '', percent)) / 100)) - def saturate(self,percent): + def saturate(self, percent): """Saturate a color""" - return Color(saturate_color(self.hex_color,float(re.sub(r'[\D\.]','',percent))/100)) + return Color(saturate_color(self.hex_color, float(re.sub(r'[\D\.]', '', percent)) / 100)) def read_file(input_file): @@ -76,6 +76,7 @@ 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: @@ -168,11 +169,11 @@ def blend_color(color, color2): def saturate_color(color, amount): """Saturate a hex color.""" r, g, b = hex_to_rgb(color) - r, g, b = [x/255.0 for x in (r, g, b)] + r, g, b = [x / 255.0 for x in (r, g, b)] h, l, s = colorsys.rgb_to_hls(r, g, b) s = amount r, g, b = colorsys.hls_to_rgb(h, l, s) - r, g, b = [x*255.0 for x in (r, g, b)] + r, g, b = [x * 255.0 for x in (r, g, b)] return rgb_to_hex((int(r), int(g), int(b))) |
