Skip to content

Instantly share code, notes, and snippets.

@agdelax
Last active Sep 7, 2015
Embed
What would you like to do?
Dots Generator
<!DOCTYPE HTML>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).on("mousemove", function(event){
var width = (event.pageX)/10;
var colors = ["rgba(255,0,0,0.6)", "rgba(0,0,255,0.6)", "rgba(255,255,0,0.6)"];
var rand = Math.round(Math.random()*colors.length);
var div = document.createElement('div');
div.style.backgroundColor = colors[rand];
div.style.height = width + 1 + "px";
div.style.width = width + 1 + "px";
div.style.top = Math.random() * 100 + "%";
div.style.left = Math.random() * 100 + "%";
div.style.position = "absolute";
div.style.borderRadius = "100%";
document.getElementsByTagName('body')[0].appendChild(div);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment