Skip to content

Commit

Permalink
make contrast actually do something
Browse files Browse the repository at this point in the history
  • Loading branch information
AtelierSnek authored and eylles committed Aug 24, 2024
1 parent 42b7ada commit 4b816cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pywal/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def get_args():
help="Skip reloading gtk/xrdb/i3/sway/polybar")

arg.add_argument("--contrast", metavar="1.0-21.0",
required = False, type=float, nargs='?',
help="Specify a minimum contrast ratio between palette "
"colors and the source image according to W3 "
"contrast specifications. Values between 1.5-4.5 "
Expand Down Expand Up @@ -201,7 +202,7 @@ def parse_args(parser):
if args.w:
cached_wallpaper = util.read_file(os.path.join(CACHE_DIR, "wal"))
colors_plain = colors.get(cached_wallpaper[0], args.l, args.cols16, args.backend,
sat=args.saturate)
sat=args.saturate,contrast=args.contrast)

if args.b:
args.b = "#%s" % (args.b.strip("#"))
Expand Down
10 changes: 7 additions & 3 deletions pywal/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ def ensure_contrast(colors, contrast, light, image):
# produce the desired luminance, additionally decrease saturation
elif not light:
colors[index] = binary_luminance_adjust(luminance_desired, h, 0, s, 1, 1)
# If the color is to be darker than background, produce desired luminance by decreasing value
# If the color is to be darker than background, produce desired luminance by decreasing value, and raising saturation
else:
colors[index] = binary_luminance_adjust(luminance_desired, h, s, s, 0, v)
colors[index] = binary_luminance_adjust(luminance_desired, h, s, 1, 0, v)

return colors

Expand Down Expand Up @@ -283,7 +283,11 @@ def palette():
def get(img, light=False, cols16=False, backend="wal", cache_dir=CACHE_DIR, sat="", contrast=""):
"""Generate a palette."""
# home_dylan_img_jpg_backend_1.2.2.json
cache_name = cache_fname(img, backend, cols16, light, cache_dir, sat, float(contrast))
if not contrast or contrast == "":
cache_name = cache_fname(img, backend, cols16, light, cache_dir, sat, "None")
else:
cache_name = cache_fname(img, backend, cols16, light, cache_dir, sat, float(contrast))

cache_file = os.path.join(*cache_name)

# Check the wallpaper's checksum against the cache'
Expand Down
4 changes: 2 additions & 2 deletions pywal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import platform


__version__ = "3.6.0"
__cache_version__ = "1.1.0"
__version__ = "3.6.1"
__cache_version__ = "2.0.0"


HOME = os.getenv("HOME", os.getenv("USERPROFILE"))
Expand Down

0 comments on commit 4b816cc

Please sign in to comment.