[ Launch: test ] 4cfa40801525d56f757f by georules
[ Launch: test ] 4653053 by enjalot
[ Launch: test ] 4652017 by enjalot
[ Launch: test ] 4582399 by enjalot
-
-
Save georules/4cfa40801525d56f757f to your computer and use it in GitHub Desktop.
test
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
{"description":"test","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"tab":"edit","display_percent":0.7,"thumbnail":"http://i.imgur.com/hRUYJyB.png","fullscreen":false,"ajax-caching":true,"inline-console":false} |
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 svg = d3.select("svg") | |
d3.select("body").style("background-color",d3.rgb(25,25,25)) | |
var colors = [ | |
'#fe2d85' | |
, '#4DA9DF' | |
, '#37ff00' | |
, '#fed075' | |
] | |
tall = 15 | |
times = 14 | |
var color = function(i) { | |
var num_interps = colors.length -1 | |
var ord = d3.scale.linear() | |
.domain([0, times]) | |
.range([0, num_interps]) | |
var section = parseInt(ord(i)) | |
//console.log("section", section) | |
var section_size = times / num_interps | |
//get the two colors we want to interpolate between | |
var col_range = [colors[section], colors[section+1]] | |
var col_scale = d3.scale.linear() | |
.domain([section * section_size, (section+1) * section_size]) | |
//.interpolate(d3.interpolateRgb) | |
.interpolate(d3.interpolateHsl) | |
.range(col_range) | |
return col_scale(i) | |
} | |
num = 14 | |
fibs = new Array() | |
for (i = num; i >= 0; i--) { | |
d = fib(i) | |
fibs[i] = d | |
for(j = 0; j < times; j++) { | |
drawthing(d/4, tall,i*2+d+10, j*tall*2,j) | |
drawthing(d/4, tall,(num-i)-d*1.275+788, tall+j*tall*2,j) | |
} | |
} | |
function fib(n) { | |
if (n < 2) { | |
return 1; | |
} else { | |
return fib(n - 2) + fib(n - 1); | |
} | |
} | |
function drawthing(w,h,x,y,i) { | |
c = color(i) | |
svg.append("rect") | |
.attr({ | |
width: w, | |
height: h, | |
x: x+20, | |
y: y, | |
fill: c | |
}) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment