Skip to content

Instantly share code, notes, and snippets.

@hemulin
Created April 8, 2013 08:37
Show Gist options
  • Save hemulin/5335207 to your computer and use it in GitHub Desktop.
Save hemulin/5335207 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;
function randomXToY(minVal,maxVal,floatVal)
{
var randVal = minVal+(Math.random()*(maxVal-minVal));
return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}
tributary.init = function(g) {
var text = {"message":"Hello","amplitude":1.216,"segments":26.03,"change1":0,"functionName":"Sinus", "change2" : 16.3,"a":1,"b":1,"c":0};
var boolFlag = false;
var r = 576 / 2,
data = d3.range(430).map(function(i) {
var axis = 4;
var segments = Math.floor(361 / axis);
var part = Math.floor(i/segments);
var value = text.amplitude + Math.sin(i / text.segments * Math.PI) / text.change2;
var scale = d3.scale.linear().domain([0, -166]).range([0.79, 20]);
var check = Math.sin(i / -10);
var val = scale(check);
return val;
});
var svg = g
.data([data])
.append("g")
.attr("transform", "translate(" + r + "," + r + ")");
svg.append("path")
.attr("class", "area")
.attr("d", d3.svg.area.radial()
.innerRadius(94.6)
.outerRadius(function(d) { return r * d; })
.angle(function(d, i) { return i / 180 * Math.PI; }));
};
tributary.run = function(g,t) {
var delta = Math.floor(t * 100);
var r = 300;randomXToY(10,300);
var rect = g.rect;
if(delta % 77 == 0 ){
var text = {"message":"Hello","amplitude":1.216,"segments":44.91,"change1":0,"functionName":"Sinus", "change2" : 16.3,"a":1,"b":1,"c":0};
var data2 = d3.range(430).map(function(i) {
var axis = 4;
var segments = Math.floor(361 / axis);
var part = Math.floor(i/segments);
var value = text.amplitude + Math.sin(i / text.segments * Math.PI) / text.change2;
var scale = d3.scale.linear().domain([0, randomXToY(0,200)]).range([0.79, 20]);
var check = Math.sin(i / 20);
var val = scale(check);
return val;
});
var svg = g.data([data2])
g.select('path').transition()
.duration(2000)
.attr('fill','#'+Math.floor(Math.random()*16777215).toString(16))
.attr("d", d3.svg.area.radial()
.innerRadius(randomXToY(10,30))
.outerRadius(function(d) { return r * d; })
.angle(function(d, i) { return i / 129 * Math.PI; }));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment