assets/scripts/jsplumb/2.0/jsplumb.js
function(point, curve) {
		var candidates = [],
			w = _convertToBezier(point, curve),
			degree = curve.length - 1, higherDegree = (2 * degree) - 1,
			numSolutions = _findRoots(w, higherDegree, candidates, 0),
			v = Vectors.subtract(point, curve[0]), dist = Vectors.square(v), t = 0.0;

		for (var i = 0; i < numSolutions; i++) {
			v = Vectors.subtract(point, _bezier(curve, degree, candidates[i], null, null));
			var newDist = Vectors.square(v);
			if (newDist < dist) {
				dist = newDist;
				t = candidates[i];
			}
		}
		v = Vectors.subtract(point, curve[degree]);
		newDist = Vectors.square(v);
		if (newDist < dist) {
			dist = newDist;
			t = 1.0;
		}
		return {location:t, distance:dist};
	}
function(point, curve) {
		var candidates = [],
			w = _convertToBezier(point, curve),
			degree = curve.length - 1, higherDegree = (2 * degree) - 1,
			numSolutions = _findRoots(w, higherDegree, candidates, 0),
			v = Vectors.subtract(point, curve[0]), dist = Vectors.square(v), t = 0.0;

		for (var i = 0; i < numSolutions; i++) {
			v = Vectors.subtract(point, _bezier(curve, degree, candidates[i], null, null));
			var newDist = Vectors.square(v);
			if (newDist < dist) {
				dist = newDist;
				t = candidates[i];
			}
		}
		v = Vectors.subtract(point, curve[degree]);
		newDist = Vectors.square(v);
		if (newDist < dist) {
			dist = newDist;
			t = 1.0;
		}
		return {location:t, distance:dist};
	}
function ( point , curve ) { var candidates = [ ] , w = _convertToBezier ( point , curve ) , degree = curve . length - 1 , higherDegree = ( 2 * degree ) - 1 , numSolutions = _findRoots ( w , higherDegree , candidates , 0 ) , v = Vectors . subtract ( point , curve [ 0 ] ) , dist = Vectors . square ( v ) , t = 0.0 ; for ( var i = 0 ; i < numSolutions ; i ++ ) { v = Vectors . subtract ( point , _bezier ( curve , degree , candidates [ i ] , null , null ) ) ; var newDist = Vectors . square ( v ) ; if ( newDist < dist ) { dist = newDist ; t = candidates [ i ] ; } } v = Vectors . subtract ( point , curve [ degree ] ) ; newDist = Vectors . square ( v ) ; if ( newDist < dist ) { dist = newDist ; t = 1.0 ; } return { location : t , distance : dist } ; }
Calculates the distance that the point lies from the curve.

@param point a point in the form {x:567, y:3342}
@param curve a Bezier curve in the form [{x:..., y:...}, {x:..., y:...}, {x:..., y:...}, {x:..., y:...}].  note that this is currently
hardcoded to assume cubiz beziers, but would be better off supporting any degree.
@return a JS object literal containing location and distance, for example: {location:0.35, distance:10}.  Location is analogous to the location
argument you pass to the pointOnPath function: it is a ratio of distance travelled along the curve.  Distance is the distance in pixels from
the point to the curve.
Calculates the distance that the point lies from the curve .