Skip to content

Instantly share code, notes, and snippets.

@vitvad
Created October 7, 2014 11:16
Show Gist options
  • Save vitvad/e84b2929fef38927a4bb to your computer and use it in GitHub Desktop.
Save vitvad/e84b2929fef38927a4bb to your computer and use it in GitHub Desktop.
generate random color pair for paceholde.it
function getPair(num) {
var randColor = function(){
var rnd = Math.random();
var color = Math.floor(rnd * 16777215).toString(16);
var oposite = Math.floor(16777215 - rnd * 16777215).toString(16);
while (oposite.length < 6) {
oposite = '0' + oposite;
}
return color +'/'+ oposite;
}
var txt = '',
xx = 0;
while (xx < num) {
xx++;
txt += randColor() + '\n';
}
return txt;
}
getPair(10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment