Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Created February 1, 2015 16: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 AllThingsSmitty/0c8db6d08c38a3b60873 to your computer and use it in GitHub Desktop.
Save AllThingsSmitty/0c8db6d08c38a3b60873 to your computer and use it in GitHub Desktop.
Get HSL color value based on time value
setInterval(function () {
'use strict';
var d = new Date(),
h = d.getHours(),
m = d.getMinutes(),
s = d.getSeconds();
document.body.textContent = [h, m, s].map(function (a) { return a < 10 ? '0' + a : a}).join(':');
document.body.style.background = 'hsl(' + ~~(s * 6) + ', ' + ~~(m * 10/6) + '%, ' + ~~(h * 25/6) + '%)';
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment