Skip to content

Instantly share code, notes, and snippets.

@toroidal-code
Created January 14, 2014 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toroidal-code/8422795 to your computer and use it in GitHub Desktop.
Save toroidal-code/8422795 to your computer and use it in GitHub Desktop.
function rand(min, max) {
return parseInt(Math.random() * (max-min+1), 10) + min;
}
function get_random_color() {
var h = rand(1, 360); // color hue between 1 and 360
var s = 58; // saturation 30-100%
var l = 32; // lightness 30-70%
return 'hsl(' + h + ',' + s + '%,' + l + '%)';
}
function changeBackground() {
document.body.style.background = get_random_color();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment