mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-06-19 17:19:08 +02:00
backend: Add colorthief.py
This commit is contained in:
parent
7d4eb6b075
commit
6430724400
@ -9,7 +9,7 @@ from .. import util
|
||||
from ..settings import COLOR_COUNT
|
||||
|
||||
|
||||
def create_palette(img, colors):
|
||||
def adjust(img, colors):
|
||||
"""Create palette."""
|
||||
raw_colors = colors[:1] + colors[8:16] + colors[8:-1]
|
||||
|
||||
@ -61,4 +61,4 @@ def gen_colors(img, color_count):
|
||||
def get(img, color_count=COLOR_COUNT, light=False):
|
||||
"""Get colorscheme."""
|
||||
colors = gen_colors(img, color_count)
|
||||
return create_palette(img, colors)
|
||||
return adjust(img, colors)
|
||||
|
@ -56,7 +56,7 @@ def gen_colors(img, color_count):
|
||||
return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]]
|
||||
|
||||
|
||||
def create_palette(img, colors, light):
|
||||
def adjust(img, colors, light):
|
||||
"""Sort 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]
|
||||
@ -103,4 +103,4 @@ def create_palette(img, colors, light):
|
||||
def get(img, color_count=COLOR_COUNT, light=False):
|
||||
"""Get colorscheme."""
|
||||
colors = gen_colors(img, color_count)
|
||||
return create_palette(img, colors, light)
|
||||
return adjust(img, colors, light)
|
||||
|
@ -24,8 +24,9 @@ def generate(img, cache_dir=CACHE_DIR,
|
||||
# home_dylan_img_jpg_1.2.2.json
|
||||
color_type = "light" if light else "dark"
|
||||
cache_file = re.sub("[/|\\|.]", "_", img)
|
||||
cache_file = os.path.join(cache_dir, "schemes", "%s_%s_%s.json"
|
||||
% (cache_file, color_type, __cache_version__))
|
||||
cache_file = os.path.join(cache_dir, "schemes", "%s_%s_%s_%s.json"
|
||||
% (cache_file, color_type,
|
||||
backend, __cache_version__))
|
||||
|
||||
if os.path.isfile(cache_file):
|
||||
colors = file(cache_file)
|
||||
|
Loading…
x
Reference in New Issue
Block a user