I'm trying to create a simple color chooser GUI with a box on the right that displays the chosen color. However, I've noticed that black might not be the best color as it would be invisible with a black background.
So I decided to try inverting the color and displaying it and it works a bit better but is still sometimes not as readable as I'd like.
Is there a convention for choosing a color for text above a color, or does this happen to already be the accepted method of doing so?
TIA
Examples of my old method (first is more readable) :
Edit: This question may be similar to the suggested duplicate, but the answers most definitely are not (and they don't answer my question). One answer to the other question suggests merely to use a lighter/darker shade depending on the color (and then goes on to say that presets may be more reasonable), and the other gives an answer that depends on the asker's original color ("looks like your BG color is about #aa0000"). The two answers on this question, however, do fix my original problem - how to determine a color dynamically based on the background.