begin refactoring

This commit is contained in:
2024-08-08 00:18:03 +01:00
parent 7c2f74b33b
commit 894dca2017
10 changed files with 554 additions and 561 deletions

View File

@@ -0,0 +1,44 @@
structure AppInit =
struct
open AppType
local
fun init (windowWidth, windowHeight, wStart, wFinish, hStart, hFinish) =
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
}
end
in
fun fromWidthAndHeight (windowWidth, windowHeight) =
if windowWidth = windowHeight then
init (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
init (windowWidth, windowHeight, wStart, wFinish, 0, windowHeight)
end
else
let
val difference = windowHeight - windowWidth
val hStart = difference div 2
val hFinish = hStart + windowWidth
in
init (windowWidth, windowHeight, 0, windowWidth, hStart, hFinish)
end
end
end