summaryrefslogtreecommitdiff
path: root/pywal
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2018-02-02 19:32:30 +1100
committerDylan Araps <dylan.araps@gmail.com>2018-02-02 19:32:30 +1100
commit69604342a15066b3c7db09b0d2618fe415b871c0 (patch)
tree47eec7ca302606d85be9883d1af955e102850fcb /pywal
parent059eeecfcd368b3a416331a68561e8af44064f23 (diff)
colors: Add light theme support.
Diffstat (limited to 'pywal')
-rw-r--r--pywal/__main__.py5
-rw-r--r--pywal/colors.py54
-rw-r--r--pywal/util.py11
3 files changed, 52 insertions, 18 deletions
diff --git a/pywal/__main__.py b/pywal/__main__.py
index 283b47f..867e7cb 100644
--- a/pywal/__main__.py
+++ b/pywal/__main__.py
@@ -48,6 +48,9 @@ def get_args(args):
arg.add_argument("-g", action="store_true",
help="Generate an oomox theme.")
+ arg.add_argument("-l", action="store_true",
+ help="Generate a light colorscheme.")
+
arg.add_argument("-n", action="store_true",
help="Skip setting the wallpaper.")
@@ -118,7 +121,7 @@ def process_args(args):
if args.i:
image_file = image.get(args.i)
- colors_plain = colors.get(image_file, notify=not args.q)
+ colors_plain = colors.get(image_file, light=args.l, notify=not args.q)
if args.f:
colors_plain = colors.file(args.f)
diff --git a/pywal/colors.py b/pywal/colors.py
index 53321eb..5ed0e62 100644
--- a/pywal/colors.py
+++ b/pywal/colors.py
@@ -56,34 +56,54 @@ 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):
+def create_palette(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]
- # Darken the background color slightly.
- if raw_colors[0][1] != "0":
- raw_colors[0] = util.darken_color(raw_colors[0], 0.25)
+ if light:
+ # Manually adjust colors.
+ raw_colors[7] = raw_colors[0]
+ raw_colors[0] = util.lighten_color(raw_colors[15], 0.9)
+ raw_colors[15] = raw_colors[7]
+ raw_colors[8] = util.lighten_color(raw_colors[7], 0.25)
- # Manually adjust colors.
- 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.blend_color(raw_colors[15], "#EEEEEE")
+ colors = {"wallpaper": img, "alpha": util.Color.alpha_num,
+ "special": {}, "colors": {}}
+ colors["special"]["background"] = raw_colors[0]
+ colors["special"]["foreground"] = raw_colors[15]
+ colors["special"]["cursor"] = raw_colors[15]
- colors = {"wallpaper": img, "alpha": util.Color.alpha_num,
- "special": {}, "colors": {}}
- colors["special"]["background"] = raw_colors[0]
- colors["special"]["foreground"] = raw_colors[15]
- colors["special"]["cursor"] = raw_colors[15]
+ for i, color in enumerate(raw_colors):
+ color = util.darken_color(color, 0.30)
+ colors["colors"]["color%s" % i] = util.saturate_color(color, 50)
- for i, color in enumerate(raw_colors):
- colors["colors"]["color%s" % i] = color
+ colors["colors"]["color0"] = raw_colors[0]
+
+ else:
+ # 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.blend_color(raw_colors[7], "#EEEEEE")
+ raw_colors[8] = util.darken_color(raw_colors[7], 0.30)
+ raw_colors[15] = util.blend_color(raw_colors[15], "#EEEEEE")
+
+ colors = {"wallpaper": img, "alpha": util.Color.alpha_num,
+ "special": {}, "colors": {}}
+ colors["special"]["background"] = raw_colors[0]
+ colors["special"]["foreground"] = raw_colors[15]
+ colors["special"]["cursor"] = raw_colors[15]
+
+ for i, color in enumerate(raw_colors):
+ colors["colors"]["color%s" % i] = color
return colors
def get(img, cache_dir=CACHE_DIR,
- color_count=COLOR_COUNT, notify=False):
+ color_count=COLOR_COUNT, light=False, notify=False):
"""Get the colorscheme."""
# home_dylan_img_jpg_1.2.2.json
cache_file = re.sub("[/|\\|.]", "_", img)
@@ -99,7 +119,7 @@ def get(img, cache_dir=CACHE_DIR,
util.msg("wal: Generating a colorscheme...", notify)
colors = gen_colors(img, color_count)
- colors = create_palette(img, colors)
+ colors = create_palette(img, colors, light)
util.save_file_json(colors, cache_file)
util.msg("wal: Generation complete.", notify)
diff --git a/pywal/util.py b/pywal/util.py
index 70dca2f..5550eec 100644
--- a/pywal/util.py
+++ b/pywal/util.py
@@ -121,6 +121,17 @@ def blend_color(color, color2):
return rgb_to_hex((r3, g3, b3))
+def saturate_color(color, amount):
+ """Saturate a hex color."""
+ r, g, b = hex_to_rgb(color)
+
+ r2 = r + amount
+ g2 = g + amount
+ b2 = b + amount
+
+ return rgb_to_hex((r2, g2, b2))
+
+
def disown(cmd):
"""Call a system command in the background,
disown it and hide it's output."""