structure AppWith = struct open AppType fun arrowX (app, arrowX) = let val { mode , arrowX = _ , arrowY , canvasWidth , canvasHeight , windowWidth , windowHeight , xClickPoints , yClickPoints , showGraph , mouseX , mouseY , openFilePath , r , g , b , a , layer , layerTree , modalNum } = app in { mode = mode , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , mouseX = mouseX , mouseY = mouseY , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = modalNum } end fun arrowY (app, arrowY) = let val { mode , arrowX , arrowY = _ , canvasWidth , canvasHeight , windowWidth , windowHeight , xClickPoints , yClickPoints , showGraph , mouseX , mouseY , openFilePath , r , g , b , a , layer , layerTree , modalNum } = app in { mode = mode , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , mouseX = mouseX , mouseY = mouseY , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = modalNum } end fun windowResize (app: app_type, windowWidth, windowHeight) : app_type = let val { mode , xClickPoints = _ , yClickPoints = _ , windowWidth = _ , windowHeight = _ , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , mouseX , mouseY , openFilePath , r , g , b , a , layer , layerTree , modalNum } = app val (xClickPoints, yClickPoints) = ClickPoints.generate (windowWidth, windowHeight, canvasWidth, canvasHeight) in { mode = mode , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , mouseX = mouseX , mouseY = mouseY , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = modalNum } end fun mousePosition (app: app_type, mouseX, mouseY) = let val { mode , mouseX = _ , mouseY = _ , xClickPoints , yClickPoints , windowWidth , windowHeight , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , r , g , b , a , layer , layerTree , modalNum } = app in { mode = mode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = modalNum } end fun graphVisibility (app: app_type, shouldShowGraph) = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , arrowX , arrowY , canvasWidth , canvasHeight , showGraph = _ , openFilePath , r , g , b , a , layer , layerTree , modalNum } = app in { mode = mode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = shouldShowGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = modalNum } end fun mode (app: app_type, newMode) = let val { mode = _ , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , r , g , b , a , layer , layerTree , modalNum } = app in { mode = newMode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = modalNum } end fun modalNum (app: app_type, newNum) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , r , g , b , a , layer , layerTree , modalNum = prevNum } = app val newNum = (prevNum * 10) + newNum in { mode = mode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = newNum } end fun r (app: app_type) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , r = _ , g , b , a , layer , layerTree , modalNum } = app val r = Int.min (modalNum, 255) in { mode = mode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = 0 } end fun g (app: app_type) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , r , g = _ , b , a , layer , layerTree , modalNum } = app val g = Int.min (modalNum, 255) in { mode = mode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = 0 } end fun b (app: app_type) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , r , g , b = _ , a , layer , layerTree , modalNum } = app val b = Int.min (modalNum, 255) in { mode = mode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = 0 } end fun a (app: app_type) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , r , g , b , a = _ , layer , layerTree , modalNum } = app val a = Int.min (modalNum, 255) in { mode = mode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = 0 } end fun layer (app: app_type) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , r , g , b , a , layer = _ , layerTree , modalNum } = app val layer = Int.max (modalNum, 1) in { mode = mode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = 0 } end fun layerTree (app: app_type, layerTree, arrowX, arrowY) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , arrowX = _ , arrowY = _ , canvasWidth , canvasHeight , showGraph , openFilePath , r , g , b , a , layer , layerTree = _ , modalNum } = app in { mode = mode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = modalNum } end fun canvasWidth (app: app_type, newCanvasWidth, newLayerTree) = let val { mode , canvasWidth = _ , arrowX , arrowY , canvasHeight , windowWidth , windowHeight , xClickPoints , yClickPoints , showGraph , mouseX , mouseY , openFilePath , r , g , b , a , layer , layerTree = _ , modalNum } = app val arrowX = Int.min (arrowX, newCanvasWidth) val (xClickPoints, yClickPoints) = ClickPoints.generate (windowWidth, windowHeight, newCanvasWidth, canvasHeight) in { mode = mode , canvasWidth = newCanvasWidth , arrowX = arrowX , mouseX = mouseX , mouseY = mouseY , arrowY = arrowY , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = newLayerTree , modalNum = 0 } end fun canvasHeight (app: app_type, newCanvasHeight, newLayerTree) = let val { mode , canvasHeight = _ , canvasWidth , arrowX , arrowY , windowWidth , windowHeight , xClickPoints , yClickPoints , showGraph , mouseX , mouseY , openFilePath , r , g , b , a , layer , layerTree = _ , modalNum } = app val arrowY = Int.min (arrowY, newCanvasHeight) val (xClickPoints, yClickPoints) = ClickPoints.generate (windowWidth, windowHeight, canvasWidth, newCanvasHeight) in { mode = mode , canvasHeight = newCanvasHeight , canvasWidth = canvasWidth , arrowX = arrowX , mouseX = mouseX , mouseY = mouseY , arrowY = arrowY , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = newLayerTree , modalNum = 0 } end fun cursorColour (app, r, g, b, a) = let val { mode , canvasHeight , canvasWidth , arrowX , arrowY , windowWidth , windowHeight , xClickPoints , yClickPoints , showGraph , mouseX , mouseY , openFilePath , r = _ , g = _ , b = _ , a = _ , layer , layerTree , modalNum } = app in { mode = mode , canvasHeight = canvasHeight , canvasWidth = canvasWidth , arrowX = arrowX , mouseX = mouseX , mouseY = mouseY , arrowY = arrowY , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = 0 } end fun parsedLayerTree (app: app_type, layerTree, canvasWidth, canvasHeight) : app_type = let val { mode , mouseX , mouseY , xClickPoints = _ , yClickPoints = _ , windowWidth , windowHeight , arrowX , arrowY , canvasWidth = _ , canvasHeight = _ , showGraph , openFilePath , r , g , b , a , layer , layerTree = _ , modalNum } = app val arrowX = if canvasWidth = 0 then 0 else Int.min (canvasWidth - 1, arrowX) val arrowY = if canvasHeight = 0 then 0 else Int.min (canvasHeight - 1, arrowY) val (xClickPoints, yClickPoints) = ClickPoints.generate (windowWidth, windowHeight, canvasWidth, canvasHeight) in { mode = mode , mouseX = mouseX , mouseY = mouseY , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , r = r , g = g , b = b , a = a , layer = layer , layerTree = layerTree , modalNum = modalNum } end end