[ Launch: Tributary inlet ] 6722715 by poezn
-
-
Save poezn/6722715 to your computer and use it in GitHub Desktop.
Hovering Planets
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
{"description":"Hovering Planets","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},"circles.svg":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":true,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/f7UO8XS.png","inline-console":true} |
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
/* | |
var hover = function() { | |
var numTicksPassed = (Date.now() - startTime)/1000; | |
g.selectAll("g") | |
.attr({ | |
"transform": function(d, i) { | |
var angle = numTicksPassed % 2 * Math.PI; | |
var tx = 50 + Math.sin(angle) * 99; | |
ty = 50 + Math.cos(angle) * 20; | |
return "translate(" + [tx, ty] + ")" | |
} | |
}); | |
} | |
d3.timer(hover); | |
*/ | |
tributary.init = function(g) { | |
var scale = d3.scale.sqrt() | |
.domain([0, 70]) | |
.range([20, 120]); | |
var master = g.append("g").attr({"id": "master"}); | |
var grps = master.selectAll("circle") | |
.data([10, 25, 70]) | |
.enter().append("circle").attr({ | |
"cx" : function(d, i) { | |
return (i+1) * 280 | |
}, | |
"cy" : function(d, i) { | |
return 300 | |
}, | |
"r": scale | |
}) | |
.style({ | |
"fill": "#614C4C" | |
}); | |
}; | |
tributary.run = function(g, t) { | |
var numTicksPassed = t; | |
var rad = t % (2 * Math.PI); | |
console.log(rad); | |
g.selectAll("circle") | |
.attr({ | |
"transform": function(d, i) { | |
var tx = 50 + Math.sin(rad) * 99; | |
ty = 50 + Math.cos(rad) * 20; | |
return "translate(" + [tx, ty] + ")" | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment