Skip to content

Instantly share code, notes, and snippets.

@antulik
Created February 2, 2013 05:03
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 antulik/4696173 to your computer and use it in GitHub Desktop.
Save antulik/4696173 to your computer and use it in GitHub Desktop.
d3.timer
{"description":"d3.timer","endpoint":"","display":"svg","public":true,"require":[{"name":"d3","url":"http://d3js.org/d3.v2.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"index.html":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"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}
var i = 0,
svg = d3.select("svg");
svg.append("circle");
var circle = svg.select("circle");
circle.attr("fill", "#777777")
.attr("cx", function(){ return $(window).width() / 2 })
.attr("cy", function(){ return $(window).height() / 2 })
d3.timer(function() {
i++;
var a = 1 + Math.sin(i / 30);
var x = a * 124;
var c = d3.rgb(x,x,x)
circle.attr("r", function() { return a * 40; })
.attr("fill", function() { return c; });
});
body {
background-color: #555;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment