diff options
| author | dylan <dylan.araps@gmail.com> | 2020-02-20 18:55:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-20 18:55:23 +0200 |
| commit | 94b0ca58068eb3dc27e19f1428daf70760ec5315 (patch) | |
| tree | 7def2e5c07f13e784103ac5a742940c7affbd5fe | |
| parent | 1bc5c0e63ad9ac0aac08cc4ff80c3d3fe1266ef6 (diff) | |
| parent | 82dbd3f8ed15e3357fa368b1963905b42bd81b98 (diff) | |
Merge pull request #487 from stefanfrick/separate_rgb
Added red, green and blue properties to Color class.
| -rw-r--r-- | pywal/util.py | 15 |
1 files changed, 15 insertions, 0 deletions
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))) |
