Skip to content

Instantly share code, notes, and snippets.

@slopjong
Created March 27, 2017 14:19
Show Gist options
  • Save slopjong/67524b901cd83243dac6f485158a0575 to your computer and use it in GitHub Desktop.
Save slopjong/67524b901cd83243dac6f485158a0575 to your computer and use it in GitHub Desktop.
<html style="background: #184b34">
<script>
window.color = {
red: 0,
green: 0,
blue: 0
};
window.color2 = [0, 0, 0];
window.steps = 0;
window.dir = [true, true, true];
var change = function(){
var rand = Math.floor(Math.random() * 3);
if (window.color2[rand] < 0 || window.color2[rand] > 255) {
window.dir[rand] = ! window.dir[rand];
}
if (window.dir[rand]) {
window.color2[rand]++;
} else {
window.color2[rand]--;
}
var color = "rgb("+ window.color2[0] +", "+ window.color2[1] +", "+ window.color2[2] +")";
document.getElementsByTagName('html')[0].style.background = color;
setTimeout(change, 1);
};
setTimeout(change, 1);
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment