Comment by akkartik
Recently I made a little hypertext browser in 500 lines. Then I added this sort of automatic contrasting color selector in another 200 lines. In the process I learned a lot about color spaces.
https://akkartik.name/post/2025-04-04-devlog
One difference in my approach is: it's an authoring-time tool. If no sufficiently contrasting color exists you get an error. And so you have to change the background until there is one.