Lines Matching refs:background
47 public static int compositeColors(@ColorInt int foreground, @ColorInt int background) {
48 int bgAlpha = Color.alpha(background);
53 Color.red(background), bgAlpha, a);
55 Color.green(background), bgAlpha, a);
57 Color.blue(background), bgAlpha, a);
84 * Returns the contrast ratio between {@code foreground} and {@code background}.
85 * {@code background} must be opaque.
90 public static double calculateContrast(@ColorInt int foreground, @ColorInt int background) {
91 if (Color.alpha(background) != 255) {
92 throw new IllegalArgumentException("background can not be translucent: #"
93 + Integer.toHexString(background));
96 // If the foreground is translucent, composite the foreground over the background
97 foreground = compositeColors(foreground, background);
101 final double luminance2 = calculateLuminance(background) + 0.05;
110 * {@code background}.
113 * @param background the opaque background color
117 public static int calculateMinimumAlpha(@ColorInt int foreground, @ColorInt int background,
119 if (Color.alpha(background) != 255) {
120 throw new IllegalArgumentException("background can not be translucent: #"
121 + Integer.toHexString(background));
126 double testRatio = calculateContrast(testForeground, background);
142 testRatio = calculateContrast(testForeground, background);