src/util/freehand/FreehandLineFinder.js
/**
   * Returns true if the mouse point projects onto the line segment.
   * @private
   * @method
   *
   * @param {number} toolIndex The index of the particular freehand tool.
   * @param {Object} handleIndexArray An array of indicies corresponding to the line segment.
   * @returns {boolean} True if the mouse point projects onto the line segment
   */
Returns true if the mouse point projects onto the line segment.
@private
@method

@param {number} toolIndex The index of the particular freehand tool.
@param {Object} handleIndexArray An array of indicies corresponding to the line segment.
@returns {boolean} True if the mouse point projects onto the line segment
Returns true if the mouse point projects onto the line segment . @private @method @param { number } toolIndex The index of the particular freehand tool . @param { Object } handleIndexArray An array of indicies corresponding to the line segment . @returns { boolean } True if the mouse point projects onto the line segment
_pointProjectsToLineSegment(toolIndex, handleIndexArray) {
    const eventData = this._eventData;
    const toolData = this._toolData;
    const data = toolData.data[toolIndex];
    const points = data.handles.points;
    if (data.handles.points === undefined) {
      return;
    }
    if (data.visible === false) {
      return false;
    }
    const handle1 = points[handleIndexArray[0]];
    const handle2 = points[handleIndexArray[1]];
    const p = FreehandLineFinder.getCanvasPointsFromHandles(
      handle1,
      handle2,
      eventData.element
    );
    const r = FreehandLineFinder.getLineAsVector(p);
    const m = this._getLineOriginToMouseAsVector(p);
    const mProj = (m[0] * r[0] + m[1] * r[1]) / r.magnitude;
    if (mProj > 0 && mProj < r.magnitude) {
      return true;
    }
    return false;
  }
_pointProjectsToLineSegment ( toolIndex , handleIndexArray ) { const eventData = this . _eventData ; const toolData = this . _toolData ; const data = toolData . data [ toolIndex ] ; const points = data . handles . points ; if ( data . handles . points === undefined ) { return ; } if ( data . visible === false ) { return false ; } const handle1 = points [ handleIndexArray [ 0 ] ] ; const handle2 = points [ handleIndexArray [ 1 ] ] ; const p = FreehandLineFinder . getCanvasPointsFromHandles ( handle1 , handle2 , eventData . element ) ; const r = FreehandLineFinder . getLineAsVector ( p ) ; const m = this . _getLineOriginToMouseAsVector ( p ) ; const mProj = ( m [ 0 ] * r [ 0 ] + m [ 1 ] * r [ 1 ] ) / r . magnitude ; if ( mProj > 0 && mProj < r . magnitude ) { return true ; } return false ; }
Returns true if the mouse point projects onto the line segment.
Returns true if the mouse point projects onto the line segment .
// Project vector m onto r to see if the point is within bounds of line segment