1
Guys, I have this code where it generates me a kind of theme https://jsfiddle.net/jpcaja7t/18/ and I would like to apply this other code on it so that the text is in contrast to bg, how can I do that because my bg and the text color are randomized?
But I would like the code to give me several core contrast and not just one.
Code to contrast text
var rgb = $('#content').css('backgroundColor');
var colors = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
var brightness = 1;
var r = colors[1];
var g = colors[2];
var b = colors[3];
var ir = Math.floor((255-r)*brightness);
var ig = Math.floor((255-g)*brightness);
var ib = Math.floor((255-b)*brightness);
$('#content').css('color', 'rgb('+ir+','+ig+','+ib+')');
So what I want is for the font color to change according to the background contrast, the bg of what I passed it works normal, just do not want a red bg to fall a pink font for example.
– Victor Saul
i based it on that code where the text is in contrast to bg http://jsfiddle.net/2VTnZ/2/
– Victor Saul
I don’t understand the update the answer, and how do I get to implement the code that passed me in my random theme? pq that is the big problem, in all models they work however in what I did that generates random theme does not work
– Victor Saul
In the color section where the second color is generated you compare the tolerance
if (isNeighborColor(rgb, nrgb, 165))
and the tolerance is less than165
you generate againnrgb = GenerateRGB(rgb, 1.2);
this is the rule you need to implement in your color generator @Victorsaul– KaduAmaral
and with that code like I do for him to read the colors I put on and not just black and white?
– Victor Saul