Skip to content

Instantly share code, notes, and snippets.

@ejfox
Forked from anonymous/inlet.js
Created September 27, 2012 03:26
Show Gist options
  • Save ejfox/3792004 to your computer and use it in GitHub Desktop.
Save ejfox/3792004 to your computer and use it in GitHub Desktop.
just another inlet to tributary

No Previous Gist

{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":600,"height":300,"hide":false},"endpoint":"delta","public":true}
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 + ")";
});
};
Display the source blob
Display the rendered blob
Raw
Loading
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