A good user interface design provides user interface elements that contrast sufficiently with their surroundings. While color contrasting is relatively simple to do when there is one surrounding color, when choosing foreground colors between two background colors, the foreground must simultaneously contrast with both background colors. Given two background colors and an initial foreground color, this disclosure describes techniques to automatically select a foreground color that contrasts with both background colors and is similar in hue to the initial foreground color. The choice of colors can be constrained to a palette of valid colors grouped by similar hue. Given a range of potential relative luminances and two points within that range, the most contrasting luminance to both points is determined to be an endpoint of the range or the midpoint between the two luminances.
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 License.
Kasting, Peter and Boström, Peter, "Identifying a Color with Sufficient Contrast Against Two Distinct Background Colors", Technical Disclosure Commons, (June 14, 2022)