mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-05-29 22:18:49 +02:00
Made all backend scripts, use the newly modified adjust function from colors.py, that makes pywal generate darker shades for 1-7
This commit is contained in:
parent
236aa48e74
commit
e504c55e70
@ -13,6 +13,7 @@ except ImportError:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
from .. import util
|
from .. import util
|
||||||
|
from .. import colors
|
||||||
|
|
||||||
|
|
||||||
def gen_colors(img):
|
def gen_colors(img):
|
||||||
@ -25,7 +26,7 @@ def gen_colors(img):
|
|||||||
if len(raw_colors) >= 8:
|
if len(raw_colors) >= 8:
|
||||||
break
|
break
|
||||||
|
|
||||||
if i == 10:
|
elif i == 10:
|
||||||
logging.error("ColorThief couldn't generate a suitable palette.")
|
logging.error("ColorThief couldn't generate a suitable palette.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -41,21 +42,7 @@ def adjust(cols, light):
|
|||||||
cols.sort(key=util.rgb_to_yiq)
|
cols.sort(key=util.rgb_to_yiq)
|
||||||
raw_colors = [*cols, *cols]
|
raw_colors = [*cols, *cols]
|
||||||
|
|
||||||
if light:
|
return colors.generic_adjust(raw_colors, light)
|
||||||
raw_colors[0] = util.lighten_color(cols[0], 0.90)
|
|
||||||
raw_colors[7] = util.darken_color(cols[0], 0.75)
|
|
||||||
|
|
||||||
else:
|
|
||||||
for color in raw_colors:
|
|
||||||
color = util.lighten_color(color, 0.40)
|
|
||||||
|
|
||||||
raw_colors[0] = util.darken_color(cols[0], 0.80)
|
|
||||||
raw_colors[7] = util.lighten_color(cols[0], 0.60)
|
|
||||||
|
|
||||||
raw_colors[8] = util.lighten_color(cols[0], 0.20)
|
|
||||||
raw_colors[15] = raw_colors[7]
|
|
||||||
|
|
||||||
return raw_colors
|
|
||||||
|
|
||||||
|
|
||||||
def get(img, light=False):
|
def get(img, light=False):
|
||||||
|
@ -8,6 +8,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from .. import util
|
from .. import util
|
||||||
|
from .. import colors
|
||||||
|
|
||||||
|
|
||||||
def imagemagick(color_count, img, magick_command):
|
def imagemagick(color_count, img, magick_command):
|
||||||
@ -43,7 +44,7 @@ def gen_colors(img):
|
|||||||
if len(raw_colors) > 16:
|
if len(raw_colors) > 16:
|
||||||
break
|
break
|
||||||
|
|
||||||
if i == 19:
|
elif i == 19:
|
||||||
logging.error("Imagemagick couldn't generate a suitable palette.")
|
logging.error("Imagemagick couldn't generate a suitable palette.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -54,31 +55,12 @@ def gen_colors(img):
|
|||||||
return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]]
|
return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]]
|
||||||
|
|
||||||
|
|
||||||
def adjust(colors, light):
|
def adjust(cols, light):
|
||||||
"""Adjust the generated colors and store them in a dict that
|
"""Adjust the generated colors and store them in a dict that
|
||||||
we will later save in json format."""
|
we will later save in json format."""
|
||||||
raw_colors = colors[:1] + colors[8:16] + colors[8:-1]
|
raw_colors = cols[:1] + cols[8:16] + cols[8:-1]
|
||||||
|
|
||||||
# Manually adjust colors.
|
return colors.generic_adjust(raw_colors, light)
|
||||||
if light:
|
|
||||||
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.40)
|
|
||||||
|
|
||||||
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")
|
|
||||||
|
|
||||||
return raw_colors
|
|
||||||
|
|
||||||
|
|
||||||
def get(img, light=False):
|
def get(img, light=False):
|
||||||
|
@ -67,16 +67,31 @@ def generic_adjust(colors, light):
|
|||||||
color = util.saturate_color(color, 0.60)
|
color = util.saturate_color(color, 0.60)
|
||||||
color = util.darken_color(color, 0.5)
|
color = util.darken_color(color, 0.5)
|
||||||
|
|
||||||
colors[0] = util.lighten_color(colors[0], 0.95)
|
|
||||||
colors[7] = util.darken_color(colors[0], 0.75)
|
colors[0] = util.lighten_color(colors[0], 0.75)
|
||||||
|
colors[7] = util.darken_color(colors[0], 0.50)
|
||||||
colors[8] = util.darken_color(colors[0], 0.25)
|
colors[8] = util.darken_color(colors[0], 0.25)
|
||||||
colors[15] = colors[7]
|
colors[1] = util.darken_color(colors[9], 0.25)
|
||||||
|
colors[2] = util.darken_color(colors[10], 0.25)
|
||||||
|
colors[3] = util.darken_color(colors[11], 0.25)
|
||||||
|
colors[4] = util.darken_color(colors[12], 0.25)
|
||||||
|
colors[5] = util.darken_color(colors[13], 0.25)
|
||||||
|
colors[6] = util.darken_color(colors[14], 0.25)
|
||||||
|
colors[15] = util.darken_color(colors[0], 0.75)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
colors[0] = util.darken_color(colors[0], 0.80)
|
|
||||||
colors[7] = util.lighten_color(colors[0], 0.75)
|
colors[0] = util.darken_color(colors[0], 0.75)
|
||||||
|
colors[7] = util.lighten_color(colors[0], 0.50)
|
||||||
colors[8] = util.lighten_color(colors[0], 0.25)
|
colors[8] = util.lighten_color(colors[0], 0.25)
|
||||||
colors[15] = colors[7]
|
colors[1] = util.darken_color(colors[9], 0.25)
|
||||||
|
colors[2] = util.darken_color(colors[10], 0.25)
|
||||||
|
colors[3] = util.darken_color(colors[11], 0.25)
|
||||||
|
colors[4] = util.darken_color(colors[12], 0.25)
|
||||||
|
colors[5] = util.darken_color(colors[13], 0.25)
|
||||||
|
colors[6] = util.darken_color(colors[14], 0.25)
|
||||||
|
colors[15] = util.lighten_color(colors[0], 0.75)
|
||||||
|
|
||||||
|
|
||||||
return colors
|
return colors
|
||||||
|
|
||||||
@ -95,11 +110,9 @@ def cache_fname(img, backend, light, cache_dir, sat=""):
|
|||||||
"""Create the cache file name."""
|
"""Create the cache file name."""
|
||||||
color_type = "light" if light else "dark"
|
color_type = "light" if light else "dark"
|
||||||
file_name = re.sub("[/|\\|.]", "_", img)
|
file_name = re.sub("[/|\\|.]", "_", img)
|
||||||
file_size = os.path.getsize(img)
|
|
||||||
|
|
||||||
file_parts = [file_name, color_type, backend,
|
file_parts = [file_name, color_type, backend, sat, __cache_version__]
|
||||||
sat, file_size, __cache_version__]
|
return [cache_dir, "schemes", "%s_%s_%s_%s_%s.json" % (*file_parts,)]
|
||||||
return [cache_dir, "schemes", "%s_%s_%s_%s_%s_%s.json" % (*file_parts,)]
|
|
||||||
|
|
||||||
|
|
||||||
def get_backend(backend):
|
def get_backend(backend):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user