-
-
Save smlombardi/d357310da45ba4161fa7 to your computer and use it in GitHub Desktop.
HSL clock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* HSL clock | |
*/ | |
height: 100%; | |
font: bold 5em/1 Helvetica Neue, sans-serif; | |
display: flex; | |
text-align: center; | |
align-items: center; | |
justify-content: center; | |
margin-top: -.1em; | |
transition: .1s background; | |
color: white; | |
text-shadow: 0 0 1px black, 0 0 2px black, 0 0 2px black, 1px 1px black; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- content to be placed inside <body>…</body> --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setInterval(function(){ | |
var d = new Date(); | |
var h = d.getHours(); | |
var m = d.getMinutes(); | |
var s = d.getSeconds(); | |
document.body.textContent = [h, m, s].map(function(a){ return a < 10? '0' + a : a}).join(':'); | |
// TODO: Shift lightness so that the color is dark at night and light in the day | |
document.body.style.background = 'hsl(' + ~~(s*6) + ', ' + ~~(m*10/6) + '%, ' + ~~(h*25/6) + '%)'; | |
}, 1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"javascript"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment