How to programmatically calculate the contrast ratio between two colors?

lLloydRiosa

New Member
Pretty straight-forward, take yellow and white:\[code\]back_color = {r:255,g:255,b:255}; //whitetext_color = {r:255,g:255,b:0}; //yellow\[/code\]What law of physics on God's Earth of universal constants, makes the fact that yellow text can't be read on white backgrounds but blue text can?For the sake of my customizable widget I tried all possible color models that I found conversions functions for; neither can say that green can be on white and yellow can't, based on just numerical comparisons.I looked at Adsense (which is created by the Budda of all Internet) and guess what they did, they made presets and color cells distance calculations. I can't to do that. My users have the right to pick even the most retina-inflammatory, unaesthetic combinations, as long as the text can still be read.
 
Back
Top