I am having to write my own mouse-over code for a particular control in a C++/VCL application. The question is, given ANY combination of foreground and background colors, how do you calculate a highlight color to indicate that the mouse is over that control?
I've found the articles on how to convert RGB to HSL and adjust the lightness (references: how to highlight a given color in c sharp and algorithm to switch between rgb and hsb color values), so I've got the math part. It's the determination of what to do when, say, the text color is already white. Or if the user is using black on white, lightening the black makes it grey on white, and very hard to read.
I was thinking I probably want to do something like take the background color, find its opposite on the color wheel (and I have no idea how to do that). If that color is too close (however you determine that) to the text color, make it lighter or darker.
Does anyone have an algorithm they are willing to share?
Thanks!
Edit: This question was marked as a duplicate of Determine font color based on background color. That solution chooses either black or white as a font color given a background color. I want to go one step further and choose a third color as a highlight when the mouse is over that text. Thanks!