2024-08-08 05:56:20 +01:00
|
|
|
signature APP_INIT =
|
2024-08-08 01:37:46 +01:00
|
|
|
sig
|
2024-09-20 21:33:35 +01:00
|
|
|
val fromWindowWidthAndHeight: int * int * int -> AppType.app_type
|
2024-08-08 01:37:46 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
structure AppInit :> APP_INIT =
|
2024-08-08 00:18:03 +01:00
|
|
|
struct
|
|
|
|
|
open AppType
|
|
|
|
|
|
2024-08-08 01:37:46 +01:00
|
|
|
fun helpFromWidthAndHeight
|
2024-09-20 21:33:35 +01:00
|
|
|
( windowWidth
|
|
|
|
|
, windowHeight
|
|
|
|
|
, wStart
|
|
|
|
|
, wFinish
|
|
|
|
|
, hStart
|
|
|
|
|
, hFinish
|
|
|
|
|
, numClickPoints
|
|
|
|
|
) : app_type =
|
2024-08-08 01:37:46 +01:00
|
|
|
let
|
2024-09-20 21:33:35 +01:00
|
|
|
val xClickPoints = ClickPoints.generate (wStart, wFinish, numClickPoints)
|
|
|
|
|
val yClickPoints = ClickPoints.generate (hStart, hFinish, numClickPoints)
|
2024-08-08 01:37:46 +01:00
|
|
|
in
|
2024-09-24 21:54:19 +01:00
|
|
|
{ mode = AppType.NORMAL_MODE
|
|
|
|
|
, triangles = []
|
2024-08-08 01:37:46 +01:00
|
|
|
, triangleStage = NO_TRIANGLE
|
|
|
|
|
, windowWidth = windowWidth
|
|
|
|
|
, windowHeight = windowHeight
|
2024-09-20 21:33:35 +01:00
|
|
|
, numClickPoints = numClickPoints
|
2024-08-08 01:37:46 +01:00
|
|
|
, xClickPoints = xClickPoints
|
|
|
|
|
, yClickPoints = yClickPoints
|
2024-08-08 06:34:40 +01:00
|
|
|
, undo = []
|
2024-08-08 23:10:38 +01:00
|
|
|
, redo = []
|
2024-08-08 21:58:50 +01:00
|
|
|
, mouseX = 0.0
|
|
|
|
|
, mouseY = 0.0
|
2024-08-14 02:31:28 +01:00
|
|
|
, showGraph = true
|
2024-09-20 10:17:57 +01:00
|
|
|
, arrowX = 0
|
|
|
|
|
, arrowY = 0
|
2024-08-08 01:37:46 +01:00
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-20 21:33:35 +01:00
|
|
|
fun fromWindowWidthAndHeight (windowWidth, windowHeight, numClickPoints) =
|
2024-08-08 01:37:46 +01:00
|
|
|
if windowWidth = windowHeight then
|
|
|
|
|
helpFromWidthAndHeight
|
2024-09-20 21:33:35 +01:00
|
|
|
( windowWidth
|
|
|
|
|
, windowHeight
|
|
|
|
|
, 0
|
|
|
|
|
, windowWidth
|
|
|
|
|
, 0
|
|
|
|
|
, windowHeight
|
|
|
|
|
, numClickPoints
|
|
|
|
|
)
|
2024-08-08 01:37:46 +01:00
|
|
|
else if windowWidth > windowHeight then
|
|
|
|
|
let
|
|
|
|
|
val difference = windowWidth - windowHeight
|
|
|
|
|
val wStart = difference div 2
|
|
|
|
|
val wFinish = wStart + windowHeight
|
|
|
|
|
in
|
|
|
|
|
helpFromWidthAndHeight
|
2024-09-20 21:33:35 +01:00
|
|
|
( windowWidth
|
|
|
|
|
, windowHeight
|
|
|
|
|
, wStart
|
|
|
|
|
, wFinish
|
|
|
|
|
, 0
|
|
|
|
|
, windowHeight
|
|
|
|
|
, numClickPoints
|
|
|
|
|
)
|
2024-08-08 01:37:46 +01:00
|
|
|
end
|
|
|
|
|
else
|
2024-08-08 00:18:03 +01:00
|
|
|
let
|
2024-08-08 01:37:46 +01:00
|
|
|
val difference = windowHeight - windowWidth
|
|
|
|
|
val hStart = difference div 2
|
|
|
|
|
val hFinish = hStart + windowWidth
|
2024-08-08 00:18:03 +01:00
|
|
|
in
|
2024-08-08 01:37:46 +01:00
|
|
|
helpFromWidthAndHeight
|
2024-09-20 21:33:35 +01:00
|
|
|
( windowWidth
|
|
|
|
|
, windowHeight
|
|
|
|
|
, 0
|
|
|
|
|
, windowWidth
|
|
|
|
|
, hStart
|
|
|
|
|
, hFinish
|
|
|
|
|
, numClickPoints
|
|
|
|
|
)
|
2024-08-08 00:18:03 +01:00
|
|
|
end
|
|
|
|
|
end
|