From 8ecfdfe5cb2393dfe2a74b52f54afe31134d1225 Mon Sep 17 00:00:00 2001 From: Xin Wu Date: Tue, 23 Jan 2024 22:37:54 -0600 Subject: [PATCH 1/3] add option for brighter colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit colors 8 to 15 are brighter, the old method would darken colors 1 to 6 the new method would be correct at brightening colors 9 to 14 however the old method was kept and the ´--cols´ flag modified to accept the values of darken and lighten. for compatibility and expected behaviour the behaviour when the flag ´--cols16´ is passed without an argument has been kept as darkening colors 1 to 6. --- pywal/__main__.py | 7 +++++-- pywal/colors.py | 26 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index 1d5838f..917c9b2 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -53,8 +53,11 @@ def get_args(): "flag is used: Go through the images in order " "instead of shuffled.") - arg.add_argument("--cols16", action="store_true", - help="Use 16 color output. ") + arg.add_argument("--cols16", metavar="method", required=False, nargs='?', + default=False, const="darken", + choices=['darken', 'lighten'], + help='Use 16 color output' + 'darken or lighten default: darken') arg.add_argument("--recursive", action="store_true", help="When pywal is given a directory as input and this " diff --git a/pywal/colors.py b/pywal/colors.py index a59f5b2..565502b 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -67,7 +67,7 @@ def generic_adjust(colors, light, cols16): color = util.saturate_color(color, 0.60) color = util.darken_color(color, 0.5) - if cols16: + if cols16 == "darken": colors[0] = util.lighten_color(colors[0], 0.95) colors[7] = util.darken_color(colors[0], 0.50) colors[8] = util.darken_color(colors[0], 0.25) @@ -78,6 +78,17 @@ def generic_adjust(colors, light, cols16): colors[5] = util.darken_color(colors[5], 0.25) colors[6] = util.darken_color(colors[6], 0.25) colors[15] = util.darken_color(colors[0], 0.75) + elif cols16 == "lighten": + colors[0] = util.lighten_color(colors[0], 0.95) + colors[7] = util.darken_color(colors[0], 0.50) + colors[8] = util.darken_color(colors[0], 0.25) + colors[9] = util.lighten_color(colors[1], 0.25) + colors[10] = util.lighten_color(colors[2], 0.25) + colors[11] = util.lighten_color(colors[3], 0.25) + colors[12] = util.lighten_color(colors[4], 0.25) + colors[13] = util.lighten_color(colors[5], 0.25) + colors[14] = util.lighten_color(colors[6], 0.25) + colors[15] = util.darken_color(colors[0], 0.75) else: colors[0] = util.lighten_color(colors[0], 0.95) @@ -86,7 +97,7 @@ def generic_adjust(colors, light, cols16): colors[15] = colors[7] else: - if cols16: + if cols16 == "darken": colors[0] = util.darken_color(colors[0], 0.80) colors[7] = util.lighten_color(colors[0], 0.50) colors[8] = util.lighten_color(colors[0], 0.25) @@ -97,6 +108,17 @@ def generic_adjust(colors, light, cols16): colors[5] = util.darken_color(colors[5], 0.25) colors[6] = util.darken_color(colors[6], 0.25) colors[15] = util.lighten_color(colors[0], 0.75) + elif cols16 == "lighten": + colors[0] = util.darken_color(colors[0], 0.80) + colors[7] = util.lighten_color(colors[0], 0.50) + colors[8] = util.lighten_color(colors[0], 0.25) + colors[9] = util.lighten_color(colors[1], 0.25) + colors[10] = util.lighten_color(colors[2], 0.25) + colors[11] = util.lighten_color(colors[3], 0.25) + colors[12] = util.lighten_color(colors[4], 0.25) + colors[13] = util.lighten_color(colors[5], 0.25) + colors[14] = util.lighten_color(colors[6], 0.25) + colors[15] = util.lighten_color(colors[0], 0.75) else: colors[0] = util.darken_color(colors[0], 0.80) From c028e8c68ec8bfeff01ca27340c61dab910d8608 Mon Sep 17 00:00:00 2001 From: eylles Date: Tue, 23 Jan 2024 22:43:08 -0600 Subject: [PATCH 2/3] formatting --- pywal/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index 917c9b2..929de52 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -56,8 +56,8 @@ def get_args(): arg.add_argument("--cols16", metavar="method", required=False, nargs='?', default=False, const="darken", choices=['darken', 'lighten'], - help='Use 16 color output' - 'darken or lighten default: darken') + help='Use 16 color output ' + '\"darken\" or \"lighten\" default: darken') arg.add_argument("--recursive", action="store_true", help="When pywal is given a directory as input and this " From 2405e43c274a1368d54bf2ac66c939732d040d17 Mon Sep 17 00:00:00 2001 From: eylles Date: Tue, 23 Jan 2024 22:50:06 -0600 Subject: [PATCH 3/3] formatting --- pywal/colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pywal/colors.py b/pywal/colors.py index 565502b..d0e98af 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -66,7 +66,7 @@ def generic_adjust(colors, light, cols16): for color in colors: color = util.saturate_color(color, 0.60) color = util.darken_color(color, 0.5) - + if cols16 == "darken": colors[0] = util.lighten_color(colors[0], 0.95) colors[7] = util.darken_color(colors[0], 0.50)