mirror of
https://github.com/dylanaraps/pywal.git
synced 2024-11-25 17:33:09 +01:00
backend: Add haishoku
This commit is contained in:
parent
b514de8e8a
commit
435e4cd2a8
@ -11,12 +11,14 @@ Created by Dylan Araps.
|
||||
|
||||
from . import colorthief
|
||||
from . import colorz
|
||||
from . import haishoku
|
||||
from . import schemer2
|
||||
from . import wal
|
||||
|
||||
__all__ = [
|
||||
"colorthief",
|
||||
"colorz",
|
||||
"haishoku",
|
||||
"schemer2",
|
||||
"wal",
|
||||
]
|
||||
|
@ -17,8 +17,8 @@ def gen_colors(img):
|
||||
|
||||
def adjust(cols, light):
|
||||
"""Create palette."""
|
||||
# Create list with placeholder values.
|
||||
bg = util.blend_color("#555555", cols[1])
|
||||
|
||||
raw_colors = [bg, *cols, "#FFFFFF",
|
||||
"#333333", *cols, "#FFFFFF"]
|
||||
|
||||
|
36
pywal/backends/haishoku.py
Normal file
36
pywal/backends/haishoku.py
Normal file
@ -0,0 +1,36 @@
|
||||
"""
|
||||
Generate a colorscheme using Haishoku.
|
||||
"""
|
||||
import sys
|
||||
|
||||
try:
|
||||
from haishoku.haishoku import Haishoku
|
||||
|
||||
except ImportError:
|
||||
print("error: Haishoku wasn't found on your system.",
|
||||
"Try another backend. (wal --backend)")
|
||||
sys.exit(1)
|
||||
|
||||
from .. import colors
|
||||
from .. import util
|
||||
|
||||
|
||||
def gen_colors(img):
|
||||
"""Generate a colorscheme using Colorz."""
|
||||
palette = Haishoku.getPalette(img)
|
||||
return [util.rgb_to_hex(col[1]) for col in palette]
|
||||
|
||||
|
||||
def adjust(cols, light):
|
||||
"""Create palette."""
|
||||
cols.sort(key=util.rgb_to_yiq)
|
||||
raw_colors = [*cols, *cols]
|
||||
raw_colors[0] = util.lighten_color(cols[0], 0.40)
|
||||
|
||||
return colors.generic_adjust(raw_colors, light)
|
||||
|
||||
|
||||
def get(img, light=False):
|
||||
"""Get colorscheme."""
|
||||
cols = gen_colors(img)
|
||||
return adjust(cols, light)
|
@ -17,7 +17,6 @@ def gen_colors(img):
|
||||
|
||||
def adjust(cols, light):
|
||||
"""Create palette."""
|
||||
# Create list with placeholder values.
|
||||
cols.sort(key=util.rgb_to_yiq)
|
||||
raw_colors = [*cols[8:], *cols[8:]]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user