Built with blockbuilder.org
forked from anonymous's block: random circles
Built with blockbuilder.org
forked from anonymous's block: random circles
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
svg { width:100%; height: 100% } | |
</style> | |
</head> | |
<body> | |
<svg width="720" height="120"> | |
<circle></circle> | |
<circle></circle> | |
<circle></circle> | |
<circle></circle> | |
<circle></circle> | |
</svg> | |
<script> | |
var circle = d3.selectAll("circle"); | |
circle.data([32, 57, 112]); | |
circle.style("fill", "steelblue"); | |
circle.attr("r", function() { return Math.random() * 50; }); | |
function moveCircles(){ | |
circle.transition().attr("r", function() { return Math.random() * 5; }); | |
circle.transition().attr("cx", function() { return Math.random() * 720; }); | |
circle.transition().attr("cy", function() { return Math.random() * 720; }); | |
setTimeout(moveCircles, 500); | |
} | |
moveCircles(); | |
</script> | |
</body> |