function rand(min, max) {
return parseInt(Math.random() * (max-min+1), 10) + min;
}
// generate random colour from 1 hue range (blues)
function randomHslColor() {
var h = rand(240, 225);
var s = rand(25,50);
var l = rand(20, 90);
return 'hsl(' + h + ',' + s + '%,' + l + '%)';
}
// generate random colour from 2 different hues
function randomHslColorHues(index) {
var h, s, l;
// desaturated, darker blues
$hueFirst = rand(240, 225); // blues
$satFirst = rand(25,50); // blues
$lightFirst = rand(35,65); // blues
// saturated, lighter oranges
$hueSecond = rand(50,40); // oranges/yellows
$satSecond = rand(85,99); // oranges/yellows
$lightSecond = rand(65,80); // oranges/yellows
$randPick = Math.floor(Math.random() * Math.floor(4));
// pick a hue between range of blue and oranges
// if ( $randPick === 1 ) { // use yellows less often
if (index % 2) {
h = $hueSecond;
s = $satSecond;
l = $lightSecond;
} else { // use blue more
h = $hueFirst;
s = $satFirst;
l = $lightFirst;
}
return 'hsl(' + h + ',' + s + '%,' + l + '%)';
}