Last active
August 29, 2015 14:20
-
-
Save briansw/6e5fbb9b5d07bd204d9d 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> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | |
<style> | |
.circle { | |
position: absolute; | |
width: 100px; | |
height: 100px; | |
border-radius: 50px; | |
background: #f1f1f1; | |
} | |
.blue { background: #00f; } | |
.green { background: #0f0; } | |
</style> | |
</head> | |
<body> | |
<div class="content"> | |
</div> | |
<script> | |
var App = { | |
color : null | |
}; | |
var colors = ["green", "blue"]; | |
App.color = colors[Math.floor(Math.random()*colors.length)]; | |
function add_circle() { | |
var x = Math.floor(Math.random() * $(window).width()), | |
y = Math.floor(Math.random() * $(window).height()), | |
circle = "<div style='top: " + y + "px; left: " + x + "px;' class='circle " + App.color + "'></div>"; | |
$('.content').append(circle); | |
} | |
function change_color() { | |
var new_color = App.color; | |
while (App.color == new_color) { | |
App.color = colors[Math.floor(Math.random()*colors.length)]; | |
} | |
} | |
var colorize = setInterval(add_circle, 1000); | |
var change_color = setInterval(change_color, 5000); | |
</script> | |
</body> | |
</html> |
Can I edit this and show you what I'm doing?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AH!!!!