Skip to content

Instantly share code, notes, and snippets.

@evuez
Created April 17, 2015 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evuez/895986822449ef300ab8 to your computer and use it in GitHub Desktop.
Save evuez/895986822449ef300ab8 to your computer and use it in GitHub Desktop.
Lighten a color
def lighten(color, scale=1.0):
"""
Lighten a color.
- color must be a tuple (r, g, b, a)
- scale can be any number, if < 1, color will be darkened
"""
return map(
lambda x: int(min(max(x * scale, 0), 255)),
color[:3]
) + list(color[3:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment