Created
August 19, 2012 23:55
-
-
Save ariaz/3398678 to your computer and use it in GitHub Desktop.
just another inlet to tributary
This file contains 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 margin = 50, | |
width = 600, | |
height = 600; | |
var n = 9; | |
var colors = ["#2C8121", "#494949"]; | |
cs = d3.interpolateHsl("#000000", "#FFFFFF"); | |
svg = d3.select('svg'); | |
svg | |
.attr('width', width) | |
.attr('height',height); | |
data = 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)}; | |
data.push(point); | |
} | |
} | |
function zCord(x,y){ | |
return Math.sqrt(1-Math.pow(x,2)-Math.pow(y,2)); | |
} | |
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]); | |
svg | |
.selectAll('rect') | |
.data(data) | |
.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()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment