mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-09 15:38:30 +01:00
backend: cleanup
This commit is contained in:
parent
dc09707a87
commit
b514de8e8a
@ -36,23 +36,23 @@ def gen_colors(img):
|
|||||||
return [util.rgb_to_hex(color) for color in raw_colors]
|
return [util.rgb_to_hex(color) for color in raw_colors]
|
||||||
|
|
||||||
|
|
||||||
def adjust(colors, light):
|
def adjust(cols, light):
|
||||||
"""Create palette."""
|
"""Create palette."""
|
||||||
colors.sort(key=util.rgb_to_yiq)
|
cols.sort(key=util.rgb_to_yiq)
|
||||||
raw_colors = [*colors, *colors]
|
raw_colors = [*cols, *cols]
|
||||||
|
|
||||||
if light:
|
if light:
|
||||||
raw_colors[0] = util.lighten_color(colors[0], 0.90)
|
raw_colors[0] = util.lighten_color(cols[0], 0.90)
|
||||||
raw_colors[7] = util.darken_color(colors[0], 0.75)
|
raw_colors[7] = util.darken_color(cols[0], 0.75)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for color in raw_colors:
|
for color in raw_colors:
|
||||||
color = util.lighten_color(color, 0.40)
|
color = util.lighten_color(color, 0.40)
|
||||||
|
|
||||||
raw_colors[0] = util.darken_color(colors[0], 0.80)
|
raw_colors[0] = util.darken_color(cols[0], 0.80)
|
||||||
raw_colors[7] = util.lighten_color(colors[0], 0.60)
|
raw_colors[7] = util.lighten_color(cols[0], 0.60)
|
||||||
|
|
||||||
raw_colors[8] = util.lighten_color(colors[0], 0.20)
|
raw_colors[8] = util.lighten_color(cols[0], 0.20)
|
||||||
raw_colors[15] = raw_colors[7]
|
raw_colors[15] = raw_colors[7]
|
||||||
|
|
||||||
return raw_colors
|
return raw_colors
|
||||||
@ -60,5 +60,5 @@ def adjust(colors, light):
|
|||||||
|
|
||||||
def get(img, light=False):
|
def get(img, light=False):
|
||||||
"""Get colorscheme."""
|
"""Get colorscheme."""
|
||||||
colors = gen_colors(img)
|
cols = gen_colors(img)
|
||||||
return adjust(colors, light)
|
return adjust(cols, light)
|
||||||
|
@ -5,6 +5,7 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from .. import colors
|
||||||
from .. import util
|
from .. import util
|
||||||
|
|
||||||
|
|
||||||
@ -14,30 +15,14 @@ def gen_colors(img):
|
|||||||
return subprocess.check_output([*cmd, img]).splitlines()
|
return subprocess.check_output([*cmd, img]).splitlines()
|
||||||
|
|
||||||
|
|
||||||
def adjust(colors, light):
|
def adjust(cols, light):
|
||||||
"""Create palette."""
|
"""Create palette."""
|
||||||
# Create list with placeholder values.
|
# Create list with placeholder values.
|
||||||
raw_colors = ["#000000", *colors, "#FFFFFF",
|
bg = util.blend_color("#555555", cols[1])
|
||||||
"#333333", *colors, "#FFFFFF"]
|
raw_colors = [bg, *cols, "#FFFFFF",
|
||||||
|
"#333333", *cols, "#FFFFFF"]
|
||||||
|
|
||||||
# Update placeholder values.
|
return colors.generic_adjust(raw_colors, light)
|
||||||
if light:
|
|
||||||
for color in raw_colors:
|
|
||||||
color = util.saturate_color(color, 0.50)
|
|
||||||
color = util.darken_color(color, 0.4)
|
|
||||||
|
|
||||||
raw_colors[0] = util.lighten_color(colors[0], 0.9)
|
|
||||||
raw_colors[7] = util.darken_color(colors[0], 0.75)
|
|
||||||
raw_colors[8] = util.darken_color(colors[0], 0.25)
|
|
||||||
raw_colors[15] = raw_colors[7]
|
|
||||||
|
|
||||||
else:
|
|
||||||
raw_colors[0] = util.darken_color(colors[0], 0.75)
|
|
||||||
raw_colors[7] = util.lighten_color(colors[0], 0.75)
|
|
||||||
raw_colors[8] = util.darken_color(colors[0], 0.25)
|
|
||||||
raw_colors[15] = raw_colors[7]
|
|
||||||
|
|
||||||
return raw_colors
|
|
||||||
|
|
||||||
|
|
||||||
def get(img, light=False):
|
def get(img, light=False):
|
||||||
@ -47,6 +32,5 @@ def get(img, light=False):
|
|||||||
"Try another backend. (wal --backend)")
|
"Try another backend. (wal --backend)")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
colors = gen_colors(img)
|
cols = [col.decode('UTF-8').split()[0] for col in gen_colors(img)]
|
||||||
colors = [color.decode('UTF-8').split()[0] for color in colors]
|
return adjust(cols, light)
|
||||||
return adjust(colors, light)
|
|
||||||
|
@ -5,6 +5,7 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from .. import colors
|
||||||
from .. import util
|
from .. import util
|
||||||
|
|
||||||
|
|
||||||
@ -14,30 +15,13 @@ def gen_colors(img):
|
|||||||
return subprocess.check_output([*cmd, img]).splitlines()
|
return subprocess.check_output([*cmd, img]).splitlines()
|
||||||
|
|
||||||
|
|
||||||
def adjust(colors, light):
|
def adjust(cols, light):
|
||||||
"""Create palette."""
|
"""Create palette."""
|
||||||
# Create list with placeholder values.
|
# Create list with placeholder values.
|
||||||
colors.sort(key=util.rgb_to_yiq)
|
cols.sort(key=util.rgb_to_yiq)
|
||||||
raw_colors = [*colors[8:], *colors[8:]]
|
raw_colors = [*cols[8:], *cols[8:]]
|
||||||
|
|
||||||
# Update placeholder values.
|
return colors.generic_adjust(raw_colors, light)
|
||||||
if light:
|
|
||||||
for color in raw_colors:
|
|
||||||
color = util.saturate_color(color, 0.50)
|
|
||||||
color = util.darken_color(color, 0.4)
|
|
||||||
|
|
||||||
raw_colors[0] = util.lighten_color(colors[0], 0.9)
|
|
||||||
raw_colors[7] = util.darken_color(colors[0], 0.75)
|
|
||||||
raw_colors[8] = util.darken_color(colors[0], 0.25)
|
|
||||||
raw_colors[15] = raw_colors[7]
|
|
||||||
|
|
||||||
else:
|
|
||||||
raw_colors[0] = util.darken_color(colors[0], 0.75)
|
|
||||||
raw_colors[7] = util.lighten_color(colors[0], 0.75)
|
|
||||||
raw_colors[8] = util.lighten_color(colors[0], 0.25)
|
|
||||||
raw_colors[15] = raw_colors[7]
|
|
||||||
|
|
||||||
return raw_colors
|
|
||||||
|
|
||||||
|
|
||||||
def get(img, light=False):
|
def get(img, light=False):
|
||||||
@ -47,6 +31,5 @@ def get(img, light=False):
|
|||||||
"Try another backend. (wal --backend)")
|
"Try another backend. (wal --backend)")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
colors = gen_colors(img)
|
cols = [col.decode('UTF-8') for col in gen_colors(img)]
|
||||||
colors = [color.decode('UTF-8') for color in colors]
|
return adjust(cols, light)
|
||||||
return adjust(colors, light)
|
|
||||||
|
@ -3,7 +3,6 @@ Generate a palette using various backends.
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from . import backends
|
from . import backends
|
||||||
@ -33,6 +32,27 @@ def colors_to_dict(colors, img):
|
|||||||
return scheme
|
return scheme
|
||||||
|
|
||||||
|
|
||||||
|
def generic_adjust(colors, light):
|
||||||
|
"""Generic color adjustment for themers."""
|
||||||
|
if light:
|
||||||
|
for color in colors:
|
||||||
|
color = util.saturate_color(color, 0.50)
|
||||||
|
color = util.darken_color(color, 0.4)
|
||||||
|
|
||||||
|
colors[0] = util.lighten_color(colors[0], 0.9)
|
||||||
|
colors[7] = util.darken_color(colors[0], 0.75)
|
||||||
|
colors[8] = util.darken_color(colors[0], 0.25)
|
||||||
|
colors[15] = colors[7]
|
||||||
|
|
||||||
|
else:
|
||||||
|
colors[0] = util.darken_color(colors[0], 0.75)
|
||||||
|
colors[7] = util.lighten_color(colors[0], 0.75)
|
||||||
|
colors[8] = util.lighten_color(colors[0], 0.25)
|
||||||
|
colors[15] = colors[7]
|
||||||
|
|
||||||
|
return colors
|
||||||
|
|
||||||
|
|
||||||
def gen(img, light=False, backend="wal", cache_dir=CACHE_DIR):
|
def gen(img, light=False, backend="wal", cache_dir=CACHE_DIR):
|
||||||
"""Generate a palette."""
|
"""Generate a palette."""
|
||||||
# home_dylan_img_jpg_backend_1.2.2.json
|
# home_dylan_img_jpg_backend_1.2.2.json
|
||||||
|
Loading…
Reference in New Issue
Block a user