mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-02-19 03:31:10 +01:00
Merge pull request #497 from patzm/patzm/feat/alpha_decimal
alpha decimal support
This commit is contained in:
commit
eb4200820b
@ -1,15 +1,16 @@
|
|||||||
foreground {foreground}
|
foreground {foreground}
|
||||||
background {background}
|
background {background}
|
||||||
cursor {cursor}
|
background_opacity {background.alpha_dec}
|
||||||
|
cursor {cursor}
|
||||||
|
|
||||||
active_tab_foreground {background}
|
active_tab_foreground {background}
|
||||||
active_tab_background {foreground}
|
active_tab_background {foreground}
|
||||||
inactive_tab_foreground {foreground}
|
inactive_tab_foreground {foreground}
|
||||||
inactive_tab_background {background}
|
inactive_tab_background {background}
|
||||||
|
|
||||||
active_border_color {foreground}
|
active_border_color {foreground}
|
||||||
inactive_border_color {background}
|
inactive_border_color {background}
|
||||||
bell_border_color {color1}
|
bell_border_color {color1}
|
||||||
|
|
||||||
color0 {color0}
|
color0 {color0}
|
||||||
color8 {color8}
|
color8 {color8}
|
||||||
|
@ -36,16 +36,21 @@ class Color:
|
|||||||
def rgba(self):
|
def rgba(self):
|
||||||
"""Convert a hex color to rgba."""
|
"""Convert a hex color to rgba."""
|
||||||
return "rgba(%s,%s,%s,%s)" % (*hex_to_rgb(self.hex_color),
|
return "rgba(%s,%s,%s,%s)" % (*hex_to_rgb(self.hex_color),
|
||||||
int(self.alpha_num) / 100)
|
self.alpha_dec)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def alpha(self):
|
def alpha(self):
|
||||||
"""Add URxvt alpha value to color."""
|
"""Add URxvt alpha value to color."""
|
||||||
return "[%s]%s" % (self.alpha_num, self.hex_color)
|
return "[%s]%s" % (self.alpha_num, self.hex_color)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def alpha_dec(self):
|
||||||
|
"""Export the alpha value as a decimal number in [0, 1]."""
|
||||||
|
return int(self.alpha_num) / 100
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def octal(self):
|
def octal(self):
|
||||||
"""Export color in octal"""
|
"""Export color in octal."""
|
||||||
return "%s%s" % ("#", oct(int(self.hex_color[1:], 16))[2:])
|
return "%s%s" % ("#", oct(int(self.hex_color[1:], 16))[2:])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -74,17 +79,17 @@ class Color:
|
|||||||
return "%.3f" % (hex_to_rgb(self.hex_color)[2]/255.)
|
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)))
|
||||||
return Color(lighten_color(self.hex_color, percent / 100))
|
return Color(lighten_color(self.hex_color, percent / 100))
|
||||||
|
|
||||||
def darken(self, percent):
|
def darken(self, percent):
|
||||||
"""Darken color by percent"""
|
"""Darken color by percent."""
|
||||||
percent = float(re.sub(r'[\D\.]', '', str(percent)))
|
percent = float(re.sub(r'[\D\.]', '', str(percent)))
|
||||||
return Color(darken_color(self.hex_color, percent / 100))
|
return Color(darken_color(self.hex_color, percent / 100))
|
||||||
|
|
||||||
def saturate(self, percent):
|
def saturate(self, percent):
|
||||||
"""Saturate a color"""
|
"""Saturate a color."""
|
||||||
percent = float(re.sub(r'[\D\.]', '', str(percent)))
|
percent = float(re.sub(r'[\D\.]', '', str(percent)))
|
||||||
return Color(saturate_color(self.hex_color, percent / 100))
|
return Color(saturate_color(self.hex_color, percent / 100))
|
||||||
|
|
||||||
@ -103,7 +108,7 @@ def read_file_json(input_file):
|
|||||||
|
|
||||||
def read_file_raw(input_file):
|
def read_file_raw(input_file):
|
||||||
"""Read data from a file as is, don't strip
|
"""Read data from a file as is, don't strip
|
||||||
newlines or other special characters.."""
|
newlines or other special characters."""
|
||||||
with open(input_file, "r") as file:
|
with open(input_file, "r") as file:
|
||||||
return file.readlines()
|
return file.readlines()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user