Created
August 4, 2012 07:20
-
-
Save roundrobin/3255363 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
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 data = d3.range(0,232); | |
var enterSelection = g.append('g') | |
.attr('class','groupi') | |
var gg = enterSelection.selectAll('.elemets') | |
.data(data) | |
.enter() | |
var rect = gg.append('rect') | |
.attr("width",function(d,i){ | |
return d; | |
}) | |
.attr("height",function(d,i){ | |
return d; | |
}) | |
.attr("x",function(d,i){ | |
return Math.sin(d)*1994.32 % 500; | |
}) | |
.attr("y", function(d,i){ | |
return Math.sin(d)*(211); | |
}) | |
.attr("fill","#1A252C") | |
.attr("stroke","#000000") | |
.attr("stroke-width",5); | |
g.rect = rect; | |
}; | |
var toogle = 1; | |
tributary.run = function(g,t) { | |
var delta = Math.floor(t * 100); | |
if(delta % 100 == 0 ){ | |
g.rect | |
.transition() | |
.ease('elastic(22,2)') | |
.duration(2000) | |
.attr('stroke-width',function(){ | |
return randomXToY(0,72); | |
}) | |
.attr('opacity',function(){ | |
return randomXToY(0,0.5); | |
}) | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment