2024-08-08 05:56:20 +01:00
|
|
|
signature APP_INIT =
|
2024-08-08 01:37:46 +01:00
|
|
|
sig
|
2024-08-08 05:56:20 +01:00
|
|
|
val fromWindowWidthAndHeight: 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-08-08 21:58:50 +01:00
|
|
|
(windowWidth, windowHeight, wStart, wFinish, hStart, hFinish) : app_type =
|
2024-08-08 01:37:46 +01:00
|
|
|
let
|
|
|
|
|
val xClickPoints = ClickPoints.generate (wStart, wFinish)
|
|
|
|
|
val yClickPoints = ClickPoints.generate (hStart, hFinish)
|
|
|
|
|
in
|
|
|
|
|
{ triangles = []
|
|
|
|
|
, triangleStage = NO_TRIANGLE
|
|
|
|
|
, windowWidth = windowWidth
|
|
|
|
|
, windowHeight = windowHeight
|
|
|
|
|
, 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-08-08 01:37:46 +01:00
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
2024-08-08 05:56:20 +01:00
|
|
|
fun fromWindowWidthAndHeight (windowWidth, windowHeight) =
|
2024-08-08 01:37:46 +01:00
|
|
|
if windowWidth = windowHeight then
|
|
|
|
|
helpFromWidthAndHeight
|
|
|
|
|
(windowWidth, windowHeight, 0, windowWidth, 0, windowHeight)
|
|
|
|
|
else 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)
|
|
|
|
|
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
|
|
|
|
|
(windowWidth, windowHeight, 0, windowWidth, hStart, hFinish)
|
2024-08-08 00:18:03 +01:00
|
|
|
end
|
|
|
|
|
end
|