export function getScale()

in src/service/MinimapUtils.ts [7:25]


export function getScale(workspace: DiagramMakerWorkspace, minimap: DiagramMakerPlugin): number {
  const { height: workspaceHeight, width: workspaceWidth } = workspace.canvasSize;
  const workspaceRatio = workspaceWidth / workspaceHeight;

  const containerSize = minimap.data.size;
  const { height: containerHeight, width: containerWidth } = containerSize;
  const containerRatio = containerWidth / containerHeight;

  let scale;

  if (workspaceRatio > containerRatio) {
        // Short and fat, fill empty space at the top and bottom
    scale = workspaceWidth / containerWidth;
  } else {
        // Tall and thin, fill empty space at the left and right
    scale = workspaceHeight / containerHeight;
  }
  return scale;
}