src/tools/FreehandRoiSculptorTool.js
/**
   * Limits the cursor radius so that it its maximum area is the same as the
   * ROI being sculpted.
   *
   * @private
   * @param  {Object}  eventData    Data object associated with the event.
   * @param  {Number}  radius       The distance from the mouse to the ROI.
   * @param  {Boolean} canvasCoords Whether the calculation should be performed
   *                                In canvas coordinates.
   * @returns {Number}              The limited radius.
   */
Limits the cursor radius so that it its maximum area is the same as the
ROI being sculpted.

@private
@param  {Object}  eventData    Data object associated with the event.
@param  {Number}  radius       The distance from the mouse to the ROI.
@param  {Boolean} canvasCoords Whether the calculation should be performed
In canvas coordinates.
@returns {Number}              The limited radius.
Limits the cursor radius so that it its maximum area is the same as the ROI being sculpted . @private @param { Object } eventData Data object associated with the event . @param { Number } radius The distance from the mouse to the ROI . @param { Boolean } canvasCoords Whether the calculation should be performed In canvas coordinates . @returns { Number } The limited radius .
_limitCursorRadius(eventData, radius, canvasCoords = false) {
    const element = eventData.element;
    const image = eventData.image;
    const config = this.configuration;
    const toolState = getToolState(element, this.referencedToolName);
    const data = toolState.data[config.currentTool];
    let areaModifier = 1.0;
    if (canvasCoords) {
      const topLeft = external.cornerstone.pixelToCanvas(element, {
        x: 0,
        y: 0,
      });
      const bottomRight = external.cornerstone.pixelToCanvas(element, {
        x: image.width,
        y: image.height,
      });
      const canvasArea =
        (bottomRight.x - topLeft.x) * (bottomRight.y - topLeft.y);
      areaModifier = canvasArea / (image.width * image.height);
    }
    const area = data.area * areaModifier;
    const maxRadius = Math.pow(area / Math.PI, 0.5);
    return Math.min(radius, maxRadius);
  }
_limitCursorRadius ( eventData , radius , canvasCoords = false ) { const element = eventData . element ; const image = eventData . image ; const config = this . configuration ; const toolState = getToolState ( element , this . referencedToolName ) ; const data = toolState . data [ config . currentTool ] ; let areaModifier = 1.0 ; if ( canvasCoords ) { const topLeft = external . cornerstone . pixelToCanvas ( element , { x : 0 , y : 0 , } ) ; const bottomRight = external . cornerstone . pixelToCanvas ( element , { x : image . width , y : image . height , } ) ; const canvasArea = ( bottomRight . x - topLeft . x ) * ( bottomRight . y - topLeft . y ) ; areaModifier = canvasArea / ( image . width * image . height ) ; } const area = data . area * areaModifier ; const maxRadius = Math . pow ( area / Math . PI , 0.5 ) ; return Math . min ( radius , maxRadius ) ; }
Limits the cursor radius so that it its maximum area is the same as the
 ROI being sculpted.
Limits the cursor radius so that it its maximum area is the same as the ROI being sculpted .