No Previous Gist
-
-
Save ejfox/3792004 to your computer and use it in GitHub Desktop.
just another inlet to tributary
This file contains hidden or 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
{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":600,"height":300,"hide":false},"endpoint":"delta","public":true} |
This file contains hidden or 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 txt; | |
var n = 51; | |
var colors = ["#76E4F3", "#000000"]; | |
var size = 6.48; | |
var percent = 0.94464; | |
var corners = 3; | |
var data = _.map(d3.range(n), function(d,i) { | |
size *= percent; | |
return size; | |
}); | |
tributary.loop = "pingpong"; | |
tributary.init = function(g) { | |
g.append("rect") | |
.attr("width", "100%") | |
.attr("height", "100%"); | |
var squares = g.selectAll("g.square") | |
.data(data) | |
.enter().append("svg:g") | |
.classed("square", true) | |
.attr("transform", "translate(" + [0,0] + ")"); | |
squares.append("svg:rect") | |
.attr("rx", corners) | |
.attr("ry", corners) | |
.attr("x", -12.5) | |
.attr("y", -12.5) | |
.attr("width", 25) | |
.attr("height", 25) | |
.attr("transform", function(d, i) { return "scale(" + (d) * 20 + ")"; }) | |
.style("fill", function(d,i) { | |
return colors[i%2]; | |
}); | |
squares.map(function(d) { | |
return {center: [tributary.sw/2,tributary.sh/2], angle: 0}; | |
}); | |
}; | |
tributary.run = function(g,t) { | |
var squares = g.selectAll("g.square") | |
squares.attr("transform", function(d, i) { | |
d.angle = d3.interpolateNumber(0, -90*i)(t); | |
return "translate(" + d.center + ")rotate(" + d.angle + ")"; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment