use 16 color adjust in fast_colorthief

This commit is contained in:
eylles 2022-02-20 05:41:29 -06:00
parent 34e2dd28ab
commit 7aa7085d5f
No known key found for this signature in database
GPG Key ID: 87BB13678A662E19

View File

@ -13,6 +13,7 @@ except ImportError:
sys.exit(1)
from .. import util
from .. import colors
def gen_colors(img):
@ -22,29 +23,15 @@ def gen_colors(img):
return [util.rgb_to_hex(color) for color in raw_colors]
def adjust(cols, light):
def adjust(cols, light, cols16):
"""Create palette."""
cols.sort(key=util.rgb_to_yiq)
raw_colors = [*cols, *cols]
if 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
return colors.generic_adjust(raw_colors, light, cols16)
def get(img, light=False):
def get(img, light=False, cols16=False):
"""Get colorscheme."""
cols = gen_colors(img)
return adjust(cols, light)
return adjust(cols, light, cols16)