Skip to content

Instantly share code, notes, and snippets.

@hemulin
Created April 8, 2013 08:38
Show Gist options
  • Save hemulin/5335212 to your computer and use it in GitHub Desktop.
Save hemulin/5335212 to your computer and use it in GitHub Desktop.
Tributary inlet
{"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":true,"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}
var txt;
tributary.init = function(g) {
function randomXToY(minVal,maxVal,floatVal)
{
var randVal = minVal+(Math.random()*(maxVal-minVal));
return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}
var scale = d3.scale.linear().domain([0, -96]).range([0.6636, 20]);
var data = d3.range(430).map(function(i) { return 1.2 * scale(i/(71) ) / 1; });
var svg = g
.data([data])
.append("g")
.attr("transform", "translate(" + 319 + "," + 274 + ")");
var path = svg.append("path")
.attr("class", "area")
.attr("d", d3.svg.area.radial()
.innerRadius(50)
.outerRadius(function(d) { return 227; })
.angle(function(d, i) { return (-0.4) * Math.sin(i)*(-8); }));
g.path = path;
}
tributary.run = function(g,t) {
g.path
.attr("class", "area")
.attr("d", d3.svg.area.radial()
.innerRadius(205)
.outerRadius(function(d) { return 227; })
.angle(function(d, i) { return Math.sin(t/3) * Math.cos(i)*(-8); }));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment