Skip to content

Instantly share code, notes, and snippets.

@ariaz
Created August 20, 2012 00:58
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 ariaz/3398948 to your computer and use it in GitHub Desktop.
Save ariaz/3398948 to your computer and use it in GitHub Desktop.
just another inlet to tributary
var margin = 50,
width = 600,
height = 600;
var colors = ["#2C8121", "#494949"];
cs = d3.interpolateHsl("#000000", "#FFFFFF");
svg = d3.select('svg');
svg
.attr('width', width)
.attr('height',height);
tributary.init = function(g) {
};
tributary.run = function(g,t) {
n =3;
d3.selectAll('rect').remove();
var dat = new Array();
for (var i = 0; i < n; i++){
for(var j = 0; j < n; j++){
var point = {x:(i+1)/(n+1), y:(j+1)/(n+1)};
dat.push(point);
}
}
g
.selectAll('rect')
.data(dat)
.enter()
.append('svg:rect')
.attr('rx',function(d){return 4})
.attr('ry',function(d){return 4})
.attr('x', function(d){return x_scale(d.x)})
.attr('y', function(d){return y_scale(d.y)})
.attr('width', 200/n)
.attr('height',200/n)
.style("fill", function(d,i) {
return cs(Math.random());
});
tributary.clear();
};
corners = 2;
x_scale = d3.scale.linear()
.range([margin,width-margin])
.domain([0,1]);
y_scale = d3.scale.linear()
.range([height-margin,margin])
.domain([0,1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment