Skip to content

Instantly share code, notes, and snippets.

@Alquimista
Created January 11, 2012 16:24
Show Gist options
  • Save Alquimista/1595443 to your computer and use it in GitHub Desktop.
Save Alquimista/1595443 to your computer and use it in GitHub Desktop.
#http://xiix.wordpress.com/2010/06/23/calculating-opacitys-effect-on-color/
def dark (val, pct):
return int(round(val*(1.0-(pct/100.0))))
def light (val, pct):
return int(round(val+((255-val)*(pct/100.0))))
def darken (R, G, B, pct):
return (dark(R, pct), dark(G, pct), dark(B, pct))
def lighten (R, G, B, pct):
return (light(R, pct), light(G, pct), light(B, pct))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment