Last active
August 14, 2017 18:18
-
-
Save zallesov/e34cc61f0ec568de54805b59ce2c13b4 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
static Color biasedColor(Color color, float offset){ | |
float value = (color.r + color.g + color.b) / 3.0; | |
float newValue = value+2.0*((float)random(0,10000)/10000.0)*offset-offset; | |
float valueRatio = newValue / value; | |
int R = (int)((float)color.r * valueRatio); | |
int G = (int)((float)color.g * valueRatio); | |
int B = (int)((float)color.b * valueRatio); | |
return Color(R,G,B); | |
} | |
static Color fadeColor(Color color, float ratio) { | |
Color newColor; | |
newColor.r = color.r * ratio; | |
newColor.g = color.g * ratio; | |
newColor.b = color.b * ratio; | |
return newColor; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment