src/util/freehand/FreehandLineFinder.js
/**
   * Finds the nearest handle to the mouse cursor for a specific tool.
   * @private
   * @method
   *
   * @param {number} toolIndex The index of the particular freehand tool.
   * @returns {Object} An object containing information about the closest handle.
   */
Finds the nearest handle to the mouse cursor for a specific tool.
@private
@method

@param {number} toolIndex The index of the particular freehand tool.
@returns {Object} An object containing information about the closest handle.
Finds the nearest handle to the mouse cursor for a specific tool . @private @method @param { number } toolIndex The index of the particular freehand tool . @returns { Object } An object containing information about the closest handle .
_nearestHandleToPoint(toolIndex) {
    const eventData = this._eventData;
    const toolData = this._toolData;
    const data = toolData.data[toolIndex];
    const points = data.handles.points;
    if (points === undefined) {
      return null;
    }
    if (data.visible === false) {
      return null;
    }
    const closest = {
      toolIndex,
      handleIndex: null,
      distance: Infinity, 
    };
    for (let i = 0; i < points.length; i++) {
      const handleCanvas = external.cornerstone.pixelToCanvas(
        eventData.element,
        points[i]
      );
      const handleDistanceFromMousePoint = external.cornerstoneMath.point.distance(
        handleCanvas,
        this._mousePoint
      );
      if (handleDistanceFromMousePoint < closest.distance) {
        closest.handleIndex = i;
        closest.distance = handleDistanceFromMousePoint;
      }
    }
    return closest;
  }
_nearestHandleToPoint ( toolIndex ) { const eventData = this . _eventData ; const toolData = this . _toolData ; const data = toolData . data [ toolIndex ] ; const points = data . handles . points ; if ( points === undefined ) { return null ; } if ( data . visible === false ) { return null ; } const closest = { toolIndex , handleIndex : null , distance : Infinity , } ; for ( let i = 0 ; i < points . length ; i ++ ) { const handleCanvas = external . cornerstone . pixelToCanvas ( eventData . element , points [ i ] ) ; const handleDistanceFromMousePoint = external . cornerstoneMath . point . distance ( handleCanvas , this . _mousePoint ) ; if ( handleDistanceFromMousePoint < closest . distance ) { closest . handleIndex = i ; closest . distance = handleDistanceFromMousePoint ; } } return closest ; }
Finds the nearest handle to the mouse cursor for a specific tool.
Finds the nearest handle to the mouse cursor for a specific tool .
// Some large number