Skip to content

Commit

Permalink
fix multiple statements
Browse files Browse the repository at this point in the history
There should not be any new statement after ":"
  • Loading branch information
eylles committed Oct 31, 2024
1 parent d452daf commit 2ad8cb5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pywal/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,12 @@ def saturate_colors(colors, amount):

return colors


def ensure_contrast(colors, contrast, light, image):
"""Ensure user-specified W3 contrast of colors depending on dark or light theme."""
# If no contrast checking was specified, do nothing
if not contrast or contrast == "": return colors
if not contrast or contrast == "":
return colors

# Contrast must be within a predefined range
if float(contrast) < 1 or float(contrast) > 21:
Expand All @@ -160,8 +162,10 @@ def ensure_contrast(colors, contrast, light, image):
# This will modify all of the colors to be brighter or darker than the background
# image depending on whether the user has specified for a dark or light theme
try:
if light: luminance_desired = (background_luminance + 0.05) / float(contrast) - 0.05
else: luminance_desired = (background_luminance + 0.05) * float(contrast) - 0.05
if light:
luminance_desired = (background_luminance + 0.05) / float(contrast) - 0.05
else:
luminance_desired = (background_luminance + 0.05) * float(contrast) - 0.05
except ValueError:
logging.error("ensure_contrast(): Contrast valued could not be parsed")
return colors
Expand All @@ -182,8 +186,10 @@ def ensure_contrast(colors, contrast, light, image):
color = util.Color(colors[index])

# If the color already has sufficient contrast, do nothing
if light and color.w3_luminance <= luminance_desired: continue
elif color.w3_luminance >= luminance_desired: continue
if light and color.w3_luminance <= luminance_desired:
continue
elif color.w3_luminance >= luminance_desired:
continue

h, s, v = colorsys.rgb_to_hsv(float(color.red), float(color.green), float(color.blue))

Expand Down

0 comments on commit 2ad8cb5

Please sign in to comment.