Skip to content

Instantly share code, notes, and snippets.

@zallesov
Last active August 14, 2017 18:18
Show Gist options
  • Save zallesov/e34cc61f0ec568de54805b59ce2c13b4 to your computer and use it in GitHub Desktop.
Save zallesov/e34cc61f0ec568de54805b59ce2c13b4 to your computer and use it in GitHub Desktop.
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