Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created July 22, 2012 22:09
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/3161169 to your computer and use it in GitHub Desktop.
Save roundrobin/3161169 to your computer and use it in GitHub Desktop.
just another inlet to tributary
var pathWay = [];
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','')
g.on('click',function(){
console.log('dfgsd')
pathWay.push(d3.mouse(this))
redraw()
})
function redraw(){
var curve = '';
for(i in pathWay){
var e = pathWay[i];
var x = e[0];
var y = e[1];
if(curve == ''){
curve = 'M'+x+','+y;
}else{
curve += 'L'+x+','+y+' '
}
}
path.attr('d',curve)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment