add Color.fade(color, alpha)

This commit is contained in:
Hannes Janetzek 2013-09-28 20:59:44 +02:00
parent 32d17cca18
commit 01d98cbcb7

View File

@ -94,4 +94,13 @@ public class Color {
} }
throw new IllegalArgumentException("Unknown color"); throw new IllegalArgumentException("Unknown color");
} }
public static int fade(int color, double alpha) {
alpha *= ((color >>> 24) & 0xff);
return ((int) alpha) << 24
| ((int) alpha * ((color >>> 16) & 0xff)) << 16
| ((int) alpha * ((color >>> 8) & 0xff)) << 8
| ((int) alpha * ((color) & 0xff));
}
} }