Skip to content

Instantly share code, notes, and snippets.

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