formatt a couple of files

This commit is contained in:
2025-07-11 00:57:55 +01:00
parent d5fda8b488
commit 024f1293c0
2 changed files with 46 additions and 24 deletions

View File

@@ -5,8 +5,8 @@ end
structure GraphLines :> GRAPH_LINES =
struct
fun helpGenGraphLinesX (pos, xClickPoints, yClickPoints, acc,
windowWidth, windowHeight) =
fun helpGenGraphLinesX
(pos, xClickPoints, yClickPoints, acc, windowWidth, windowHeight) =
if pos = Vector.length xClickPoints then
Vector.concat acc
else
@@ -21,7 +21,7 @@ struct
val minY = Vector.sub (xClickPoints, 0)
val minY = (~(minY - halfHeight)) / halfHeight
val maxY = Vector.sub (xClickPoints, Vector.length xClickPoints - 1)
val maxY = (~(maxY - halfHeight)) /halfHeight
val maxY = (~(maxY - halfHeight)) / halfHeight
val acc = Ndc.ltrbToVertex (minusX, maxY, plusX, minY) :: acc
in
@@ -29,8 +29,8 @@ struct
(pos + 1, xClickPoints, yClickPoints, acc, windowWidth, windowHeight)
end
fun helpGenGraphLinesY (pos, yClickPoints, xClickPoints, acc,
windowWidth, windowHeight) =
fun helpGenGraphLinesY
(pos, yClickPoints, xClickPoints, acc, windowWidth, windowHeight) =
if pos = Vector.length yClickPoints then
acc
else
@@ -56,16 +56,16 @@ struct
end
fun helpGenerate (windowWidth, windowHeight, xClickPoints, yClickPoints) =
let
val acc = helpGenGraphLinesY (0, yClickPoints, xClickPoints, [], windowWidth, windowHeight)
in
helpGenGraphLinesX (0, xClickPoints, yClickPoints, acc, windowWidth, windowHeight)
end
fun generate (app: AppType.app_type) =
let
val {windowWidth, windowHeight, xClickPoints, yClickPoints, ...} = app
val acc = helpGenGraphLinesY
(0, yClickPoints, xClickPoints, [], windowWidth, windowHeight)
in
helpGenerate (windowWidth, windowHeight, xClickPoints, yClickPoints)
helpGenGraphLinesX
(0, xClickPoints, yClickPoints, acc, windowWidth, windowHeight)
end
fun generate (app: AppType.app_type) =
let val {windowWidth, windowHeight, xClickPoints, yClickPoints, ...} = app
in helpGenerate (windowWidth, windowHeight, xClickPoints, yClickPoints)
end
end

View File

@@ -149,8 +149,7 @@ struct
val xpos = Vector.sub (xClickPoints, hIdx)
val ypos = Vector.sub (yClickPoints, vIdx)
val model = AppWith.addSquare
(model, hIdx, vIdx, hIdx, vIdx)
val model = AppWith.addSquare (model, hIdx, vIdx, hIdx, vIdx)
val squares = #squares model
val dotVec = getDotVecFromIndices (model, hIdx, vIdx)
@@ -159,9 +158,16 @@ struct
val halfHeight = Real32.fromInt (windowHeight div 2)
val maxSide = Int.max (canvasWidth, canvasHeight)
val squares =
CollisionTree.toTriangles (windowWidth, windowHeight, squares, maxSide,
canvasWidth, canvasHeight, xClickPoints, yClickPoints)
val squares = CollisionTree.toTriangles
( windowWidth
, windowHeight
, squares
, maxSide
, canvasWidth
, canvasHeight
, xClickPoints
, yClickPoints
)
val drawMsg = DRAW_SQUARES_AND_DOTS {squares = squares, dots = dotVec}
in
(model, [DRAW drawMsg])
@@ -181,13 +187,29 @@ struct
let
val model = AppWith.windowResize (model, width, height)
val {squares, canvasWidth, canvasHeight, showGraph, arrowX, arrowY,
xClickPoints, yClickPoints, ...} =
model
val
{ squares
, canvasWidth
, canvasHeight
, showGraph
, arrowX
, arrowY
, xClickPoints
, yClickPoints
, ...
} = model
val maxSide = Int.max (canvasWidth, canvasHeight)
val squares = CollisionTree.toTriangles (width, height, squares, maxSide,
canvasWidth, canvasHeight, xClickPoints, yClickPoints)
val squares = CollisionTree.toTriangles
( width
, height
, squares
, maxSide
, canvasWidth
, canvasHeight
, xClickPoints
, yClickPoints
)
val graphLines =
if showGraph then GraphLines.generate model else Vector.fromList []