mirror of
https://github.com/dylanaraps/pywal.git
synced 2024-12-01 12:24:36 +01:00
colors: Create comment color based on bg.
This commit is contained in:
parent
29d7c93779
commit
93c4bcd96b
@ -61,18 +61,21 @@ def sort_colors(img, colors):
|
|||||||
if raw_colors[0][1] not in ["0", "1", "2"]:
|
if raw_colors[0][1] not in ["0", "1", "2"]:
|
||||||
raw_colors[0] = util.darken_color(raw_colors[0], 0.25)
|
raw_colors[0] = util.darken_color(raw_colors[0], 0.25)
|
||||||
|
|
||||||
|
# Create a comment color from the background.
|
||||||
|
raw_colors[8] = util.lighten_color(raw_colors[0], 0.40)
|
||||||
|
|
||||||
colors = {"wallpaper": img}
|
colors = {"wallpaper": img}
|
||||||
|
|
||||||
colors_special = {}
|
colors_special = {}
|
||||||
|
colors_hex = {}
|
||||||
|
|
||||||
colors_special.update({"background": raw_colors[0]})
|
colors_special.update({"background": raw_colors[0]})
|
||||||
colors_special.update({"foreground": raw_colors[15]})
|
colors_special.update({"foreground": raw_colors[15]})
|
||||||
colors_special.update({"cursor": raw_colors[15]})
|
colors_special.update({"cursor": raw_colors[15]})
|
||||||
|
|
||||||
colors_hex = {}
|
|
||||||
for index, color in enumerate(raw_colors):
|
for index, color in enumerate(raw_colors):
|
||||||
colors_hex.update({f"color{index}": color})
|
colors_hex.update({f"color{index}": color})
|
||||||
|
|
||||||
colors_hex["color8"] = util.set_grey(raw_colors)
|
|
||||||
colors["special"] = colors_special
|
colors["special"] = colors_special
|
||||||
colors["colors"] = colors_hex
|
colors["colors"] = colors_hex
|
||||||
|
|
||||||
|
@ -34,23 +34,6 @@ class Color:
|
|||||||
return f"[{self.alpha_num}]{self.hex_color}"
|
return f"[{self.alpha_num}]{self.hex_color}"
|
||||||
|
|
||||||
|
|
||||||
def set_grey(colors):
|
|
||||||
"""Set a grey color based on the brightness
|
|
||||||
of another color."""
|
|
||||||
return {
|
|
||||||
"0": "#666666",
|
|
||||||
"1": "#666666",
|
|
||||||
"2": "#757575",
|
|
||||||
"3": "#999999",
|
|
||||||
"4": "#999999",
|
|
||||||
"5": "#8a8a8a",
|
|
||||||
"6": "#a1a1a1",
|
|
||||||
"7": "#a1a1a1",
|
|
||||||
"8": "#a1a1a1",
|
|
||||||
"9": "#a1a1a1",
|
|
||||||
}.get(colors[0][1], colors[7])
|
|
||||||
|
|
||||||
|
|
||||||
def read_file(input_file):
|
def read_file(input_file):
|
||||||
"""Read data from a file and trim newlines."""
|
"""Read data from a file and trim newlines."""
|
||||||
with open(input_file, "r") as file:
|
with open(input_file, "r") as file:
|
||||||
@ -114,9 +97,17 @@ def rgb_to_hex(color):
|
|||||||
return f"#{color[0]:02x}{color[1]:02x}{color[2]:02x}"
|
return f"#{color[0]:02x}{color[1]:02x}{color[2]:02x}"
|
||||||
|
|
||||||
|
|
||||||
def darken_color(color, darkness):
|
def darken_color(color, amount):
|
||||||
"""Darken a hex color."""
|
"""Darken a hex color."""
|
||||||
return rgb_to_hex([int(col * (1 - darkness)) for col in hex_to_rgb(color)])
|
color = [int(col * (1 - amount)) for col in hex_to_rgb(color)]
|
||||||
|
print(color)
|
||||||
|
return rgb_to_hex(color)
|
||||||
|
|
||||||
|
|
||||||
|
def lighten_color(color, amount):
|
||||||
|
"""Lighten a hex color."""
|
||||||
|
color = [int(col + (255 - col) * amount) for col in hex_to_rgb(color)]
|
||||||
|
return rgb_to_hex(color)
|
||||||
|
|
||||||
|
|
||||||
def disown(cmd):
|
def disown(cmd):
|
||||||
|
Loading…
Reference in New Issue
Block a user