Lines Matching full:ratio

27  * color and a contrast ratio.
29 * <p>Contrast ratio is calculated using XYZ's Y. When linearized to match human perception, Y
33 // The minimum contrast ratio of two colors.
34 // Contrast ratio equation = lighter + 5 / darker + 5, if lighter == darker, ratio == 1.
37 // The maximum contrast ratio of two colors.
38 // Contrast ratio equation = lighter + 5 / darker + 5. Lighter and darker scale from 0 to 100.
39 // If lighter == 100, darker = 0, ratio == 21.
45 // Given a color and a contrast ratio to reach, the luminance of a color that reaches that ratio
47 // contrast ratio of the input color and the returned luminance may not reach the contrast ratio
50 // When the desired contrast ratio and the result contrast ratio differ by more than this amount,
52 // it will return a valid luminance but that luminance may not meet the requested contrast ratio.
54 // 0.04 selected because it ensures the resulting ratio rounds to the same tenth.
73 // display color spaces, methods that take a contrast ratio and luminance, and return a luminance
74 // that reaches that contrast ratio for the input luminance, purposefully darken/lighten their
75 // result such that the desired contrast ratio will be reached even if inaccuracy is introduced.
79 // lightness rounds to the same as the requested, the desired contrast ratio will be reached.
85 * Contrast ratio is a measure of legibility, its used to compare the lightness of two colors.
91 * <p>The equation is ratio = lighter Y + 5 / darker Y + 5.
100 * Contrast ratio of two tones. T in HCT, L* in L*a*b*. Also known as luminance or perpectual
103 * <p>Contrast ratio is defined using Y in XYZ, relative luminance. However, relative luminance is
110 * of a ratio, a linear difference. This allows a designer to determine what they need to adjust a
119 * Returns T in HCT, L* in L*a*b* >= tone parameter that ensures ratio with input T/L*. Returns -1
120 * if ratio cannot be achieved.
123 * @param ratio Desired contrast ratio of return value and tone parameter.
125 public static double lighter(double tone, double ratio) { in lighter() argument
129 // Invert the contrast ratio equation to determine lighter Y given a ratio and darker Y. in lighter()
131 final double lightY = ratio * (darkY + 5.0) - 5.0; in lighter()
136 final double delta = Math.abs(realContrast - ratio); in lighter()
137 if (realContrast < ratio && delta > CONTRAST_RATIO_EPSILON) { in lighter()
150 * Tone >= tone parameter that ensures ratio. 100 if ratio cannot be achieved.
153 * bounds return value may not reach the desired ratio.
156 * @param ratio Desired contrast ratio of return value and tone parameter.
158 public static double lighterUnsafe(double tone, double ratio) { in lighterUnsafe() argument
159 double lighterSafe = lighter(tone, ratio); in lighterUnsafe()
164 * Returns T in HCT, L* in L*a*b* <= tone parameter that ensures ratio with input T/L*. Returns -1
165 * if ratio cannot be achieved.
168 * @param ratio Desired contrast ratio of return value and tone parameter.
170 public static double darker(double tone, double ratio) { in darker() argument
174 // Invert the contrast ratio equation to determine darker Y given a ratio and lighter Y. in darker()
176 final double darkY = ((lightY + 5.0) / ratio) - 5.0; in darker()
181 final double delta = Math.abs(realContrast - ratio); in darker()
182 if (realContrast < ratio && delta > CONTRAST_RATIO_EPSILON) { in darker()
186 // For information on 0.4 constant, see comment in lighter(tone, ratio). in darker()
196 * Tone <= tone parameter that ensures ratio. 0 if ratio cannot be achieved.
199 * bounds return value may not reach the desired ratio.
202 * @param ratio Desired contrast ratio of return value and tone parameter.
204 public static double darkerUnsafe(double tone, double ratio) { in darkerUnsafe() argument
205 double darkerSafe = darker(tone, ratio); in darkerUnsafe()