Given a background color, how to get a foreground color that makes it readable on that background color?
I mean computing that foreground color automatically in a program.
Or simplify the problem, if the foreground color is chosen from white/black, how to do the choice in a program?
You could compute the inverse colour, but you run the risk of contrast diminishing "in the middle" of the colour space.