Created
January 11, 2012 16:24
-
-
Save Alquimista/1595443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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