import { DiagramMakerPlugin , DiagramMakerWorkspace , Position , Size } from 'diagram-maker' ; export function subtract ( a , b ) { return { x : a . x - b . x , y : a . y - b . y } ; } export function getScale ( workspace , minimap ) { 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 ) { scale = workspaceWidth / containerWidth ; } else { scale = workspaceHeight / containerHeight ; } return scale ; } export function getRectOffset ( workspace , scale ) { const workspacePosition = workspace . position ; const workspaceScale = workspace . scale ; const rectPosition = { x : - workspacePosition . x / ( scale * workspaceScale ) , y : - workspacePosition . y / ( scale * workspaceScale ) } ; return rectPosition ; } export function getRectSize ( workspace , scale ) { const workspaceScale = workspace . scale ; const viewContainerSize = workspace . viewContainerSize ; const { width : viewWidth , height : viewHeight } = viewContainerSize ; const rectSize = { height : viewHeight / ( scale * workspaceScale ) - 2 , width : viewWidth / ( scale * workspaceScale ) - 2 } ; return rectSize ; }