Created
September 15, 2014 18:46
-
-
Save realityking/ef11511ad8d266bf13a7 to your computer and use it in GitHub Desktop.
This file contains 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> | |
<head> | |
<style> | |
.something { | |
font: 700 300px sans-serif; | |
position: absolute; | |
} | |
</style> | |
<script> | |
function animate(element, color) { | |
var start = null; | |
function step(timestamp) { | |
if (start === null) { | |
start = timestamp; | |
} | |
progress = timestamp - start; | |
var steps = progress / 100; | |
var newColor = (color += steps) % 360; | |
var pretty = "hsl( "+newColor+", 100%, 60%)"; | |
element.style.color = pretty; | |
requestAnimationFrame(step); | |
} | |
requestAnimationFrame(step); | |
} | |
document.addEventListener("DOMContentLoaded", function () { | |
for (var i = 0; i < 200; i++) { | |
var something = document.createElement('something'); | |
something.innerText = 'YOLO'; | |
something.className = 'something'; | |
document.body.appendChild(something); | |
something.style.top = i; | |
something.style.left = i; | |
var color = 0 + parseInt(i*(360/200)); | |
animate(something, color); | |
} | |
}); | |
</script> | |
</head> | |
<body></bod> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment