Lines Matching refs:background
34 public static int compositeColors(int foreground, int background) {
35 int bgAlpha = Color.alpha(background);
40 Color.red(background), bgAlpha, a);
42 Color.green(background), bgAlpha, a);
44 Color.blue(background), bgAlpha, a);
77 * Returns the contrast ratio between {@code foreground} and {@code background}.
78 * {@code background} must be opaque.
83 public static double calculateContrast(int foreground, int background) {
84 if (Color.alpha(background) != 255) {
85 throw new IllegalArgumentException("background can not be translucent");
88 // If the foreground is translucent, composite the foreground over the background
89 foreground = compositeColors(foreground, background);
93 final double luminance2 = calculateLuminance(background) + 0.05;
102 * {@code background}.
105 * @param background the background color. Should be opaque.
109 public static int calculateMinimumAlpha(int foreground, int background,
111 if (Color.alpha(background) != 255) {
112 throw new IllegalArgumentException("background can not be translucent");
117 double testRatio = calculateContrast(testForeground, background);
133 testRatio = calculateContrast(testForeground, background);