summaryrefslogtreecommitdiff
path: root/pywal/backends/haishoku.py
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2018-03-31 16:31:26 +1100
committerDylan Araps <dylan.araps@gmail.com>2018-03-31 16:31:26 +1100
commit435e4cd2a87d58816f8bb22bf803177c87d29a1e (patch)
tree782d2c40fc9ca0c0aacb3dd6e0e6b5de554221bf /pywal/backends/haishoku.py
parentb514de8e8a79c7524e43284c86be61f97063d3a9 (diff)
backend: Add haishoku
Diffstat (limited to 'pywal/backends/haishoku.py')
-rw-r--r--pywal/backends/haishoku.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/pywal/backends/haishoku.py b/pywal/backends/haishoku.py
new file mode 100644
index 0000000..413c9d7
--- /dev/null
+++ b/pywal/backends/haishoku.py
@@ -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)