Files
sml-projects/functional-core/app-init.sml

55 lines
1.6 KiB
Standard ML
Raw Normal View History

2024-08-08 05:56:20 +01:00
signature APP_INIT =
sig
2024-08-08 05:56:20 +01:00
val fromWindowWidthAndHeight: int * int -> AppType.app_type
end
structure AppInit :> APP_INIT =
2024-08-08 00:18:03 +01:00
struct
open AppType
fun helpFromWidthAndHeight
(windowWidth, windowHeight, wStart, wFinish, hStart, hFinish) : app_type =
let
val xClickPoints = ClickPoints.generate (wStart, wFinish)
val yClickPoints = ClickPoints.generate (hStart, hFinish)
val graphLines =
GraphLines.generate
(windowWidth, windowHeight, xClickPoints, yClickPoints)
in
{ triangles = []
, triangleStage = NO_TRIANGLE
, windowWidth = windowWidth
, windowHeight = windowHeight
, xClickPoints = xClickPoints
, yClickPoints = yClickPoints
, graphLines = graphLines
, undo = []
, mouseX = 0.0
, mouseY = 0.0
}
end
2024-08-08 05:56:20 +01:00
fun fromWindowWidthAndHeight (windowWidth, windowHeight) =
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
val difference = windowHeight - windowWidth
val hStart = difference div 2
val hFinish = hStart + windowWidth
2024-08-08 00:18:03 +01:00
in
helpFromWidthAndHeight
(windowWidth, windowHeight, 0, windowWidth, hStart, hFinish)
2024-08-08 00:18:03 +01:00
end
end