Skip to content

Instantly share code, notes, and snippets.

@briansw
Last active August 29, 2015 14:20
Show Gist options
  • Save briansw/6e5fbb9b5d07bd204d9d to your computer and use it in GitHub Desktop.
Save briansw/6e5fbb9b5d07bd204d9d to your computer and use it in GitHub Desktop.
<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>
@zakklauck
Copy link

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