I am trying to generate 2 random colors for chart reports by calling this function twice:
function randomNumberGenerator() {
let color_x = Math.floor(Math.random() * 256);
let color_y = Math.floor(Math.random() * 256);
let color_z = Math.floor(Math.random() * 256);
return `rgba(${color_x}, ${color_y}, ${color_z}, 0.6)`;
}
Everything works fine but the problem is:
Sometimes this function generate 2 random numbers close in the color itself for example grey and light grey.
What I am trying to do is getting two random colors totally not close to each other for example: blue and red or dark-orange and green.
Some possible alternative solutions: