Created
September 16, 2013 00:24
-
-
Save theMagicalKarp/6575504 to your computer and use it in GitHub Desktop.
Had the opportunity to play with colors in js/html and had a little too much fun.
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
<html> | |
<style> | |
div { | |
height:5px; | |
} | |
</style> | |
<body> | |
<script> | |
var htmlDivs = []; | |
var colors = []; | |
var n = 200; | |
for(var i = 0; i <n; i++) { | |
var color = 'hsla(' + Math.floor(((i+1)/n)*360) + ',90%,60%,1)'; | |
colors.push(color); | |
htmlDivs.push('<div style="background-color:' + color + ';"></div>'); | |
} | |
document.getElementsByTagName("body")[0].innerHTML = htmlDivs.join(""); | |
var divs = document.getElementsByTagName("div"); | |
setInterval(function(){ | |
colors.push(colors.shift()); | |
for (var i = 0, len = colors.length; i < len; i++) { | |
divs[i].style.backgroundColor = colors[i]; | |
} | |
}, 50); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment