Skip to content

Commit

Permalink
Error suppression in color lightness function
Browse files Browse the repository at this point in the history
  • Loading branch information
duracell80 committed Aug 21, 2022
1 parent b546458 commit 5c2946c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ def adjust_brightness(img, brightness_factor):
def adjust_color_lightness(r, g, b, factor):
h, l, s = rgb2hls(r / 255.0, g / 255.0, b / 255.0)
l = max(min(l * factor, 1.0), 0.0)
if h > 1:
h = 1
if l > 1:
l = 1
if s > 1:
s = 1
r, g, b = hls2rgb(h, l, s)
return rgb2hex(int(r * 255), int(g * 255), int(b * 255))

Expand Down

0 comments on commit 5c2946c

Please sign in to comment.