diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2018-03-31 11:28:28 +1100 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2018-03-31 11:28:28 +1100 |
| commit | 520b065a30152fb9639418ce0557d45c6a07d9a5 (patch) | |
| tree | 3faba953c0174960299a54c34a9d57c6f0cf8e28 /pywal/backends | |
| parent | 32792a0b98baa6c920ebd8fba74a5fa196ae1fd5 (diff) | |
backend: cleanup
Diffstat (limited to 'pywal/backends')
| -rw-r--r-- | pywal/backends/colorthief.py | 29 | ||||
| -rw-r--r-- | pywal/backends/colorz.py | 20 | ||||
| -rw-r--r-- | pywal/backends/wal.py | 42 |
3 files changed, 25 insertions, 66 deletions
diff --git a/pywal/backends/colorthief.py b/pywal/backends/colorthief.py index a35b91e..837fc66 100644 --- a/pywal/backends/colorthief.py +++ b/pywal/backends/colorthief.py @@ -30,36 +30,25 @@ def gen_colors(img): return [util.rgb_to_hex(color) for color in raw_colors] -def adjust(img, colors, light): +def adjust(colors, light): """Create palette.""" if light: print("colors: Colortheif backend doesn't support light themes.") raw_colors = colors[:1] + colors[8:16] + colors[8:-1] - raw_colors[0] = util.darken_color(colors[0], 0.80) - raw_colors[15] = util.lighten_color(colors[15], 0.80) - raw_colors[7] = raw_colors[15] - - colors = {"wallpaper": img, - "alpha": util.Color.alpha_num, - "special": {}, - "colors": {}} - - for i, color in enumerate(raw_colors): - colors["colors"]["color%s" % i] = util.lighten_color(color, 0.25) + for color in raw_colors: + color = util.lighten_color(color, 0.25) - raw_colors[8] = util.blend_color(raw_colors[0], raw_colors[15]) - - colors["colors"]["color0"] = raw_colors[0] - colors["special"]["background"] = raw_colors[0] - colors["special"]["foreground"] = raw_colors[15] - colors["special"]["cursor"] = raw_colors[1] + raw_colors[0] = util.darken_color(colors[0], 0.80) + raw_colors[7] = util.lighten_color(colors[15], 0.60) + raw_colors[8] = util.blend_color(colors[0], colors[15]) + raw_colors[15] = raw_colors[7] - return colors + return raw_colors def get(img, light=False): """Get colorscheme.""" colors = gen_colors(img) - return adjust(img, colors, light) + return adjust(colors, light) diff --git a/pywal/backends/colorz.py b/pywal/backends/colorz.py index 39a0d17..44a07d0 100644 --- a/pywal/backends/colorz.py +++ b/pywal/backends/colorz.py @@ -12,36 +12,26 @@ def gen_colors(img): return subprocess.check_output([*colorz, img]).splitlines() -def adjust(img, colors, light): +def adjust(colors, light): """Create palette.""" if light: print("colors: Colorz backend doesn't support light themes.") + # Create list with placeholder values. raw_colors = ["#000000", *colors, "#FFFFFF", "#333333", *colors, "#FFFFFF"] + # Update placeholder values. raw_colors[0] = util.darken_color(colors[0], 0.75) raw_colors[8] = util.darken_color(colors[0], 0.25) raw_colors[7] = util.lighten_color(colors[0], 0.75) raw_colors[15] = raw_colors[7] - colors = {"wallpaper": img, - "alpha": util.Color.alpha_num, - "special": {}, - "colors": {}} - - for i, color in enumerate(raw_colors): - colors["colors"]["color%s" % i] = color - - colors["special"]["background"] = raw_colors[0] - colors["special"]["foreground"] = raw_colors[15] - colors["special"]["cursor"] = raw_colors[1] - - return colors + return raw_colors def get(img, light=False): """Get colorscheme.""" colors = gen_colors(img) colors = [color.decode('UTF-8').split()[0] for color in colors] - return adjust(img, colors, light) + return adjust(colors, light) diff --git a/pywal/backends/wal.py b/pywal/backends/wal.py index d74ed82..af955a4 100644 --- a/pywal/backends/wal.py +++ b/pywal/backends/wal.py @@ -54,54 +54,34 @@ def gen_colors(img): return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]] -def adjust(img, colors, light): +def adjust(colors, light): """Adjust the generated colors and store them in a dict that we will later save in json format.""" raw_colors = colors[:1] + colors[8:16] + colors[8:-1] + # Manually adjust colors. if light: - # Manually adjust colors. - raw_colors[7] = raw_colors[0] - raw_colors[0] = util.lighten_color(raw_colors[15], 0.85) - raw_colors[15] = raw_colors[7] - raw_colors[8] = util.lighten_color(raw_colors[7], 0.25) + for color in raw_colors: + color = util.saturate_color(color, 0.5) + + raw_colors[0] = util.lighten_color(colors[-1], 0.85) + raw_colors[7] = colors[0] + raw_colors[8] = util.darken_color(colors[-1], 0.4) + raw_colors[15] = colors[0] else: # 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.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, - "special": {}, - "colors": {}} - - colors["special"]["background"] = raw_colors[0] - colors["special"]["foreground"] = raw_colors[15] - colors["special"]["cursor"] = raw_colors[15] - - if light: - for i, color in enumerate(raw_colors): - 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): - colors["colors"]["color%s" % i] = color - - return colors + return raw_colors def get(img, light=False): """Get colorscheme.""" colors = gen_colors(img) - return adjust(img, colors, light) + return adjust(colors, light) |
