I am trying to find the correct color. For example if I have a dark green color then I need a light green color or if I have a light green color then I need a dark green color. I have a code which tells me if the color is dark or light.
function calcBrightness(red,green,blue) {
return Math.sqrt(
red * red * .299 +
green * green * .587 +
blue * blue * .114);
}
var brightness = calcBrightness(red, green, blue);
var foreColor = (brightness < 130) ? "light" : "green";
I am able to detect if the color is dark or light but how can I get the dark color if the result is light or light color if the foreColor
value is green?