- Question: With text overlapping a picture of a person with a black-and-white-striped shirt. No matter what fixed "color value" you choose or what system you express it in (RGBA, APCA, etc.), you're going to have some of your letterforms appear in an area of insufficient contrast. (e.g. if you choose a dark color, your letters won't be readable on top of the black shirt stripe and visa versa for a light color).
Funny you should mention this. One of the experiments that we use in the lab for determining the middle point of perceptual contrast, specifically involves putting text against stripes of black and white.
The spatial frequency, in other words the size of the stripes relative to the font, is substantially important. As is the overall size and weight of the font. If I understand what you are asking for — maximum contrast at any given point, the results may not be what you expect. Here are examples.
Alternating the text color is actually a non-starter. The guidance APCA states is to not put text over such a busy background!!
But what is it like if we pick a middle contrast? Against black and white on an sRGB monitor the middle is about #a6a6a6 or so. It looks like this:
In this second example, if you allow your eye to rest on either a white or a black stripe for a moment you'll notice that the contrast is essentially equal for either the white or the black area. But when trying to view the entire image at once, we are unable to see past the very high contrast white and black stripes. Everything in perception is very context sensitive.
Even with a very large font, we have difficulty... What is needed is some help, like an outline or a shadow. Here a simple drop shadow helps make the text pop a bit more... We can even make the text white in this case, the shadow holding the background steady enough that we can see past the stripes. Even a saturated color can not by itself negate the busy background. Shawdows are still needed. White shadows can work with a darker text color as in here.What I hoped to illustrate is that some automated contrast check over something like this is not a solution at all. It is bad practice to put any text over such an image, unless you add sufficient backing to keep a visual separation between the text and the busy background.
A major issue is each browser renders the shadow differently, creating content consistency issues. And some modes shut off shadow so it is not a reliable source of contrast, more of an add-on only. Realistically, nothing really helps this use-case except lowering the background contrast so that it does not compete, and kind of more my point.
Best practices and guidelines are: reduce image contrast when it is to be used as a background for text.... massively reduce it in this case.