colors: Add light theme support.

This commit is contained in:
Dylan Araps 2018-02-03 10:50:22 +11:00
parent c4b5a667c9
commit a3bedee34a
3 changed files with 14 additions and 10 deletions

View File

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

View File

@ -64,7 +64,7 @@ def create_palette(img, colors, light):
if light:
# Manually adjust colors.
raw_colors[7] = raw_colors[0]
raw_colors[0] = util.lighten_color(raw_colors[15], 0.85)
raw_colors[0] = util.lighten_color(raw_colors[15], 0.90)
raw_colors[15] = raw_colors[7]
raw_colors[8] = util.lighten_color(raw_colors[7], 0.25)
@ -75,7 +75,6 @@ def create_palette(img, colors, light):
# Manually adjust colors.
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.blend_color(raw_colors[15], "#EEEEEE")
colors = {"wallpaper": img, "alpha": util.Color.alpha_num,
@ -86,10 +85,12 @@ def create_palette(img, colors, light):
if light:
for i, color in enumerate(raw_colors):
color = util.darken_color(color, 0.30)
colors["colors"]["color%s" % i] = util.saturate_color(color, 50)
colors["colors"]["color%s" % i] = util.saturate_color(color, 0.5)
colors["colors"]["color0"] = raw_colors[0]
colors["colors"]["color7"] = raw_colors[15]
colors["colors"]["color8"] = util.darken_color(raw_colors[0], 0.5)
colors["colors"]["color15"] = raw_colors[15]
else:
for i, color in enumerate(raw_colors):

View File

@ -1,6 +1,7 @@
"""
Misc helper functions.
"""
import colorsys
import json
import os
import shutil
@ -124,12 +125,14 @@ def blend_color(color, color2):
def saturate_color(color, amount):
"""Saturate a hex color."""
r, g, b = hex_to_rgb(color)
r, g, b = [x/255.0 for x in (r, g, b)]
h, s, v = colorsys.rgb_to_hsv(r, g, b)
s = amount
v = 0.2
r, g, b = colorsys.hls_to_rgb(h, s, v)
r, g, b = [x*255.0 for x in (r, g, b)]
r2 = r + amount
g2 = g + amount
b2 = b + amount
return rgb_to_hex((r2, g2, b2))
return rgb_to_hex((int(r), int(g), int(b)))
def disown(cmd):