mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-22 13:59:01 +01:00
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.
This commit is contained in:
parent
1bc5c0e63a
commit
82dbd3f8ed
@ -58,6 +58,21 @@ class Color:
|
|||||||
"""Strip '#' from color."""
|
"""Strip '#' from color."""
|
||||||
return self.hex_color[1:]
|
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):
|
def lighten(self, percent):
|
||||||
"""Lighten color by percent"""
|
"""Lighten color by percent"""
|
||||||
percent = float(re.sub(r'[\D\.]', '', str(percent)))
|
percent = float(re.sub(r'[\D\.]', '', str(percent)))
|
||||||
|
Loading…
Reference in New Issue
Block a user