Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created July 22, 2012 19:15
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/3160760 to your computer and use it in GitHub Desktop.
Save roundrobin/3160760 to your computer and use it in GitHub Desktop.
just another inlet to tributary
var pathWay =[[183,246,'M',183,246],[323,203,'Q',323,203],[307,498,'Q',307,498],[236,564,'Q',236,564],[155,507,'Q',155,507],[127,399,'Q',127,399],[246,513,'Q',246,513],[277,342,'Q',277,342],[110,367,'Q',110,367],[207,276,'M',207,276],[164,341,'Q',164,341],[275,324,'Q',275,324],[291,252,'Q',291,252]];
var curve = '';
for(i in pathWay){
var p = pathWay[i]
curve += p[2]+p[0]+','+p[1]+' '+p[3]+','+p[4]+' ';
}
function randomXToY(minVal,maxVal,floatVal)
{
var randVal = minVal+(Math.random()*(maxVal-minVal));
return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}
curve += 'Z';
console.log(curve)
var path = g.append('path')
.attr('stroke','red')
.attr('stroke-width','2')
.attr('fill',"none")
.attr('id','path')
.attr('fill-opacity','0.5')
.attr('class','drawit')
.attr('transform','scale(1)')
.attr('id','pathWay')
.attr('d',curve)
var keying = function(){
console.log('hey')
var x = path.attr('d');
var newPoint = 'Q'+randomXToY(1,1000)+','+randomXToY(1,1000)+' '+randomXToY(1,1000)+','+randomXToY(1,1000)
path.attr('d',x+newPoint)
}
d3.select(window).on("keypress", keying);
d3.select(window).on("keyup", keying);
d3.select(window).on("keydown", keying);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment