Reputation: 325
I want to make a transition between a rect and a circle with d3.js.
my attempt is here: http://jsfiddle.net/8kxBW/1/
But for me that transition doesn't look smooth. Has anyone an idea how to improve the transition?
Is there a easy way to do that?
var circleDAttribute = "m4,15.75c0,-6.90608 5.59392,-12.5 12.5,-12.5c6.90608,0 12.5,5.59392 12.5,12.5c0,6.90608 -5.59392,12.5 -12.5,12.5c-6.90608,0 -12.5,-5.59392 -12.5,-12.5z";
var rectDAttribute = "m1.75,1.75l0,40l80.25,0l-0.25,-40l-80,0z";
d3.select("#pathTransition")
.append("svg").append("g")
.attr("transform","translate(60,60)")
.append("path")
.attr("d",rectDAttribute)
.transition()
.duration(3000)
.attr("fill","blue")
.transition()
.duration(8000)
.attr("d",circleDAttribute);
Upvotes: 2
Views: 417
Reputation: 109232
The superformula explorer allows you to transition between these shapes and many more.
Upvotes: 1