demo/curve.bspline.js
function repel( pt, i ) {
  if ( pt.distance(mouse) < threshold ) { // smaller than threshold distance, push it out
    var dir = pt.$subtract(mouse).normalize();
    pt.set( dir.multiply(threshold).add( mouse ).min( space.size ).max(0, 0) );
  } else { // bigger than threshold distance, pull it in
    var orig = origs[i];
    pt.set ( orig.$add( pt.$subtract(orig).multiply(0.98) ) );
  }
}
function repel( pt, i ) {
  if ( pt.distance(mouse) < threshold ) { // smaller than threshold distance, push it out
    var dir = pt.$subtract(mouse).normalize();
    pt.set( dir.multiply(threshold).add( mouse ).min( space.size ).max(0, 0) );
  } else { // bigger than threshold distance, pull it in
    var orig = origs[i];
    pt.set ( orig.$add( pt.$subtract(orig).multiply(0.98) ) );
  }
}
function repel ( pt , i ) { if ( pt . distance ( mouse ) < threshold ) { // smaller than threshold distance, push it out var dir = pt . $subtract ( mouse ) . normalize ( ) ; pt . set ( dir . multiply ( threshold ) . add ( mouse ) . min ( space . size ) . max ( 0 , 0 ) ) ; } else { // bigger than threshold distance, pull it in var orig = origs [ i ] ; pt . set ( orig . $add ( pt . $subtract ( orig ) . multiply ( 0.98 ) ) ) ; } }
Repel the control points when mouse is near i
Repel the control points when mouse is near i