Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created August 4, 2012 23:25
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 roundrobin/3260562 to your computer and use it in GitHub Desktop.
Save roundrobin/3260562 to your computer and use it in GitHub Desktop.
just another inlet to tributary
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 defs = g.append('defs');
var gradient = defs.append('linearGradient')
.attr('id','g320')
.attr('gradientUnits','userSpaceOnUse')
.attr('x1','0%')
.attr('x2','0%')
.attr('y1','0%')
.attr('y2',141)
var stop1 = gradient.append('stop')
.attr('stop-color',"#68B4CF")
.attr('offset','0')
.attr('id','stop1');
var stop2 = gradient.append('stop')
.attr('stop-color',"#4DE3AC")
.attr('offset','1')
.attr('id','stop2');
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 circleBoundaries = d3.scale.linear().domain([0, 1489]).range([0.79, 20]);
var r = 576 / 2,
data = d3.range(361).map(function(i) {
var returnedValue = 1;
var val = circleBoundaries(returnedValue);
return val;
});
var svg = g
.data([data])
.append("g")
.attr("transform", "translate(" + r + "," + r + ")");
var path = svg.append("path")
.attr("class", "area")
.attr('fill',"url(#g320)")
.attr("d", d3.svg.area.radial()
.innerRadius(function(d,i) {
return i;
})
.outerRadius(function(d) {
return r * d;
})
.angle(function(d, i) { return i / 180 * Math.PI; }));
g.pathy = path;
g.stop1 = stop1;
g.stop2 = stop2;
};
var toogle = 1;
tributary.run = function(g,t) {
var delta = Math.floor(t * 100);
var rect = g.rect;
if(delta % 96 == 0 ){
}
if(delta % 100 == 0 ){
var r = 300;
var random = Math.sin(delta);
var radial = d3.svg.area.radial()
.innerRadius( function(d,i){
return i;
})
.outerRadius(function(d) {
return randomXToY(200,300);
})
.angle(function(d, i) {
return i / 180 * Math.PI;
});
g.stop2
.transition()
.ease('elastic(20, 2)')
.duration(1000)
.attr('stop-color','#'+Math.floor(Math.random()*16777215).toString(16))
g.stop1
.transition()
.ease('elastic(20, 2)')
.duration(1000)
.attr('stop-color','#'+Math.floor(Math.random()*16777215).toString(16))
g.pathy
.transition()
.ease('elastic(20, 2)')
.duration(1000)
.attr("d", radial)
.attr('fill',"url(#g320)")
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment