_calcRectDimensionFromPoint(x, y, presetRatio = null) {
    const canvas = this.getCanvas();
    const canvasWidth = canvas.getWidth();
    const canvasHeight = canvas.getHeight();
    const startX = this._startX;
    const startY = this._startY;
    let left = clamp(x, 0, startX);
    let top = clamp(y, 0, startY);
    let width = clamp(x, startX, canvasWidth) - left; // (startX <= x(mouse) <= canvasWidth) - left
    let height = clamp(y, startY, canvasHeight) - top; // (startY <= y(mouse) <= canvasHeight) - top

    if (this._withShiftKey && !presetRatio) {
      // make fixed ratio cropzone
      if (width > height) {
        height = width;
      } else if (height > width) {
        width = height;
      }

      if (startX >= x) {
        left = startX - width;
      }

      if (startY >= y) {
        top = startY - height;
      }
    } else if (presetRatio) {
      // Restrict cropzone to given presetRatio
      height = width / presetRatio;

      // If moving in a direction where the top left corner moves (ie. top-left, bottom-left, top-right)
      // the left and/or top values has to be changed based on the new height/width
      if (startX >= x) {
        left = clamp(startX - width, 0, canvasWidth);
      }

      if (startY >= y) {
        top = clamp(startY - height, 0, canvasHeight);
      }

      // Check if the new height is too large
      if (top + height > canvasHeight) {
        height = canvasHeight - top; // Set height to max available height
        width = height * presetRatio; // Restrict cropzone to given presetRatio based on the new height

        // If moving in a direction where the top left corner moves (ie. top-left, bottom-left, top-right)
        // the left and/or top values has to be changed based on the new height/width
        if (startX >= x) {
          left = clamp(startX - width, 0, canvasWidth);
        }

        if (startY >= y) {
          top = clamp(startY - height, 0, canvasHeight);
        }
      }
    }

    return {
      left,
      top,
      width,
      height,
    };
  }
Get rect dimension setting from Canvas-Mouse-Position(x, y)
@param {number} x - Canvas-Mouse-Position x
@param {number} y - Canvas-Mouse-Position Y
@param {number|null} presetRatio - fixed aspect ratio (width/height) of the cropzone (null if not set)
@returns {{left: number, top: number, width: number, height: number}}
@private