I have a function that takes a given color and I would like it to darken the color (reduce its brightness by 20% or so). I can\'t figure out how to do this given just a colo
If you want more simple and not accurately, below might help you.
public static int returnDarkerColor(int color){
float ratio = 1.0f - 0.2f;
int a = (color >> 24) & 0xFF;
int r = (int) (((color >> 16) & 0xFF) * ratio);
int g = (int) (((color >> 8) & 0xFF) * ratio);
int b = (int) ((color & 0xFF) * ratio);
return (a << 24) | (r << 16) | (g << 8) | b;
}