signature APP_INIT = sig val fromWindowWidthAndHeight: int * int * int * int * string -> AppType.app_type end structure AppInit :> APP_INIT = struct open AppType fun helpFromWidthAndHeight ( windowWidth , windowHeight , wStart , wFinish , hStart , hFinish , canvasWidth , canvasHeight , filepath ) : app_type = let val (xClickPoints, yClickPoints) = ClickPoints.generate (windowWidth, windowHeight, canvasWidth, canvasHeight) val maxPoints = Int.max (canvasWidth, canvasHeight) val layerTree = LayerTree.init maxPoints in { mode = AppType.NORMAL_MODE , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , mouseX = 0.0 , mouseY = 0.0 , showGraph = true , arrowX = 0 , arrowY = 0 , openFilePath = filepath , r = 0 , g = 0 , b = 0 , a = 1 , layer = LayerTree.minKey , layerTree = layerTree , modalNum = 0 } end fun fromWindowWidthAndHeight (windowWidth, windowHeight, canvasWidth, canvasHeight, filepath) = if windowWidth > windowHeight then let val difference = windowWidth - windowHeight val wStart = difference div 2 val wFinish = wStart + windowHeight in helpFromWidthAndHeight ( windowWidth , windowHeight , wStart , wFinish , 0 , windowHeight , canvasWidth , canvasHeight , filepath ) end else let val difference = windowHeight - windowWidth val hStart = difference div 2 val hFinish = hStart + windowWidth in helpFromWidthAndHeight ( windowWidth , windowHeight , 0 , windowWidth , hStart , hFinish , canvasWidth , canvasHeight , filepath ) end end