I am writing a program log window, messages of different colors are displayed depending on the type of message. Periodically there is such a combination of colors that the text is difficult to read. I want to dynamically change the color of the text depending on the background color so that it is not problematic to perceive the information.
There are two colors represented in RGB (Color). The first color is the text color, the second color is the background color. How can I programmatically understand that the text color will be difficult to distinguish on the background color? .. It seems to me that there is a fairly simple solution, but I can’t think of it ... compare in these colors so that 100% can say: "Yes, there will be no difficulty in reading the text."