Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created August 20, 2012 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save roundrobin/3398922 to your computer and use it in GitHub Desktop.
Save roundrobin/3398922 to your computer and use it in GitHub Desktop.
just another inlet to tributary

No parent Inlet

{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":619,"height":519,"hide":false}}
var cx = 430;
var cy = 263;
var circle = g.append("circle")
.attr("r",7)
.attr("cx",cx)
.attr("cy",cy)
.attr("fill","#FF00FF");
var circle = g.append("circle")
.attr("id",'arc2Circ')
.attr("r",7)
.attr("cx",209)
.attr("cy",263)
.attr("fill","#FF00FF");
//change r for different radius
var r = 152;
//change theta to see text rotate
var thetas = [92,100];
//turn theta into radians
var degrees = Math.PI/180;
d3.select("#arc2Circ")
.transition()
.duration(1500)
.attrTween("transform", function(d) {
//we interpolate between our start and end angle
//by creating an interpolation function
var theta = d3.interpolateNumber(thetas[0], thetas[1]);
return function(t) {
var x = cx + r * Math.cos(theta(t) * degrees);
var y = cy + r * Math.sin(theta(t) * degrees);
//function(t) is called for every step of the transition
//giving us a value of theta inbetween our start and end angle
//at each time step
return "translate(" + [x,y] + ")";
}
})
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment