Skip to content

Instantly share code, notes, and snippets.

@tanatana
Created November 6, 2013 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanatana/7328929 to your computer and use it in GitHub Desktop.
Save tanatana/7328929 to your computer and use it in GitHub Desktop.
circle-animation
{"description":"circle-animation","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"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}
var seed = new Array(32);
(function(){
var i;
for(i = 0; i < seed.length;i++){ seed[i] = new Array(32)}
})();
var svg = d3.select("svg")
var trigonometricScale = d3.scale.linear()
.domain([0, seed.length])
.range([-3.1415, 3.1415]);
var selection = svg.selectAll("circle").data(seed);
selection.enter().append("circle")
.attr("cx", function(d,i) { return Math.cos(trigonometricScale(i))*1 + 300 })
.attr("cy", function(d,i) { return Math.sin(trigonometricScale(i))*1 + 300 })
.attr("r", 1)
.style("fill", "#000")
setTimeout(function(){
selection
.transition()
.ease("cubic-in-out")
.duration(1000)
.attr("cx", function(d,i) { return Math.cos(trigonometricScale(i))*150 + 300 })
.attr("cy", function(d,i) { return Math.sin(trigonometricScale(i))*150 + 300 })
.attr("r", function(d,i){return 3})
.style("fill", "#000")
},10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment