89 lines
2.1 KiB
Standard ML
89 lines
2.1 KiB
Standard ML
signature APP_INIT =
|
|
sig
|
|
val fromWindowWidthAndHeight: int * int * int * int -> AppType.app_type
|
|
end
|
|
|
|
structure AppInit :> APP_INIT =
|
|
struct
|
|
open AppType
|
|
|
|
fun helpFromWidthAndHeight
|
|
( windowWidth
|
|
, windowHeight
|
|
, wStart
|
|
, wFinish
|
|
, hStart
|
|
, hFinish
|
|
, widthClickPoints
|
|
, heightClickPoints
|
|
) : app_type =
|
|
let
|
|
val xClickPoints =
|
|
ClickPoints.generate (wStart, wFinish, widthClickPoints)
|
|
val yClickPoints =
|
|
ClickPoints.generate (hStart, hFinish, heightClickPoints)
|
|
in
|
|
{ mode = AppType.NORMAL_MODE
|
|
, triangles = []
|
|
, triangleStage = NO_TRIANGLE
|
|
, windowWidth = windowWidth
|
|
, windowHeight = windowHeight
|
|
, numClickPointsX = widthClickPoints
|
|
, numClickPointsY = heightClickPoints
|
|
, xClickPoints = xClickPoints
|
|
, yClickPoints = yClickPoints
|
|
, undo = []
|
|
, redo = []
|
|
, mouseX = 0.0
|
|
, mouseY = 0.0
|
|
, showGraph = true
|
|
, arrowX = 0
|
|
, arrowY = 0
|
|
, openFilePath = ""
|
|
, fileBrowser = Vector.fromList []
|
|
, fileBrowserIdx = 0
|
|
, r = 0.0
|
|
, g = 0.0
|
|
, b = 0.0
|
|
, num = 0
|
|
}
|
|
end
|
|
|
|
fun fromWindowWidthAndHeight
|
|
(windowWidth, windowHeight, widthClickPoints, heightClickPoints) =
|
|
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
|
|
, widthClickPoints
|
|
, heightClickPoints
|
|
)
|
|
end
|
|
else
|
|
let
|
|
val difference = windowHeight - windowWidth
|
|
val hStart = difference div 2
|
|
val hFinish = hStart + windowWidth
|
|
in
|
|
helpFromWidthAndHeight
|
|
( windowWidth
|
|
, windowHeight
|
|
, 0
|
|
, windowWidth
|
|
, hStart
|
|
, hFinish
|
|
, widthClickPoints
|
|
, heightClickPoints
|
|
)
|
|
end
|
|
end
|