Skip to content

Instantly share code, notes, and snippets.

@theMagicalKarp
Created September 16, 2013 00:24
Show Gist options
  • Save theMagicalKarp/6575504 to your computer and use it in GitHub Desktop.
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.
<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