diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2018-02-03 10:50:22 +1100 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2018-02-03 10:50:22 +1100 |
| commit | a3bedee34a7559451ac26b3f8dcab4d59893312a (patch) | |
| tree | 57626ce94fc24090d897e3498cba79e33ee59ce2 | |
| parent | c4b5a667c94f895c3d3c8a61e4a6739185b7b1b6 (diff) | |
colors: Add light theme support.
| -rw-r--r-- | .pylintrc | 2 | ||||
| -rw-r--r-- | pywal/colors.py | 9 | ||||
| -rw-r--r-- | pywal/util.py | 15 |
3 files changed, 15 insertions, 11 deletions
@@ -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: diff --git a/pywal/colors.py b/pywal/colors.py index 8d5ea87..19c461b 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -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): diff --git a/pywal/util.py b/pywal/util.py index 5550eec..a2325e8 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -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) - - r2 = r + amount - g2 = g + amount - b2 = b + amount - - return rgb_to_hex((r2, g2, b2)) + 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)] + + return rgb_to_hex((int(r), int(g), int(b))) def disown(cmd): |
