src/tools/FreehandRoiSculptorTool.js
/**
   * Finds the nearest handle to the mouse cursor for all freehand
   * data on the element.
   *
   * @private
   * @param {Object} element - The element.
   * @param {Object} eventData - Data object associated with the event.
   * @returns {Number} The tool index of the closest freehand tool.
   */
Finds the nearest handle to the mouse cursor for all freehand
data on the element.

@private
@param {Object} element - The element.
@param {Object} eventData - Data object associated with the event.
@returns {Number} The tool index of the closest freehand tool.
Finds the nearest handle to the mouse cursor for all freehand data on the element . @private @param { Object } element - The element . @param { Object } eventData - Data object associated with the event . @returns { Number } The tool index of the closest freehand tool .
_getClosestFreehandToolOnElement(element, eventData) {
    const freehand = getToolForElement(element, this.referencedToolName);
    const toolState = getToolState(element, this.referencedToolName);
    if (!toolState) {
      return;
    }
    const data = toolState.data;
    const pixelCoords = eventData.currentPoints.image;
    const closest = {
      distance: Infinity,
      toolIndex: null,
    };
    for (let i = 0; i < data.length; i++) {
      const distanceFromToolI = freehand.distanceFromPoint(
        element,
        data[i],
        pixelCoords
      );
      if (distanceFromToolI === -1) {
        continue;
      }
      if (distanceFromToolI < closest.distance) {
        closest.distance = distanceFromToolI;
        closest.toolIndex = i;
      }
    }
    return closest.toolIndex;
  }
_getClosestFreehandToolOnElement ( element , eventData ) { const freehand = getToolForElement ( element , this . referencedToolName ) ; const toolState = getToolState ( element , this . referencedToolName ) ; if ( ! toolState ) { return ; } const data = toolState . data ; const pixelCoords = eventData . currentPoints . image ; const closest = { distance : Infinity , toolIndex : null , } ; for ( let i = 0 ; i < data . length ; i ++ ) { const distanceFromToolI = freehand . distanceFromPoint ( element , data [ i ] , pixelCoords ) ; if ( distanceFromToolI === - 1 ) { continue ; } if ( distanceFromToolI < closest . distance ) { closest . distance = distanceFromToolI ; closest . toolIndex = i ; } } return closest . toolIndex ; }
Finds the nearest handle to the mouse cursor for all freehand
 data on the element.
Finds the nearest handle to the mouse cursor for all freehand data on the element .