colors: better sort and better white by blending.

This commit is contained in:
Dylan Araps 2018-01-07 10:03:41 +11:00
parent b9d6eb8914
commit e06f53dc96
3 changed files with 16 additions and 4 deletions

View File

@ -1,5 +1,5 @@
[BASIC]
good-names=i,j,k,n,x,y,fg,bg,r,g,b,i3
good-names=i,j,k,n,x,y,fg,bg,r,g,b,i3,r1,r2,r3,g1,g2,g3,b1,b2,b3
[MESSAGES CONTROL]
# inconsistent-return-statements:

View File

@ -59,16 +59,16 @@ def gen_colors(img, color_count):
def create_palette(img, colors):
"""Sort the generated colors and store them in a dict that
we will later save in json format."""
raw_colors = colors[:1] + colors[8:] + colors[8:-1]
raw_colors = colors[:1] + colors[8:16] + colors[8:-1]
# Darken the background color slightly.
if raw_colors[0][1] != "0":
raw_colors[0] = util.darken_color(raw_colors[0], 0.25)
# Manually adjust colors.
raw_colors[7] = util.lighten_color(raw_colors[7], 0.25)
raw_colors[7] = util.blend_color(raw_colors[7], "#EEEEEE")
raw_colors[8] = util.darken_color(raw_colors[7], 0.30)
raw_colors[15] = util.lighten_color(raw_colors[15], 0.25)
raw_colors[15] = util.blend_color(raw_colors[15], "#EEEEEE")
colors = {"wallpaper": img, "special": {}, "colors": {}}
colors["special"]["background"] = raw_colors[0]

View File

@ -109,6 +109,18 @@ def lighten_color(color, amount):
return rgb_to_hex(color)
def blend_color(color, color2):
"""Blend two colors together."""
r1, g1, b1 = hex_to_rgb(color)
r2, g2, b2 = hex_to_rgb(color2)
r3 = int(0.5 * r1 + 0.5 * r2)
g3 = int(0.5 * g1 + 0.5 * g2)
b3 = int(0.5 * b1 + 0.5 * b2)
return rgb_to_hex((r3, g3, b3))
def disown(cmd):
"""Call a system command in the background,
disown it and hide it's output."""