Last active
September 7, 2015 23:07
-
-
Save albertodelax/6c9212fdf3208b579bc0 to your computer and use it in GitHub Desktop.
Dots Generator
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
gistup |
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
<!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