summaryrefslogtreecommitdiff
path: root/pywal
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2018-01-07 10:03:41 +1100
committerDylan Araps <dylan.araps@gmail.com>2018-01-07 10:03:41 +1100
commite06f53dc96949974e5e36af1bb8bf90c9a533cc9 (patch)
treeb3476c914b6d097fb7ce92114f19b9bb883ea3b0 /pywal
parentb9d6eb8914cc4e4c7490a4e858fee44f99d7326d (diff)
colors: better sort and better white by blending.
Diffstat (limited to 'pywal')
-rw-r--r--pywal/colors.py6
-rw-r--r--pywal/util.py12
2 files changed, 15 insertions, 3 deletions
diff --git a/pywal/colors.py b/pywal/colors.py
index fbb045d..4c7e308 100644
--- a/pywal/colors.py
+++ b/pywal/colors.py
@@ -59,16 +59,16 @@ def gen_colors(img, color_count):
def create_palette(img, colors):
"""Sort the generated colors and store them in a dict that
we will later save in json format."""
- raw_colors = colors[:1] + colors[8:] + colors[8:-1]
+ raw_colors = colors[:1] + colors[8:16] + colors[8:-1]
# Darken the background color slightly.
if raw_colors[0][1] != "0":
raw_colors[0] = util.darken_color(raw_colors[0], 0.25)
# Manually adjust colors.
- raw_colors[7] = util.lighten_color(raw_colors[7], 0.25)
+ 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.lighten_color(raw_colors[15], 0.25)
+ raw_colors[15] = util.blend_color(raw_colors[15], "#EEEEEE")
colors = {"wallpaper": img, "special": {}, "colors": {}}
colors["special"]["background"] = raw_colors[0]
diff --git a/pywal/util.py b/pywal/util.py
index b8ff682..ad1d9cf 100644
--- a/pywal/util.py
+++ b/pywal/util.py
@@ -109,6 +109,18 @@ def lighten_color(color, amount):
return rgb_to_hex(color)
+def blend_color(color, color2):
+ """Blend two colors together."""
+ r1, g1, b1 = hex_to_rgb(color)
+ r2, g2, b2 = hex_to_rgb(color2)
+
+ r3 = int(0.5 * r1 + 0.5 * r2)
+ g3 = int(0.5 * g1 + 0.5 * g2)
+ b3 = int(0.5 * b1 + 0.5 * b2)
+
+ return rgb_to_hex((r3, g3, b3))
+
+
def disown(cmd):
"""Call a system command in the background,
disown it and hide it's output."""