[ Launch: Tributary inlet ] 6046251 by pere
[ Launch: Tributary inlet ] 6046250 by pere
-
-
Save pere/6046251 to your computer and use it in GitHub Desktop.
Tributary inlet
This file contains hidden or 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
{"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01} |
This file contains hidden or 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 type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
var mouse = [480, 250], | |
count = 0; | |
var svg = d3.select("body").append("svg:svg") | |
.attr("width", 960) | |
.attr("height", 500); | |
var g = svg.selectAll("g") | |
.data(d3.range(25)) | |
.enter().append("svg:g") | |
.attr("transform", "translate(" + mouse + ")"); | |
g.append("svg:rect") | |
.attr("rx", 6) | |
.attr("ry", 6) | |
.attr("x", -12.5) | |
.attr("y", -12.5) | |
.attr("width", 25) | |
.attr("height", 25) | |
.attr("transform", function(d, i) { return "scale(" + (1 - d / 25) * 20 + ")"; }) | |
.style("fill", d3.scale.category20c()); | |
g.map(function(d) { | |
return {center: [0, 0], angle: 0}; | |
}); | |
svg.on("mousemove", function() { | |
mouse = d3.mouse(this); | |
}); | |
d3.timer(function() { | |
count++; | |
g.attr("transform", function(d, i) { | |
d.center[0] += (mouse[0] - d.center[0]) / (i + 5); | |
d.center[1] += (mouse[1] - d.center[1]) / (i + 5); | |
d.angle += Math.sin((count + i) / 10) * 7; | |
return "translate(" + d.center + ")rotate(" + d.angle + ")"; | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment